Function dfir_lang::graph::graph_algorithms::topo_sort

source ยท
pub fn topo_sort<Id, NodeIds, PredsFn, PredsIter>(
    node_ids: NodeIds,
    preds_fn: PredsFn,
) -> Result<Vec<Id>, Vec<Id>>
where Id: Copy + Eq + Ord, NodeIds: IntoIterator<Item = Id>, PredsFn: FnMut(Id) -> PredsIter, PredsIter: IntoIterator<Item = 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