pub fn topo_sort<T, Id>(deps: T) -> Result<Vec<Id>, Box<dyn Error>>
Expand description
topo_sort sorts the dependencies topologically. It returns a Vec of the sorted nodes. If a cyclic reference is detected, it returns an error.
ยงExample
use rk_utils::topo_sort;
use std::collections::{ HashMap, HashSet };
let mut deps = HashMap::new();
deps.insert("b".to_string(), HashSet::from(["a".to_string()]));
deps.insert("c".to_string(), HashSet::from(["b".to_string()]));
let sorted = topo_sort(&deps).unwrap();
assert_eq!(sorted, ["a", "b", "c"]);