## `Network::topSort` -- topological sorting of the nodes

#### Introduction

``Network::topSort`(G)` computes a topological sorting of the network `G`, i.e., a numbering T of the nodes, such that T[i] < T[j] whenever there is an edge [i,j] in the network.

#### Call(s)

`Network::topSort(G)`

#### Parameters

`G` | - | network

#### Returns

a table of nodes.

#### Details

- If `G` contains any cycle then a topological sorting does not exist and the call of `Network::topSort` results in an error.

#### Example 1

    >> Network([1,2,3,4],[[1,2],[2,4],[3,4]]):
       Network::topSort(%)

                                     table(
                                       4 = 4,
                                       2 = 3,
                                       3 = 2,
                                       1 = 1
                                     )

    >> Network::topSort(Network::complete(3))

          Error: Network contains cycle [Network::topSort]

#### Background

- Note that the returned ordering is hardly ever unique.

#### Changes

- used to be called `Network::TopSort`

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000