Tutorials › Graph Theory (Undergraduate) › Reachability as an Equivalence Relation

Paths, Cycles and Connectedness · Tutorial 51 of 799

Reachability as an Equivalence Relation

Learn how path-based reachability satisfies the three defining properties of an equivalence relation, including why a vertex reaches itself by a path of length zero.

Beginner 8 min read

What You'll Learn

  • Define the reachability relation on the vertex set of an undirected graph.
  • Explain why a path of length zero makes reachability reflexive.
  • Prove that reversing a path gives symmetry.
  • Prove transitivity by concatenating paths and removing repeated vertices.
  • Identify the reachability relation in graphs with isolated vertices.
  • Avoid confusing a length-zero path with a loop or a positive-length route.

Reachability Between Vertices

In an undirected graph, one vertex can reach another when there is a path joining them. This simple relation records which pairs of vertices are connected by routes through the graph. It has an important logical structure: each vertex reaches itself, reachability works in either direction, and two successive routes can be combined into a route. These are exactly the three properties that make a relation an equivalence relation.

Throughout, graphs are finite, simple and undirected. A path is a sequence of distinct vertices in which consecutive vertices are adjacent; its length is the number of edges in the sequence. We allow a path of length zero consisting of the single vertex \(v\). Its initial and final vertex are both \(v\). This convention does not assert that \(v\) has a loop: simple graphs have no loops.

Definition: For a graph \(G=(V,E)\), define a relation \(\sim\) on \(V\) by \(u\sim v\) if and only if there is a path from \(u\) to \(v\). We say that \(u\) and \(v\) are reachable from one another.

A relation on a set is called an equivalence relation if it is reflexive, symmetric and transitive. Reflexivity means \(x\sim x\) for every element \(x\); symmetry means \(x\sim y\) implies \(y\sim x\); transitivity means \(x\sim y\) and \(y\sim z\) together imply \(x\sim z\). We will verify each property from the definition of reachability.

A Useful Fact About Combining Routes

When two paths meet at a vertex, following the first and then the second gives a walk. The resulting walk may repeat vertices, so it need not itself be a path. The following fact explains why that causes no problem. A walk allows repeated vertices, whereas a path does not.

Lemma: If there is a walk from \(u\) to \(v\), then there is a path from \(u\) to \(v\).

Proof. Start with a walk \(v_0,v_1,\ldots,v_\ell\), where \(v_0=u\) and \(v_\ell=v\). If some vertex is repeated, choose indices \(i<j\) with \(v_i=v_j\). Delete the portion \(v_{i+1},\ldots,v_j\). If \(j<\ell\), the shortened sequence is still a walk: the step from \(v_i\) to \(v_{j+1}\) is valid because \(v_i=v_j\) and \(v_jv_{j+1}\) was an edge. If \(j=\ell\), the shortened walk still ends at \(u\)'s original destination \(v\), since \(v_i=v_\ell=v\). In either case, the endpoints are unchanged and the length decreases. Repeat this deletion whenever a vertex is repeated. The length is a nonnegative integer and decreases at every deletion, so the process stops. At that point there are no repeated vertices, and the resulting walk is a path. If the endpoints coincide, the length-zero path is permitted. \(\square\)

The Three Properties

Theorem: For every graph \(G=(V,E)\), the relation \(\sim\) of reachability on \(V\) is an equivalence relation.

Proof. We check the three properties.

Reflexivity. Let \(u\in V\). The sequence consisting only of \(u\) is a path of length zero from \(u\) to itself. Therefore \(u\sim u\).

Symmetry. Suppose \(u\sim v\). There is a path \(u=v_0,v_1,\ldots,v_k=v\). Read the same sequence in reverse: \(v=v_k,v_{k-1},\ldots,v_0=u\). Each consecutive pair remains adjacent because the graph is undirected, and the vertices remain distinct. Thus the reversed sequence is a path from \(v\) to \(u\), so \(v\sim u\).

Transitivity. Suppose \(u\sim v\) and \(v\sim w\). Choose a path from \(u\) to \(v\) and a path from \(v\) to \(w\). Following the first and then the second gives a walk from \(u\) to \(w\); the shared vertex \(v\) is included just once at the join. The walk may repeat other vertices, but by the lemma it contains a path with the same endpoints. Hence \(u\sim w\).

All three properties hold, so reachability is an equivalence relation. If \(V\) is empty, there are no vertices for which any of these conditions could fail, so the three universal statements hold vacuously. \(\square\)

The proof uses the assumptions in specific ways. The length-zero path supplies reflexivity without requiring a loop. Undirectedness is needed for reversing a path in the symmetry argument. For transitivity, the walks can be joined at their shared endpoint, and removing repetitions turns the joined walk into a path. In a directed graph, reversing a directed path need not give a directed path, so symmetry is not guaranteed.

Worked Example: An Isolated Vertex

Let \(G=(V,E)\) have \(V=\{1,2,3,4\}\) and \(E=\{12,23\}\). Determine the reachability relation.

Vertices \(1,2,3\) are pairwise reachable: the direct paths \(1,2\) and \(2,3\) use edges \(12\) and \(23\), and the path \(1,2,3\) joins \(1\) to \(3\). Reversing these paths gives the paths in the opposite directions. Each of these three vertices also reaches itself by a length-zero path. Vertex \(4\) has no incident edge, so it has no path to any other vertex; it still reaches itself by its length-zero path.

