kosaraju's algorithm

Kosaraju's algorithm is a two-pass algorithm to find the strongly connected components in a directed graph.

Step 1: - Create an empty stack to keep track of the order in which vertices are processed. - Perform depth-first search starting from each vertex, maintaining a list of visited vertices. - When there are no more adjacent unvisited vertices, add the current vertex to the stack.

Step 2: - Reverse the direction of all edges in the graph. - Pop vertices from the stack one by one and perform a depth-first search from each vertex, this time maintaining a list of visited vertices for each strongly connected component found.