Back to problems

Count Strongly Connected Components Using Kosaraju's Algorithm

Algorithm · Expedia · Medium

Problem You are given a directed graph consisting of n nodes, labeled 0 through n - 1, and m directed edges. Implement Kosaraju's algorithm to determine the number of strongly connected components (SCCs) in the graph. A strongly connected component is a maximal subset of nodes such that for every pair of nodes u and v inside the subset, there exists a directed path from u to v and a directed path from v to u. Input Format Each line ui vi describes a single directed edge that…

Checking your access…