Strongly connected components
In a directed graph, a strongly connected component is a largest group where every vertex can reach every other. Kosaraju's algorithm runs DFS once to order vertices by finishing time, then runs DFS on the reversed graph in reverse finishing order; each search there collects exactly one component.
How to recognise it
- Directed graphs where mutual reachability matters.
- Collapsing cycles into single nodes.
- Counting groups that can all reach each other.
Kosaraju in two passes
pass 1: DFS on the graph; push each vertex when it finishes
pass 2: on the reversed graph, take vertices from the latest finished;
each DFS from an unvisited one is one SCC
Vertices, edges, adjacency lists and the other words used here are on the Structures page.
Common mistakes
- Running the second pass on the original graph.
- Taking vertices in the wrong order in the second pass.
Problems
- Kosaraju's algorithmmediumguide ready