Resources For Teachers For Tutors For Students & Parents AI New Books Pricing
Year 12 General (Unit 3 & 4) Graphs and networks

Walks, trails, paths and the shortest path

20 practice questions 0 video lessons Theory + worked examples

Learn to describe and compare routes through a network in Year 12 General Mathematics for Queensland (QCAA). Whether it is a courier crossing Brisbane, a bushwalker choosing tracks on Fraser Island (K’gari) or data moving through cables, the important questions are the same: can you get there, which links are critical, and which way is quickest?

You will learn the difference between a walk, a trail, a path and a cycle, decide whether a graph is connected and find any bridges. Then you will find the shortest path in a weighted network by listing the possible routes and comparing totals, ready for Eulerian trails and circuits in the next subtopic.

Create a free accountTrack your progress and save your work as you go.
Create free account

Theory

Routes through a network have precise names. This Year 12 General Mathematics guide for Queensland students explains walks, open and closed trails, paths and cycles, what makes a graph connected, how to spot a bridge, and how to find the shortest path in a weighted network by listing and comparing routes.

A walk is a route through a graph: a list of vertices, each joined to the next by an edge. In a walk, vertices and edges may be repeated. A trail is a walk that never uses the same edge twice (vertices may repeat). A trail is open if it starts and finishes at different vertices and closed if it returns to its start. A closed trail is also called a circuit.

A path is a walk that never visits the same vertex twice, so it cannot repeat an edge either. An open path starts and finishes at different vertices. A closed path, which returns to its start with no other vertex repeated, is a cycle. So every path is a trail, and every trail is a walk.

A graph is connected if there is a path between every pair of vertices. A bridge is an edge that, if removed, would leave a connected graph disconnected. In a weighted graph the length of a route is the total of its edge weights, and the shortest path from one vertex to another is the path with the smallest total.

Key idea. Ask two questions about a route. Is an edge repeated? If yes, it is only a walk. Is a vertex repeated? If no, it is a path (a cycle if it is closed). If only a vertex repeats, it is a trail.
A connected graph with one bridgeTriangle A B C joined to triangle D E F by the single edge C D, shown in red. A B C D E F
The graph is connected. Removing \(CD\) (red) would split it into two pieces, so \(CD\) is a bridge. No other edge is a bridge.
Shortest path from A to FWeighted graph. The shortest path A C B D E F, length 2 + 1 + 5 + 2 + 3 = 13, is shown in red. A B C D E F 4 2 1 5 9 2 6 3
The shortest path from \(A\) to \(F\) is \(A\text{-}C\text{-}B\text{-}D\text{-}E\text{-}F\), length \(13\). It is not the path with the fewest edges.

The length (weight) of a route is the total of the weights of the edges it uses:

\[\text{length of a route} = \text{sum of its edge weights}\]
length=∑edge weights

How to name a route:

RouteRepeated edge?Repeated vertex?Starts and ends at the same vertex?
walkallowedallowedeither
open trailnoallowedno
closed trail (circuit)noallowedyes
open pathnonono
cycle (closed path)noonly the start = endyes
Shortest path. Compare the lengths of the possible paths between the two vertices. The smallest total is the shortest path. A path with fewer edges is not always shorter.

How to find the shortest path by trial and error

  1. Mark the start and finish. Look at the edges leaving the start and arriving at the finish.
  2. List the paths. Write down each path from start to finish that does not revisit a vertex. Work systematically, for example by the first edge used, so none are missed.
  3. Total each path, one path per line. Skip a path as soon as its running total passes the best total found so far.
  4. Compare and answer. Give the shortest path as a list of vertices and its length with units. Check that every edge you used really exists.

For bigger networks, a step-by-step method such as Dijkstra’s algorithm does the same job, but careful listing is enough for the small networks met here.

