Introduction To Kosarajus Algorithm
Introduction To Kosarajus Algorithm
Kosaraju's Algorithm
Aa
by A.M. santhosh
Directed Graphs and Strongly Connected
Components
Directed graphs are collections of nodes (vertices) connected by directed edges. In such graphs, the concept of
strongly connected components (SCCs) is crucial. An SCC is a set of vertices where every vertex is reachable from
every other vertex within the same component.
The Two-Pass Approach of Kosaraju's
Algorithm
Pass 1: Reverse Graph Exploration
Perform a depth-first search (DFS) on the reverse of the input graph,
keeping track of the finishing times of vertices.
1 2
In an SCC, each vertex is All vertices in an SCC share a Kosaraju's algorithm efficiently
reachable from every other common ancestor, which is the identifies all SCCs by leveraging
vertex within the same last vertex visited during the the order of vertex exploration in
component. DFS on the reversed graph. the two passes.
Time Complexity and Space Complexity
of Kosaraju's Algorithm