Expand description
Topological sorting and strongly connected components of directed graphs.
See the book entry Graphs, traversal and orderings.
Functions§
- condensation
- The condensation: the directed acyclic graph of strongly connected components.
- strongly_
connected_ components - Strongly connected components by Tarjan’s algorithm (iterative,
O(V + E)). Returns the component label of each vertex; labels are a reverse topological order of the condensation (component 0 has no edges to other components). - topological_
sort - A topological order (every edge
u → vhasubeforev) by Kahn’s algorithm, taking the smallest ready vertex at each step, so the result is the lexicographically smallest topological order.O((V + E) log V). Returns an error if the graph has a cycle.