pub fn topo_sort<Id, PredsIter>(
node_ids: impl IntoIterator<Item = Id>,
preds_fn: impl FnMut(Id) -> PredsIter,
) -> Result<Vec<Id>, Vec<Id>>Expand description
Topologically sorts a set of nodes. Returns a list where the order of Ids will agree with
the order of any path through the graph.
This succeeds if the input is a directed acyclic graph (DAG).
If the input has a cycle, an Err will be returned containing the cycle. Each node in the
cycle will be listed exactly once.
https://en.wikipedia.org/wiki/Topological_sorting#Depth-first_search