Function petgraph::algo::toposort [−][src]
pub fn toposort<G>(
g: G,
space: Option<&mut DfsSpace<G::NodeId, G::Map>>
) -> Result<Vec<G::NodeId>, Cycle<G::NodeId>> where
G: IntoNeighborsDirected + IntoNodeIdentifiers + Visitable,
[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.