file: job.t package: muf status: alpha
Topological sort: Resolve a partial ordering into a total ordering.
The input is a block of pairs s t
interpreted
as meaning that s
must
precede t
in the result.
The result block contains a total ordering of the
given value, consistent with the given partial
ordering constraints, if possible, below
a t
result flag.
If the input block contains a constraint cycle,
then a consistent total ordering is not possible,
and a nil
result flag is returned; The
contents of the block are undefined.
The following example specifies that 'i' must precede 'x', 'n' must precede 'i', and 'u' must precede 'n'. The computed solution is unique:
Stack: [ 'i' 'x' 'n' 'i' 'u' 'n' | |tsort Stack: [ 'u' 'n' 'i' 'x' | t
Go to the first, previous, next, last section, table of contents.