Why it matters

Kosaraju's is simpler alternative to Tarjan. Same asymptotic; teach-friendly.

Advertisement

The architecture

DFS forward; record finish order.

DFS on reverse in finish order.

Trees = SCCs.

Kosaraju's SCC algorithmDFS forwardfinish orderReverse graphDFS in orderTrees= SCCsTwo-pass; simpler to teach; same O(V+E) complexity
Kosaraju's SCC algorithm.
Advertisement

How it works end to end

Two DFS passes.

Reverse graph.

O(V+E).