fn insert_scc_with_deps<Id: Copy + Hash + Eq>(
get_id_dependencies: &dyn Fn(Id) -> Vec<Id>,
reordered_sccs: &mut LinkedHashSet<usize>,
scc_deps: &mut Vec<BTreeSet<usize>>,
sccs: &Vec<Vec<Id>>,
id_to_scc: &HashMap<Id, usize>,
scc_id: usize,
)
Expand description
The order in which Tarjan’s algorithm generates the SCCs is arbitrary, while we want to keep as much as possible the original order (the order in which the user generated the ids). For this, we iterate through the ordered ids and try to add the SCC containing the id to a new list of SCCs Of course, this SCC might have dependencies, so we need to add the dependencies first (in which case we have reordering to do). This is what this function does: we add an SCC and its dependencies to the list of reordered SCCs by doing a depth-first search. We also compute the SCC dependencies while performing this exploration.