Skip to main content
Logo image

Section 15.2 Walks, trails, and paths

Suppose G=(V,E) is a graph.
walk
a finite sequence v0,e1,v1,e2,…,vnβˆ’1,en,vn of elements from VβˆͺE, with each vi∈V and each ei∈E, such that edge ei connects vertices viβˆ’1 and vi
closed walk
a walk that ends at the same vertex at which it started (that is, vn=v0)
open walk
a walk that isn’t closed (that is, vnβ‰ v0)
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 v0,vn

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.
  2. The walks C,r1,R,r4,D and C,r1,R,r2,C are both paths, the first open and the second closed.
  3. The walk C,r1,R,r4,D,r4,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 v1 must start or end there but cannot be closed, except for the closed paths:
  2. Walk v1,e1,v2,e5,v3,e4,v4, is both a trail and a path.
  3. Walk v1,e1,v2,e5,v3,e6,v3,e4,v4, 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 v3 to v4 exist? How many of those trails are paths? Are there any paths from v3 to v4 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 v3 and ending at v4, 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 v4 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 v4, we see that there are ten trails from v3 to v4. 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 v3 to v4, 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 v3,e6,v3 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 v3 to v4, 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 v3 to v4 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 v3 to v4 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β€²}. Initially, there are two possibilities to consider. If each of the two assumed traversals of e moves from v to vβ€², 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.