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.
Provided we computed the SCCs (Strongly Connected Components) of a set of
identifier, and those identifiers are ordered, compute the set of SCCs where
the order of the SCCs and the order of the identifiers inside the SCCs attempt
to respect as much as possible the original order between the identifiers.
The ids vector gives the ordered set of identifiers.