The Kosaraju-Sharir Algorithm

Learn about the Kosaraju-Sharir algorithm for identifying strongly connected components.

The Kosaraju-Sharir algorithm finds the strongly connected components of a digraph by requiring two passes of depth-first search. While this algorithm performs more work than Tarjan’s algorithm, it’s elegant in its simple presentation and is easier to understand. Interestingly, despite the extra work, its running time remains asymptotically the same as that of depth-first search, i.e., O(n+m)O(n+m), where nn and mm are the numbers of vertices and edges, respectively.

Get hands-on with 1200+ tech skills courses.