Network::topSort -- topological
sorting of the nodes
Introduction computes a topological
sorting of the network Network::topSort(G)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)
ParametersG |
- | network |
Returnsa table of nodes.
DetailsG 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]
BackgroundNetwork::TopSort