Example 1 — Name the route
For the graph shown, name each route as a walk, an open or closed trail, an open path or a cycle. (i) \(A\text{-}B\text{-}E\text{-}F\text{-}A\) (ii) \(A\text{-}B\text{-}C\text{-}D\text{-}E\text{-}B\text{-}A\) (iii) \(F\text{-}A\text{-}B\text{-}E\text{-}D\text{-}C\text{-}B\) (iv) \(C\text{-}D\text{-}E\text{-}F\)
Solution

Check for a repeated edge first, then a repeated vertex, then whether the route is closed.

Example 1 graphRectangle A C D F split by the edge B E: edges AB, BC, CD, DE, EF, FA and BE. A B C D E F
\(A\text{-}B\text{-}E\text{-}F\text{-}A\)\(:\)\(\text{cycle}\)
\(A\text{-}B\text{-}C\text{-}D\text{-}E\text{-}B\text{-}A\)\(:\)\(\text{walk}\)
\(F\text{-}A\text{-}B\text{-}E\text{-}D\text{-}C\text{-}B\)\(:\)\(\text{open trail}\)
\(C\text{-}D\text{-}E\text{-}F\)\(:\)\(\text{open path}\)
cycle, walk, open trail, open path

(i) Only \(A\) repeats, as the start and end: a cycle. (ii) Edge \(AB\) is used twice: only a walk. (iii) \(B\) is visited twice but no edge repeats, and it ends at a different vertex: an open trail. (iv) Nothing repeats: an open path.

Example 2 — Connected graphs and bridges
The graph shows power lines between seven substations near Rockhampton. (i) Is the graph connected? (ii) Which power lines are bridges?
Solution

Test each edge: would removing it cut some substations off from the rest?

Example 2 power networkSubstations P, Q, R in a triangle; R joined to S; triangle S, T, U; U joined to V. P Q R S T U V
\(\text{remove } RS\)\(:\)\(\{P, Q, R\} \text{ cut off}\)
\(\text{remove } UV\)\(:\)\(V \text{ cut off}\)
\(\text{remove } ST\)\(:\)\(S\text{-}U\text{-}T \text{ still joins them}\)
bridges RS and UV

(i) Yes. There is a path between every pair of substations. (ii) \(RS\) and \(UV\) are bridges. Every other line lies on a triangle, so there is another way round if it is removed.

Example 3 — Shortest path by listing
Find the shortest path from \(S\) to \(T\) in the network shown (distances in km).
Solution

List every path from \(S\) to \(T\), total each one, and compare.

Example 3 weighted graphEdges SA 5, SB 3, AB 1, AC 4, BC 7, AT 9, CT 2 (km). S A B C T 5 3 1 4 7 9 2
\(S\text{-}B\text{-}A\text{-}C\text{-}T\)\(:\)\(3 + 1 + 4 + 2 = 10\ \text{km}\)
\(S\text{-}A\text{-}C\text{-}T\)\(:\)\(5 + 4 + 2 = 11\ \text{km}\)
\(S\text{-}B\text{-}C\text{-}T\)\(:\)\(3 + 7 + 2 = 12\ \text{km}\)
\(S\text{-}B\text{-}A\text{-}T\)\(:\)\(3 + 1 + 9 = 13\ \text{km}\)
\(S\text{-}A\text{-}T\)\(:\)\(5 + 9 = 14\ \text{km}\)
\(S\text{-}A\text{-}B\text{-}C\text{-}T\)\(:\)\(5 + 1 + 7 + 2 = 15\ \text{km}\)
\(S\text{-}B\text{-}C\text{-}A\text{-}T\)\(:\)\(3 + 7 + 4 + 9 = 23\ \text{km}\)
Example 3 shortest pathThe shortest path S B A C T of length 10 km shown in red. S A B C T 5 3 1 4 7 9 2
shortest=10km

The shortest path is \(S\text{-}B\text{-}A\text{-}C\text{-}T\), with length 10 km. It uses four edges, while the two-edge path \(S\text{-}A\text{-}T\) is 14 km.

