Kosaraju
Finish order from one DFS, reverse every edge, then DFS from the latest finisher to paint each component.
Bridges and Components: Kosaraju on the same graph
Pass 2: the unassigned vertex with the latest finish time is 0, finish 7. Start a DFS there on the reversed graph. It opens component 0.
Cost
- Best
- O(V + E)
- Average
- O(V + E)
- Worst
- O(V + E)
- Space
- O(V)
Before this
Related
Taught by the same lesson
Bridges and Components covers these too, in the same run.