INAIO Guide Stage 1 12Graph Theory and Algorithms
12.5 Strongly connected components
Find mutually reachable groups, compress them into a simpler graph, and identify terminal components.
In Module 12.2, a directed route from to did not guarantee a route back. Now ask a stronger question: which vertices can reach one another in both directions? If can reach and can reach , they can communicate through the network even if they have no direct two-way edge. If and can also reach one another, joining those routes shows that and can reach one another too. This lets us group vertices by mutual reachability.
A strongly connected component (SCC) is one of these groups, extended as far as possible: every vertex in it can reach every other, and no additional vertex can join while that remains true. We use SCCs to compress a complicated network of cycles into a simpler map of one-way movement between groups. In a task-dependency graph, a component containing a cycle exposes a circular dependency. The compressed map also reveals sink components, which have no outgoing edge to another group. A process following edges can enter such a component but cannot leave it; that matters for state transitions and the random walks in Module 12.6.
This is intermediate graph theory. Review reachability and DFS first. The Johns Hopkins SCC lecture notes give a full algorithmic treatment.
A basic idea: mutual reachability makes a group
Suppose , , , , , and . First check return routes: and reach each other, and and reach each other. The arrow lets the first pair reach the second, but there is no route from back to , so the pairs cannot be one SCC. Vertex has no way back to the others and forms a component by itself. The three groups are , , and .
A quick tour of components and sinks
Maximal means that we cannot add another vertex to the group while keeping mutual reachability; it does not mean that the component has more vertices than every other component. Each vertex belongs to exactly one SCC. A single vertex is an SCC even without a self-loop, because a zero-length path reaches itself. An edge inside an SCC is allowed; a sink SCC only forbids edges leaving for a different SCC.
Compress every SCC into one node, keeping arrows between different components. This condensation graph has no directed cycle: if a cycle joined several components, each could reach the others and they would actually be one SCC. Therefore the condensation graph is a directed acyclic graph. A finite nonempty condensation graph has at least one sink.
For a small graph, trace reachability in both directions, group mutually reachable vertices, then scan outgoing edges from each group. For a large graph, Kosaraju's algorithm uses two DFS passes:
- DFS the original graph and record vertices when their searches finish.
- Reverse every edge.
- DFS the reversed graph in decreasing order of first-pass finishing time. Each new search marks one SCC.
The finishing order and reversal prevent a second-pass search from mixing components linked only one way. With adjacency lists, the two passes take time. The small-graph grouping method is enough to answer most hand questions; the two-pass algorithm makes the same task efficient on large graphs.
Application 1: web pages that link one way
Pages have links , , , and . Find the SCCs and sink SCCs.
- Find mutual groups. reach each other; reach each other; stands alone. The SCCs are , , .
- Compress. The component arrows are .
- Identify sinks. Only has no arrow to another component, so it is the sole sink SCC.
Application 2: two possible terminal groups
A process has states and moves , , , , and . Which components can trap a path once entered?
- Group mutual reachability. The SCCs are , , and .
- Check outgoing edges. points to both other groups. Neither nor points out.
- Conclude. Both and are sink SCCs. A path entering either cannot reach the other under these moves.
The two sinks explain why a process without added moves may have different long-run outcomes depending on its route.
Resources
| Source | Title | Why read it |
|---|---|---|
| Johns Hopkins University | Strongly Connected Components | Study the two-pass DFS algorithm after the small-graph examples. |
Finished this module? Mark it done.
Comments
Stuck on something, spotted a mistake, or found a resource that helped you? Tell us below.
Loading comments