Example 4 — A charity ride
Riders in a Bundaberg charity ride go from the start \(S\) to the finish \(F\) along tracks between checkpoints. Riding times are in minutes. (i) Find the quickest route. (ii) On the day, the track \(CM\) is closed. What is the quickest route now?
Solution

(i) List the paths from \(S\) to \(F\), quickest first.

Charity ride checkpointsRiding times in minutes: SK 12, SL 9, KC 7, LC 11, KM 15, CM 6, CF 13, MF 5, LF 22. S K L C M F 12 9 7 11 15 6 13 5 22
\(S\text{-}K\text{-}C\text{-}M\text{-}F\)\(:\)\(12 + 7 + 6 + 5 = 30\ \text{min}\)
\(S\text{-}L\text{-}C\text{-}M\text{-}F\)\(:\)\(9 + 11 + 6 + 5 = 31\ \text{min}\)
\(S\text{-}L\text{-}F\)\(:\)\(9 + 22 = 31\ \text{min}\)
\(S\text{-}K\text{-}C\text{-}F\)\(:\)\(12 + 7 + 13 = 32\ \text{min}\)
\(S\text{-}K\text{-}M\text{-}F\)\(:\)\(12 + 15 + 5 = 32\ \text{min}\)
\(S\text{-}L\text{-}C\text{-}F\)\(:\)\(9 + 11 + 13 = 33\ \text{min}\)

The other 4 paths double back and each take more than \(40\) minutes. The quickest route is \(S\text{-}K\text{-}C\text{-}M\text{-}F\), taking 30 minutes.

Charity ride checkpointsRiding times in minutes: SK 12, SL 9, KC 7, LC 11, KM 15, CM 6, CF 13, MF 5, LF 22. Shortest route S K C M F in red. S K L C M F 12 9 7 11 15 6 13 5 22

(ii) Cross out every path that uses \(CM\). The quickest that are left are:

\(S\text{-}L\text{-}F\)\(:\)\(9 + 22 = 31\ \text{min}\)
\(S\text{-}K\text{-}C\text{-}F\)\(:\)\(12 + 7 + 13 = 32\ \text{min}\)
\(S\text{-}K\text{-}M\text{-}F\)\(:\)\(12 + 15 + 5 = 32\ \text{min}\)
30,31

With \(CM\) closed, the quickest route is \(S\text{-}L\text{-}F\), taking 31 minutes.

Common pitfalls

Trail or path? A trail must not repeat an edge, and a path must not repeat a vertex. Watch out for calling a route a path when it passes through the same vertex twice.
Fewest edges is not shortest. A path with fewer edges can still have a larger total. Watch out for stopping at the first route that looks direct; total every path.
Missing paths. When listing, work through the paths in order (for example by the first edge taken). Watch out for skipping a path that goes back across the middle of the network.

Frequently asked questions

What is the difference between a walk, a trail and a path?

A walk is any route along edges, and it may repeat vertices and edges. A trail is a walk with no repeated edge. A path is a walk with no repeated vertex, so it cannot repeat an edge either.

What is a cycle in a graph?

A cycle is a closed path. It starts and finishes at the same vertex and no other vertex is repeated. A closed trail that passes through some vertex twice is a circuit but not a cycle.

What is a bridge in a graph?

A bridge is an edge whose removal would split a connected graph into two separate parts. An edge that lies on a cycle is never a bridge, because there is another way round.

How do you find the shortest path in a network?

List the possible paths from the start to the finish, add up the edge weights along each one, and choose the path with the smallest total. Work in an organised order so no path is missed.

Do I need Dijkstra's algorithm to find a shortest path?

No. For small networks, listing the paths and comparing their totals (trial and error) is enough. Dijkstra's algorithm is one systematic method that gives the same answer for larger networks.

What does it mean for a graph to be connected?

A graph is connected if you can travel from any vertex to any other vertex along its edges. If some vertex cannot be reached, the graph is disconnected.