Skip to main content
Logo image

Section 15.2 Walks, trails, and paths

Suppose \(G = (V,E)\) is a graph.
walk
a finite sequence \(v_0, e_1, v_1, e_2, \dotsc, v_{n - 1}, e_n, v_n\) of elements from \(V \cup E\text{,}\) with each \(v_i \in V\) and each \(e_i \in E\text{,}\) such that edge \(e_i\) connects vertices \(v_{i-1}\) and \(v_i\)
closed walk
a walk that ends at the same vertex at which it started (that is, \(v_n = v_0\))
open walk
a walk that isn’t closed (that is, \(v_n \neq v_0\))
trail
a walk that traverses no edge more than once
path
a walk that passes through no vertex more than once, except possibly the endpoints \(v_0,v_n\)

Note 15.2.1.

We may also apply the adjectives open and closed to trails and paths.

Example 15.2.2.

Consider the graph in Example 15.1.1.
  1. The “trip” we found in the example is a trail of maximal length starting at vertex \(C\text{.}\)
  2. The walks \(C,r_1,R,r_4,D\) and \(C,r_1,R,r_2,C\) are both paths, the first open and the second closed.
  3. The walk \(C,r_1,R,r_4,D,r_4,R\) is neither a path nor a trail.

Example 15.2.3. Paths and trails.

Consider the following graph.
A graph to illustrate paths and trails
Figure 15.2.4. A example graph to illustrate paths and trails.
This graph has the following properties.
  1. Every path or trail passing through \(v_1\) must start or end there but cannot be closed, except for the closed paths:
    • \(v_1\text{;}\)
    • \(v_1, e_1, v_2, e_1, v_1\text{;}\)
    • \(v_2, e_1, v_1, e_1, v_2\text{;}\)
  2. Walk \(v_1, e_1, v_2, e_5, v_3, e_4, v_4,\) is both a trail and a path.
  3. Walk \(v_1, e_1, v_2, e_5, v_3, e_6, v_3, e_4, v_4,\) is a trail but not a path.

Worked Example 15.2.5.

Consider again the graph in Figure 15.2.4 from Example 15.2.3. How many trails from \(v_3\) to \(v_4\) exist? How many of those trails are paths? Are there any paths from \(v_3\) to \(v_4\) that are not trails?
Solution.
We can solve this using a graph! The graph in Figure 15.2.6 was created by mapping out all possible trails starting at \(v_3\) and ending at \(v_4\text{,}\) moving across one edge at a time. Each node in this new (directed) graph is labelled with a partial walk that is a continuation of the walk assigned to the node above it. Each leg in the graph stops when the associated walk being followed reaches \(v_4\) and cannot be continued without repeating another edge. To save space in the node labels, we have used “…” to mean the walk from the previous node.
Counting all the nodes in the graph of Figure 15.2.6 that are labelled with a walk that ends in \(v_4\text{,}\) we see that there are ten trails from \(v_3\) to \(v_4\text{.}\) Also, we can easily see that only three of the trails are paths.
We can use the same technique to map out all paths from \(v_3\) to \(v_4\text{,}\) but this time we terminate a leg when we cannot move off a vertex without repeating a vertex that is already visited in that walk. (Note that the walk \(v_3,e_6,v_3\) is a path, but if we extend this walk in any way it will no longer be a path.)
From the result in Figure 15.2.7, we see that there are only three paths from \(v_3\) to \(v_4\text{,}\) and each of them is a trail.
A graph to map the possible trails in another graph.
Figure 15.2.6. Mapping the trails from \(v_3\) to \(v_4\) in the graph of Figure 15.2.4.
A graph to map the possible paths in another graph.
Figure 15.2.7. Mapping the paths from \(v_3\) to \(v_4\) in the graph of Figure 15.2.4.
We will prove the contrapositive: a walk that is not a trail cannot be an open path. So suppose \(W\) is a walk in a graph, and that \(W\) traverses edge \(e\) twice.

Case \(e\) is a loop.

Then \(W\) passes through the vertex incident to \(e\) at least three times, hence is not a path.

Case \(e\) is not a loop.

Write \(e=\{v,v'\}\text{.}\) Initially, there are two possibilities to consider. If each of the two assumed traversals of \(e\) moves from \(v\) to \(v'\text{,}\) then \(W\) passes through each of \(v,v'\) at least twice, and hence is not a path. If the two assumed traversals of \(e\) move \(v\) to \(v'\) and \(v'\) to \(v\) respectively, then \(W\) passes through \(v\) at least twice. If \(W\) traverses \(v\) twice because it both starts and ends there, then \(W\) is not open. If \(W\) is open and traverses \(v\) twice, then \(W\) is not a path. So in any case, \(W\) is not an open path.

Note 15.2.9.

In Activity 15.1, you are asked to create counterexamples of some statements related to the above proposition.