Connected Components by Hand
A connected component of an undirected graph contains all vertices reachable from one another. Components form a partition of the vertex set.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Sketch two clusters
Edges A–B and C–D leave components \(\{A,B\}\) and \(\{C,D\}\). An isolated E is its own component. Reachability identifies each cluster by starting once from any member.
Label before doing another search
After finishing the first cluster, choose an unvisited source and label all its discovered vertices together. This avoids exploring the same component again. See partitions for why each vertex has exactly one such label.[1]
Restart search at each unseen vertex
In undirected graph with A–B and B–C, D–E, and isolated F, starting at B discovers A, B and C. Restarting at D finds D and E. Restarting at F yields a singleton. A single search from B cannot report the remaining two components. See reachability.
First search: {A,B,C}
Second search: {D,E}
Third search: {F}
Total = 3 components and 6 vertices
Validate the partition using edges and reachability
Every vertex should belong to exactly one set. An edge between two claimed components disproves the split. Each reported subset must also be internally connected. Directed edges require a choice between undirected connectivity and mutual reachability.