Connectivity and Components
Suppose a network engineer wants to know whether every server in a data center can send a message to every other server. Suppose an epidemiologist wants to know how far a disease can spread through a contact network. Both questions reduce to a single combinatorial idea: can you walk from one vertex to another along the edges of a graph? This article develops that idea rigorously. It starts from reachability between two vertices. It builds up to the notion of a connected graph and its connected components. Connectivity is one of the most basic structural questions one can ask about a graph. Yet it organizes an enormous amount of graph theory. Once we know a graph splits into pieces that cannot reach each other, we can study each piece separately. Many theorems about graphs are really theorems about connected graphs. These theorems extend to general graphs component by component. The idea also gives graph theory its first genuine equivalence relation. It turns "being connected" from a vague description into a precise partition of the vertex set. The big picture is this: reachability by walks (or equivalently by paths) is an equivalence relation on vertices. Its equivalence classes are the connected components of the graph. A graph is connected exactly when it has a single component. This sounds almost too simple to be a theorem. But proving it carefully — checking reflexivity, symmetry, transitivity, and the path-vs-walk subtlety — is exactly the kind of rigor that separates casual intuition from a working mathematical tool. This article gives the formal definitions of connectedness, components, and reachability. It proves that reachability is an equivalence relation whose classes are the components. It proves a companion characterization of components via maximal connected subgraphs. It works two nontrivial examples. It shows what breaks if a natural-looking hypothesis is dropped. It closes by connecting this material to the deeper measures of connectivity — vertex and edge connectivity. It also connects to the structural role connectivity plays in the theory of trees.
- Two vertices are connected if some walk (equivalently, some path) joins them; a graph is connected if every pair of vertices is.
- Reachability is an equivalence relation on the vertex set: reflexive, symmetric, transitive.
- Its equivalence classes are exactly the connected components of the graph — maximal connected subgraphs.
- A graph is connected iff it has exactly one connected component.
- Every walk between two vertices can be shortened to a path between them, so "connected by a walk" and "connected by a path" agree.
- Key idea: connectivity partitions any graph into independent connected pieces, and studying one connected graph at a time loses no generality.
Where this lives today
Connected components are computed by standard graph-search algorithms (breadth-first and depth-first search), which run in linear time in the size of the graph; this makes connectivity-checking one of the cheapest nontrivial questions in all of algorithmic graph theory, and it underlies union-find data structures used throughout computer science. In network engineering, checking whether a communication network stays connected after link failures is literally the question "is still ?" In social network analysis, connected components identify separate communities or clusters that share no path of acquaintance. In image processing, "connected component labeling" segments a binary image into blobs of touching pixels, a direct pixel-grid instance of this theorem. In percolation theory and statistical physics, the emergence of a single giant connected component in a random graph as edge density increases is a phase transition studied via exactly the equivalence-class machinery proved here. In cryptographic protocol design and distributed computing, connectivity of the underlying communication graph is a baseline assumption for consensus and broadcast protocols to even be possible. And in pure graph theory, connectivity is the natural first step before finer invariants: it sets up Vertex and Edge Connectivity (how many vertices or edges must be removed to disconnect a graph) and is exactly the hypothesis needed to state the defining property of trees as minimal connected graphs.
Ask the tutor: How do breadth-first search and depth-first search each compute the connected components of a graph, and why do both run in linear time?
Let be a graph (finite, undirected, simple unless stated otherwise; loops and multiple edges do not affect the definitions below).
Reachability. A vertex is said to reach a vertex , written , if or there exists a walk in from to , i.e. a sequence of vertices
with and for each .
Connected graph. is connected if for every pair ; equivalently, and there is a path between every pair of vertices (the equivalence of "walk" and "path" versions is proved below). By convention, the graph with a single vertex and no edges is connected; some authors also allow the empty graph to be vacuously connected, but we will only discuss graphs with .
Connected component. A connected component of is a maximal connected subgraph of : a subgraph that is connected, and such that no strictly larger subgraph of containing is connected. Equivalently (as we will prove), a connected component is the subgraph induced on an equivalence class of the relation . We write for the number of connected components of . Thus is connected precisely when .
Intuition
Picture a graph as a collection of islands (vertices) linked by bridges (edges). The relation says: you can walk from island to island crossing only bridges that exist. If every island can reach every other island, the whole archipelago is "one piece" — connected. If not, the archipelago naturally splits into clusters of islands that are internally fully reachable but mutually unreachable across clusters. Those clusters are the connected components. The key mental habit to build is that reachability behaves like an equivalence relation, the same kind of object as "same remainder mod " or "same parity." Once you see as an equivalence relation, the whole theory of components becomes a special case of a fact you already know: an equivalence relation partitions a set into disjoint classes. The only graph-theoretic work is showing that walks compose (to get transitivity), reverse (to get symmetry), and that a single vertex reaches itself (reflexivity).
Let be a graph with . Then: 1. The relation defined by iff or there is a walk from to is an equivalence relation on . 2. For every pair of vertices , if and only if there is a path from to (not merely a walk). 3. The equivalence classes of are precisely the vertex sets of the connected components of : each equivalence class, together with all edges of joining two vertices in that class, is a maximal connected subgraph, and every maximal connected subgraph arises this way. 4. Consequently the connected components partition and partition (every edge lies in exactly one component), and
We prove the four parts in order, using the definitions above and basic facts about walks.
(1) is an equivalence relation. Reflexivity. For any , holds by the "" clause in the definition (the trivial walk of length ). Symmetry. Suppose . If this is symmetric trivially. Otherwise there is a walk
with for each . Since the graph is undirected, for each , so the reversed sequence
is also a walk, this time from to . Hence . Transitivity. Suppose and . If then follows immediately from ; similarly if . So assume there is a walk
and a walk
Concatenating the sequences,
gives a sequence of vertices in which every consecutive pair is joined by an edge of (each consecutive pair within the first walk and within the second walk is an edge by hypothesis, and the join point contributes no new pair since it is a single vertex, not a new step). This is a walk from to , so . Since is reflexive, symmetric, and transitive on , it is an equivalence relation.
(2) Walk-reachability equals path-reachability. If there is a path from to , a path is in particular a walk (a walk with no repeated vertices), so by definition. This proves one direction (and holds even if , taking the length- path). Conversely, suppose via a walk . We show by strong induction on that a path from to exists. Base case : then , and the length- walk is already a path. Inductive step: suppose the claim holds for all walks of length less than , and let be a walk of length . If no vertex repeats among , the walk is already a path and we are done. Otherwise some vertex repeats: there exist indices with . Delete the segment strictly between them, forming the shorter sequence
Consecutive vertices in this shorter sequence are still joined by edges: within the untouched prefix and suffix this is inherited from the original walk, and at the splice point since that was an edge of the original walk. This is a walk from to of length (strictly shorter, since ). By the induction hypothesis applied to this strictly shorter walk, there is a path from to . By strong induction, every walk from to can be reduced to a path from to , completing the proof of (2).
(3) Equivalence classes are exactly the connected components. Let denote the equivalence class of under , and let denote the subgraph induced on : vertex set , and all edges of with both endpoints in . is connected. For any , we have and (by definition of the equivalence class and symmetry/reflexivity), so by transitivity , hence by part (2) there is a path from to using a walk witnessing . We must check this path lies entirely within , i.e. every vertex on it is in . Indeed, if is this path, then for every vertex on it, (walk along the initial segment of the path), so gives by transitivity. Hence the path lies in , showing and are connected within . As were arbitrary, is connected. is maximal. Suppose is a connected subgraph of with and ; we derive a contradiction. Since as subgraphs and they share the same intersection structure, has a vertex (if had the same vertex set as it could only add edges among vertices of , but already includes all edges of between vertices of , by definition of induced subgraph, so no edges could be added; hence any strictly larger must have an extra vertex). Since is nonempty (it contains ) and is connected, there is a path in from to ; this is in particular a walk in from to , so , i.e. — contradicting . Hence no strictly larger connected subgraph containing exists, and is a maximal connected subgraph, i.e. a connected component. Every connected component arises this way. Let be any maximal connected subgraph of , and pick any vertex of . We claim . Since is connected, every vertex of satisfies (a path within is a walk in ), so every vertex of lies in , giving . Conversely if then , so by part (2) there is a path from to in ; consider the subgraph (union of vertex and edge sets). It is connected, because any two vertices of are joined within , any two vertices of are joined within , and lies in both, so by transitivity of reachability-within-a-subgraph (the same argument as transitivity of , applied to walks confined to ) every vertex of reaches every other. Since is maximal and is connected, we must have , forcing . So as well, giving . Finally the edge sets agree too: , being an induced-enough maximal connected subgraph, must contain every edge of between two vertices of — for if some edge with were missing from , adding it back gives a strictly larger connected subgraph (still connected, since was already connected without needing ), contradicting maximality of . So consists of exactly all edges of within , i.e. . This proves the equivalence classes of correspond exactly, bijectively, to the connected components of .
(4) Partition and the connectedness criterion. Since is an equivalence relation on (part 1), its equivalence classes partition ; by part (3) these are exactly the vertex sets of the components, so the components partition . Every edge satisfies directly (the edge itself is a walk of length 1), so and lie in the same class/component; hence each edge lies inside exactly one component's induced subgraph, and the components partition as well. Finally, is connected (every pair of vertices satisfies ) if and only if has a single equivalence class, i.e. itself is one class — which by part (3) means there is exactly one connected component. This proves connected .
∎Worked examples
Example 1: Computing components of an explicit graph. Let have vertex set and edge set
There is no vertex numbered as isolated by omission — vertex appears only via edge , and all of – appear in some edge, so no vertex is isolated. We compute -classes directly. Start with vertex : it is joined to and directly; is joined to ; is joined to . So (edge), (edge), and via the walk . No edge touches from , so we cannot extend further from this side. Hence one candidate class is . Check maximality/closure: every edge with an endpoint in is — all four endpoints stay inside . So this is a full equivalence class (no missing outgoing edges), giving component with vertex set and edge set : a triangle with a pendant edge to . Now start from : (edge), (edge), (edge), and (edge). So all lie in one class. Checking closure: all edges touching this set are , with both endpoints inside ; no edge leaves this set. This is the second component : a triangle with a pendant edge to . By Theorem part (4), and partition (indeed , and they are disjoint), so these are all the components: , hence is not connected. Notice the asymmetry deliberately built in: 's pendant hangs off the triangle vertex , while 's pendant hangs off vertex — the two components are isomorphic as abstract graphs but attached to differently labeled anchor vertices, illustrating that component computation is about the labeled structure, not just isomorphism type.
Example 2: Verifying connectivity via path search, and reconstructing components after an edge deletion. Let have vertex set and edges
Is connected? We build a class starting at : (edge), (edge), so by transitivity; (edge) so ; (edge) so (also directly by the edge , consistent); (edge) so . Every vertex of is reachable from , and vertices are all accounted for, so has a single class itself. By Theorem part (4), is connected, . As a check via part (2), exhibit an explicit path (not just a walk) from to : — three edges, all in , no repeated vertices. Good, this confirms concretely. Now delete the edge from , forming . Recompute components. Starting from : , (direct edge), so , so . So far the class of contains — but does it contain ? The only edges touching in the original graph were and ; we removed , but remains in . So still holds via the direct edge , and , so in fact too! Let's redo this carefully: has edges (five edges, since we removed exactly one of the original six). Trace again from : (edge), (edge), (edge) gives , (edge) gives , (edge) gives . So every vertex is still reachable from — removing the single edge did not disconnect , because has an alternate route to the rest of the graph via . So is still connected, . This example is chosen precisely because the naive guess "deleting an edge increases the number of components" is false in general — it depends on whether that edge lies on a cycle (here, sits on the cycle , so removing it leaves an alternate path). This foreshadows the material on Vertex and Edge Connectivity, where the edges whose removal does disconnect a graph are singled out as bridges.
The theorem assumes is an undirected graph, and symmetry of used this crucially: from an edge we concluded as well, because in an undirected graph edges are unordered pairs. Consider instead a directed graph with vertex set and a single directed edge (arc set ), and define analogously using directed walks (walks that must follow arc directions). Then:
- holds: the arc is a directed walk from to .
- fails: there is no directed walk from to , since the only arc points from to and has no other arcs.
So is not symmetric on , hence not an equivalence relation, and the entire proof of part (1) collapses at the symmetry step — precisely where it used undirectedness of edges to reverse a walk. Consequently part (3) also fails in the naive form: the "reachability classes" of a directed graph (its strongly connected components) are generally not the same as its maximal connected subgraphs when you ignore direction (its weakly connected components). Here is weakly connected (one weakly-connected component ) but has two distinct strongly-connected components and , since neither reaches the other by directed walks. This shows undirectedness is not a cosmetic hypothesis: it is exactly what makes reachability symmetric, which is exactly what makes "connected component" a single well-defined notion rather than splitting into the weak/strong dichotomy that directed graph theory must track separately.
Scope, edge cases & common traps
| Situation | What happens | Common mistake |
|---|---|---|
| has an isolated vertex (no incident edges) | is its own component (trivially connected, one vertex) | Forgetting isolated vertices count as components; miscounting |
| is empty graph on vertices, no edges | ; is disconnected unless | Assuming "no edges" is a degenerate/undefined case |
| has multiple edges or loops (multigraph) | Definitions of and components are unaffected; a loop never helps reachability beyond reflexivity, which already holds | Thinking a loop at is needed to get |
| Directed graphs | Must distinguish weak connectivity (ignore direction) from strong connectivity (respect direction); Theorem as stated does not directly apply | Applying the undirected theorem's symmetry step to digraphs |
| Single-vertex graph | Connected by convention; | Calling it "disconnected" for lacking edges |
| Walk vs. path in the definition | Interchangeable for defining , by part (2) of the theorem | Assuming you must always exhibit a path immediately, rather than allowing any walk and reducing later |
The mathematician behind it
Origins · 1 minLeonhard Euler and how this was discovered
Euler did not use the modern vocabulary of vertices, edges, or connected components, but his 1736 resolution of the Seven Bridges of Königsberg problem is the historical seed from which this entire subject grew. He recognized that the only combinatorial data relevant to a walking-tour question was which landmasses were joined by which bridges — an abstraction that, a century and a half later, would be formalized as a graph, with connectivity and reachability as its most primitive structural questions. The rigorous equivalence-relation treatment of components used above belongs to the modern axiomatic era, but its motivating question — can I get from here to there? — is exactly Euler's.
Origins · 1 minhow this was discovered
Is a graph with zero vertices considered connected?
Most textbooks either exclude the empty graph from the discussion or declare it connected vacuously, since the condition "every pair of vertices is joined by a path" is vacuously true when there are no vertices to check. This article restricts attention to graphs with specifically to avoid this edge case, since the count becomes ambiguous (some say , others ) for the empty graph, and different authors adopt different conventions. In practice this convention almost never matters, since applications virtually always involve at least one vertex.
Why does the theorem bother proving that walk-reachability equals path-reachability?
Because the two notions look interchangeable but are not logically identical, and the difference matters for later results. A walk allows repeated vertices and edges; a path forbids them. The theorem shows that whenever a walk connects to , some (generally shorter) path also does, by repeatedly excising cycles formed by repeated vertices. This upgrade from "walk" to "path" is essential later, for instance when proving results about shortest paths, spanning trees, or distances, all of which are stated in terms of paths rather than arbitrary walks.
How is this different from the notion of a "clique" or "complete subgraph"?
A connected component only requires that vertices be reachable from one another via some path; it says nothing about how many edges are present. A component can be a single long path with very few edges, while a clique requires every pair of vertices to be directly adjacent. Every clique is connected, but a connected graph (or component) need not contain any large clique at all — a tree, for example, is connected yet has no cycle, let alone a clique larger than an edge.
Does adding an edge to a graph ever increase the number of components?
No. Adding an edge to can only merge two components into one (if and were previously in different components) or leave the component count unchanged (if and were already in the same component). This follows directly from the equivalence-class description: adding an edge can only add new pairs to the relation by transitivity, never remove existing reachability, since every walk in remains a walk in plus an edge.
How do I actually compute the connected components of a graph in practice?
Algorithmically, you run a breadth-first or depth-first search from an arbitrary unvisited vertex, mark every vertex reached as belonging to the current component, and repeat starting from any unvisited vertex until none remain. This is a direct computational implementation of the equivalence-class construction in the proof: each search execution computes exactly one class of the relation . The total running time is linear in the number of vertices plus edges, since each edge and vertex is examined a constant number of times.
Is "connected" the same as "2-connected" or "highly connected"?
No, and this distinction is exactly what the follow-up theory of Vertex and Edge Connectivity addresses. "Connected" only requires , i.e., no isolated pieces; a graph can be connected via a single fragile bridge edge whose removal disconnects it. Stronger notions like -connectivity require that connectivity survive the removal of any single vertex, giving a quantitative refinement of the qualitative yes/no notion developed in this article.
Why is the maximality condition in the definition of "connected component" necessary?
Without maximality, "connected subgraph" alone is far too weak: a single edge, or even a single vertex, is a connected subgraph of almost any graph, but it is not what we mean by a "component." Maximality forces us to take the largest connected piece containing a given vertex, which is exactly what makes components well-defined, mutually disjoint, and in bijection with equivalence classes of , as proved in the theorem.