Imagine a city whose streets are all one-way. Some neighbourhoods are tightly connected: you can drive from any intersection to any other and back again by following the one-way signs. Other districts are not â you can reach them but you can never return. Those tightly-connected pockets are strongly connected components (SCCs).
More precisely, given a directed graph, a strongly connected component is a maximal set of vertices such that there is a directed path from every vertex in the set to every other. Two nodes belong to the same SCC if and only if they lie on a common directed cycle.
The question "what are all the SCCs?" might sound like it requires many passes over the graph, one per component. In 1972, Robert Tarjan showed otherwise: a single depth-first search (DFS) is enough â the algorithm runs in time, where V is the number of vertices and E the number of edges. This is solved: the problem is in P, and linear time is optimal because you must at least read the graph.
Tarjan's algorithm works by assigning each node a discovery index and a low-link value (the smallest index reachable via the current DFS tree and one back-edge). It uses a stack to collect candidates, popping an entire SCC the moment it recognises a root â a node whose low-link equals its own index.
Comments
Loading comments...