topo_sort: Topological Sorting of Dependency Graphs
Description
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 depth,
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.