pub fn toposort<G>(
g: G,
space: Option<&mut DfsSpace<<G as GraphBase>::NodeId, <G as Visitable>::Map>>
) -> Result<Vec<<G as GraphBase>::NodeId>, Cycle<<G as GraphBase>::NodeId>>
Expand description
[Generic] Perform a topological sort of a directed graph.
If the graph was acyclic, return a vector of nodes in topological order:
each node is ordered before its successors.
Otherwise, it will return a Cycle
error. Self loops are also cycles.
To handle graphs with cycles, use the scc algorithms or DfsPostOrder
instead of this function.
If space
is not None
, it is used instead of creating a new workspace for
graph traversal. The implementation is iterative.