Performs a topological sort on the given directed graph.
Performs a topological sort on the given directed graph.
Uses post-order DFS (DfsOrder.Post) via Traversal.dfs so that each vertex appears in the journal only after all vertices reachable from it. The resulting list is in reverse post-order (i.e. topological order).
Returns None if the graph is cyclic.
Type parameters
E
the edge attribute type.
V
the vertex attribute type.
Value parameters
graph
the directed graph to sort.
Attributes
Returns
Some(Seq[V]) in topological order, or None if the graph is cyclic.