Topological Sorting of Dependency GraphsSource:
Topologically sort a graph, where we are passed node labels and a list of direct
parents for each node, as labels, too.
A node can be 'processed' if all its parents have been 'processed',
and hence occur at previous indices in the resulting sorting.
Returns a table, in topological row order for IDs, and an entry
which encodes the topological layer, starting at 0.
So nodes with
depth == 0 are the ones with no dependencies,
and the one with maximal
depth are the ones on which nothing else depends on.
Has 2 columns:
character, contains all node labels.
character, contains all direct parents label of
data.table::data.table()) with columns
depth, sorted topologically for IDs.