Advanced topics · Exercise 91 of 100
Size of a strongly connected component
In a directed graph, two vertices belong to the same strongly connected component when each can reach the other by following arrows. To find the whole component of one vertex, keep the vertices reachable from it that also have a path back to it. Count the starting vertex itself.
Try it yourself
A directed graph has the arrows A → B, B → C, C → A, C → D, D → E and E → D. These are its only arrows. How many vertices are in the strongly connected component containing C?
One-step hint
Make two lists starting at C. Follow the arrows forward for one list and backward for the other. Count the vertices common to both, including C.
Worked solution
- From C, the route through A and B returns to C, so all three vertices can reach each other.
- C can also reach D and E, but their arrows only lead back to each other. That leaves 3 vertices in C's component.