Thus the relation, written as ordered pairs, is \(\{(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,4)\}\). There are \(3\cdot3=9\) ordered pairs whose two entries are in \(\{1,2,3\}\), and the pair \((4,4)\) adds one, for \(9+1=10\) pairs altogether.

Check: Every listed pair has a path: the only nontrivial route needed beyond the edges is \(1,2,3\), and its reverse joins \(3\) to \(1\). No pair involving \(4\) and a different vertex can occur, because such a path would have to start or end with an edge incident to \(4\), and no such edge exists.

Worked Example: Reachability Through Several Edges

Let \(G=(V,E)\) have \(V=\{a,b,c,d,e\}\) and \(E=\{ab,bc,ca,cd\}\). Find the reachability relation without listing all its ordered pairs individually.

Among \(a,b,c,d\), the edges \(ab,bc,ca\) join \(a,b,c\), and \(cd\) joins \(c\) to \(d\). In particular, each of \(a,b,c\) can reach \(d\) by first reaching \(c\) and then using \(cd\). Reversing those routes shows that \(d\) can reach each of \(a,b,c\). The vertices \(a,b,c\) reach one another using the triangle edges. Therefore every vertex in \(\{a,b,c,d\}\) is reachable from every other vertex in that set.

Vertex \(e\) is incident to no edge, so it is not reachable from \(a,b,c,\) or \(d\), and none of those vertices is reachable from \(e\). The full relation is \(\{(x,y):x,y\in\{a,b,c,d\}\}\cup\{(e,e)\}\). The first set contains \(4\cdot4=16\) ordered pairs; adding \((e,e)\) gives \(16+1=17\).

Check: The relation has no pair \((x,e)\) or \((e,x)\) for \(x\in\{a,b,c,d\}\), because a path between \(e\) and any other vertex would need an edge incident to \(e\). The relation contains \((e,e)\) because the length-zero path at \(e\) is allowed.

Worked Example: Transitivity When a Joined Walk Repeats a Vertex

Let \(G=(V,E)\) have \(V=\{a,b,c,d\}\) and \(E=\{ac,cd,cb\}\). Consider the paths \(a,c,d\) from \(a\) to \(d\), and \(d,c,b\) from \(d\) to \(b\). They show \(a\sim d\) and \(d\sim b\).

Joining the paths gives the walk \(a,c,d,c,b\). It repeats \(c\), so it is not a path under the definition. Delete the segment from the first occurrence of \(c\) through the second occurrence of \(c\), retaining the shared vertex once. The remaining sequence is \(a,c,b\), which is a path because \(ac\in E\) and \(cb\in E\), and its vertices are distinct. Hence \(a\sim b\), as transitivity requires.

Check: The resulting route uses exactly the two edges \(ac\) and \(cb\), both of which belong to \(E\). It begins at \(a\), ends at \(b\), and has no repeated vertex.

Why the Length-Zero Convention Matters

The length-zero path is not a technical detail that can be omitted without changing the definition. It is what makes reachability reflexive in every graph, including graphs with isolated vertices. A positive-length path from a vertex back to itself would involve a cycle, and an isolated vertex has no such route. Requiring a positive length would therefore fail to establish \(v\sim v\) for every vertex.

The convention is also consistent with the rest of the proof. Reversing a length-zero path leaves the same path, so symmetry includes the case \(u=v\). When two paths are joined, one or both can have length zero. If the path from \(u\) to \(v\) has length zero, then \(u=v\), and the second path already joins \(u\) to \(w\). The transitivity conclusion still follows. The same reasoning applies if the second path has length zero. Thus no exception is needed for equal endpoints or trivial routes.

Common Pitfall

Wrong: “The graph has no loop at \(p\), so there is no path from \(p\) to \(p\), and reachability is not reflexive.” This confuses a loop, which would be an edge from a vertex to itself, with the length-zero path, which has no edges.

For example, take \(V=\{p,q\}\) and \(E=\{pq\}\). There is no loop at \(p\), but the one-vertex sequence \(p\) is a length-zero path from \(p\) to \(p\). Hence \(p\sim p\). The same argument gives \(q\sim q\), whether or not either vertex has any incident edges. Reflexivity comes from the path convention, not from the edge set.

Reachability is useful because it turns the question “Is there a route between these vertices?” into a relation with reliable structural rules. The theorem gives those rules directly: reverse a route to change its direction in an undirected graph, and concatenate routes to pass through an intermediate vertex. These conclusions depend only on the definition of path and the undirected nature of the graph.

Check Your Understanding

Use the definition of reachability and the three properties proved above.

  1. In a graph with \(V=\{x,y\}\) and \(E=\varnothing\), which ordered pairs belong to the reachability relation?
  2. Explain why the reverse of a path in an undirected graph is a path.
  3. Two paths meet at a vertex but their concatenation repeats a vertex. What fact allows you to conclude that their endpoints are still reachable?
  4. Which step in the proof of the theorem might fail for a directed graph, and why?
  5. Why would defining reachability using only positive-length paths fail to give a reflexive relation for every graph?