Tutorials › Graph Theory (Undergraduate) › Unique Paths Characterize Trees

Characterizations of Trees · Tutorial 94 of 799

Unique Paths Characterize Trees

Learn why connectedness gives paths, acyclicity guarantees their uniqueness, and unique paths in turn force a graph to be a tree.

Beginner 9 min read

What You'll Learn

  • Define paths, cycles and trees precisely for finite simple graphs.
  • Prove that two distinct paths with the same endpoints contain a cycle.
  • Show that every tree has a path between each pair of distinct vertices.
  • Prove that a cycle contradicts uniqueness of paths.
  • Apply the characterization to connected, cyclic and disconnected examples.
  • Distinguish a unique path from a unique shortest path.

Existence and Uniqueness of Paths

Connectedness answers whether two vertices can be joined; acyclicity rules out certain ways of joining them more than once. Together, these ideas give a precise characterization of trees: between any two distinct vertices there is exactly one path. The two parts of the statement play different roles. Connectedness supplies existence, while the absence of cycles supplies uniqueness.

Throughout, graphs are finite and simple: they have no loops or multiple edges. A path from \(u\) to \(v\) is a sequence \(v_0,v_1,\ldots,v_k\) with \(v_0=u\), \(v_k=v\), consecutive vertices adjacent, and all vertices distinct. Its length is \(k\), the number of edges in the sequence. Two paths are distinct if their vertex sequences differ. A cycle is a sequence \(v_0,v_1,\ldots,v_{\ell-1},v_0\) with consecutive vertices adjacent, \(\ell\ge 3\), and \(v_0,\ldots,v_{\ell-1}\) distinct.

Definition: A tree is a nonempty connected acyclic graph. Connected means that every pair of distinct vertices is joined by a path; acyclic means that the graph contains no cycle. A graph with one vertex is connected and acyclic, so it is a tree. We exclude the empty graph: the condition about pairs of distinct vertices would hold vacuously there, but the empty graph is not a tree under this definition.

The statement to prove is about all paths, not only shortest paths. A shortest path is one having minimum length among paths with the same endpoints. The characterization says there is exactly one path of any length between the chosen endpoints.

Two Distinct Paths Produce a Cycle

Lemma: If two distinct paths have the same endpoints in a simple graph, then the graph contains a cycle.

Proof. Let the two paths be \(P=(p_0,\ldots,p_k)\) and \(Q=(q_0,\ldots,q_\ell)\), both from \(u\) to \(v\). They start at \(p_0=q_0=u\). Let \(i\) be the last index in their common initial segment: \(p_j=q_j\) for every \(0\le j\le i\), while their next vertices differ. Such an \(i\) exists because the paths are distinct, and neither path can be a proper initial segment of the other: both end at \(v\), and a path cannot repeat \(v\).

Starting after \(p_i\), choose the first vertex \(p_j\) of \(P\) that also occurs after \(q_i\) on \(Q\). There is such a vertex because \(v\) is on both paths. Write \(p_j=q_h\). The subpath of \(P\) from \(p_i\) to \(p_j\) and the subpath of \(Q\) from \(q_i\) to \(q_h\) have the same endpoints. Their first edges differ. Their internal vertices are disjoint: if an internal vertex of the \(P\)-subpath also occurred on the \(Q\)-subpath, it would be a vertex of \(P\) occurring on \(Q\) before \(p_j\), contrary to the choice of \(j\). Thus the two subpaths form a closed sequence with no repeated vertices except its endpoints. It has at least three edges, since if both subpaths had length one they would have the same first edge. Their union is a cycle, as required. \(\square\)

The lemma is useful in both directions of the characterization. If a graph is acyclic, the lemma prevents two paths from having the same endpoints. Conversely, a cycle supplies two different paths between suitable vertices on it.

The Unique-Path Characterization

Theorem: A finite, nonempty simple graph is a tree if and only if every pair of distinct vertices is joined by exactly one path.

Proof. Suppose first that \(G\) is a tree. By the definition of connectedness, every pair of distinct vertices is joined by at least one path. If some pair were joined by two distinct paths, the lemma would give a cycle in \(G\). This contradicts the definition of a tree as acyclic. Therefore every pair of distinct vertices is joined by exactly one path. If \(G\) has only one vertex, there are no pairs of distinct vertices; the condition holds vacuously, and the tree has no cycle.

Conversely, suppose every pair of distinct vertices in \(G\) is joined by exactly one path. This condition gives connectedness directly: each such pair has a path. A graph with one vertex is also connected, since there is no pair of distinct vertices for which a path is required. It remains to show that \(G\) is acyclic.

If \(G\) contained a cycle \(v_0,v_1,\ldots,v_{\ell-1},v_0\), consider the distinct vertices \(v_0\) and \(v_1\). One path between them is the single edge \(v_0v_1\). Another is the path \(v_0,v_{\ell-1},v_{\ell-2},\ldots,v_1\), which follows the rest of the cycle. These paths are distinct: the first has length \(1\), and the second has length \(\ell-1\ge2\). This contradicts the assumed uniqueness. So \(G\) has no cycle. It is connected and acyclic, hence a tree. \(\square\)

The proof separates the logic cleanly: existence of paths is exactly the connectivity requirement, and uniqueness excludes cycles. The lemma makes the uniqueness direction precise without assuming that two paths must differ in a particular convenient way.

Worked Examples

