Skip to content

Strongly Connected Components

In a directed graph, vertices u and v belong to the same strongly connected component (SCC) when each can reach the other. SCCs partition the vertices.

Contract every SCC to one meta-vertex. The resulting condensation graph is a directed acyclic graph: a cycle among components would make them mutually reachable and therefore one component.

Kosaraju–Sharir

  1. Run DFS and record vertices by finish time.
  2. Reverse every edge.
  3. Process vertices in decreasing original finish time, running DFS in the reversed graph. Each new traversal yields one SCC.

Both traversals and reversal cost Θ(V + E) time, with Θ(V + E) additional storage when the transpose is materialized.

Tarjan

Tarjan's algorithm uses one DFS, a stack, discovery indices, and low-link values. A vertex roots an SCC when its low-link equals its discovery index; the stack is popped through that root. It also runs in Θ(V + E) time and uses Θ(V) working space beyond the graph.

Low-link is not merely the minimum neighbor number. Its update distinguishes a DFS-tree edge from an edge to a vertex still on the active stack.

Applications

SCCs expose cycles of mutual dependency, permit topological processing of a directed graph's condensation, and support reachability and program-analysis decompositions.

Exercises

  1. Prove that the condensation graph is acyclic.
  2. Trace both algorithms on a graph with three SCCs.
  3. Explain why connected components are insufficient for directed graphs.