Is there an algorithm that, given an unweighted directed acyclic graph, sorts all nodes into a list of sets of nodes such that
- the topological order is preserved (i.e., for all edges
u->v
,v
occurs in a set further down the list thanu
) and - the length of the list is minimal.
Is there a name for this problem?
Example
A possible sort for the graph below would be
[1], [2, 3], [4, 5], [6, 7]
An alternative solution would be
[1], [2, 3], [4], [5, 6, 7]