Worked Example: Paths in a Star

Let \(G=(V,E)\) be the simple graph with \(V=\{r,a,b,c\}\) and \(E=\{ra,rb,rc\}\). We check the paths between all pairs of distinct vertices and verify the characterization.

There are \(4\cdot3/2=6\) unordered pairs of distinct vertices. For pairs containing \(r\), the paths are \(r,a\), \(r,b\), and \(r,c\), each of length \(1\). For pairs of leaves, the paths are \(a,r,b\), \(a,r,c\), and \(b,r,c\), each of length \(2\). These are paths because consecutive vertices are joined by listed edges, and no sequence repeats a vertex.

Each leaf has only one incident edge. Therefore any path starting at a leaf and going to a different vertex must first go through \(r\); after reaching \(r\), it must use the edge to its chosen endpoint. This forces each of the six paths just listed, so none has an alternative. The graph is connected, and it has no cycle: a cycle would have to enter and leave each of its vertices using two incident edges, but each of \(a,b,c\) has degree \(1\).

Check: all \(6\) pairs have exactly one path, and the graph is a tree by the theorem. The edge set has \(3\) edges, one from \(r\) to each of the three leaves, in agreement with the explicit description.

Worked Example: A Cycle Gives Two Paths

Let \(G=(V,E)\) have \(V=\{1,2,3,4\}\) and \(E=\{12,23,31,34\}\). The edges \(12,23,31\) form a triangle, and \(34\) attaches vertex \(4\) to that triangle.

Consider the distinct vertices \(1\) and \(3\). The sequence \(1,3\) is a path of length \(1\), using edge \(31\). The sequence \(1,2,3\) is another path, of length \(2\), using edges \(12\) and \(23\). Both sequences have distinct vertices, and the edges used are in \(E\); the paths are different because their sequences and lengths differ. Thus the pair \(1,3\) does not have a unique path.

All vertices are connected: \(2\) is adjacent to \(1\) and \(3\), and \(4\) is adjacent to \(3\). But \(G\) is not a tree, since \(1,2,3,1\) is a cycle. This example shows how the two-path failure matches the cycle obstruction in the theorem.

Check: the two displayed paths have lengths \(1\) and \(2\), computed by counting their edges. The alternative path is not shortest, but it still counts: uniqueness concerns all paths, not just shortest ones.

Worked Example: Failure of Existence in a Disconnected Graph

Let \(G=(V,E)\) have \(V=\{a,b,c,d,e\}\) and \(E=\{ab,bc,de\}\). The vertices \(a,b,c\) form one component, and \(d,e\) form another. Here a component is a maximal set of vertices in which every pair is joined by a path.

There is no path from \(a\) to \(d\). Any sequence of adjacent vertices that starts in \(\{a,b,c\}\) stays in that set: the only listed edges incident with these vertices are \(ab\) and \(bc\), and neither has an endpoint in \(\{d,e\}\). Thus the required path does not exist. The graph fails the unique-path condition at the pair \(a,d\), because that condition requires exactly one path, not zero.

Within \(\{a,b,c\}\), the paths between distinct pairs are \(a,b\), \(b,c\), and \(a,b,c\); within \(\{d,e\}\), the path is \(d,e\). They are unique within their respective components, but this does not make the whole graph a tree: connectedness must hold between vertices in different components too.

Check: the edge list contains no edge between the two displayed vertex sets, so no path can cross between them. In particular, the pair \(a,d\) disproves connectedness and the all-pairs condition.

What the Characterization Does—and Does Not—Say

For a tree, the unique path property gives a dependable way to describe routes: once the endpoints are specified, there is no alternative path to consider. For example, in a tree used to represent a network, the path between two locations is determined by the graph itself. The theorem is also a practical test when the structure of a graph is known: establish connectivity and rule out cycles, or establish existence and uniqueness of paths directly.

A frequent error is to confuse “unique path” with “unique shortest path.” The triangle already illustrates the difference. In the graph with \(V=\{1,2,3\}\) and \(E=\{12,23,31\}\), the direct path \(1,3\) is the unique shortest path from \(1\) to \(3\): its length is \(1\), while the other displayed path \(1,2,3\) has length \(2\). But there are two paths, so the triangle is not a tree. A shortest-path calculation alone cannot establish the unique-path condition.

Another error is to prove only one direction. Finding one path for each pair proves existence, not uniqueness. Conversely, showing that no pair has two paths does not establish that all pairs have a path: the disconnected example has pairs with no path at all. Both requirements matter, and the theorem links them to connectedness and acyclicity.

Takeaway: For a finite, nonempty simple graph, being a tree is equivalent to the statement that every pair of distinct vertices has exactly one path between them. Connectedness supplies at least one path; acyclicity, through the two-path lemma, rules out a second.

Check Your Understanding

For each question, pay attention to whether it asks about existence, uniqueness, or both.

  1. In a tree, why does connectedness guarantee that every pair of distinct vertices has at least one path?
  2. Explain how two distinct paths with the same endpoints lead to a cycle, including why the constructed cycle has at least three edges.
  3. In the graph \(V=\{1,2,3,4\}\), \(E=\{12,23,31,34\}\), give two distinct paths from \(2\) to \(3\).
  4. Why does the unique-path condition imply connectedness, including when the graph has just one vertex?
  5. Give a disconnected graph in which every pair of vertices within each component has a unique path. Why does that not make the whole graph a tree?