Resources For Teachers For Tutors For Students & Parents AI New Books Pricing
Year 12 Maths - General (Unit 3 & Unit 4) Trees, minimum connectors and shortest paths

Shortest paths by inspection

20 practice questions 0 video lessons Theory + worked examples

Find the quickest way from A to B with shortest paths in Year 12 VCE General Mathematics. A courier driving from Geelong to Torquay, a cyclist in a Bendigo charity ride or an ambulance crossing town all want the route with the smallest total distance or time, and it is often not the one with the fewest turns.

You will find shortest paths in small networks by listing the possible routes and comparing their totals. You will follow one-way streets in directed networks, adjust for closed roads, add a required stop, and convert distances to times, ready to meet Dijkstra’s algorithm, a step-by-step method for larger networks.

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

Theory

The shortest path between two vertices of a network is the one with the smallest total weight. This Year 12 General Mathematics guide for students in Victoria shows how to find it by inspection, listing and comparing paths, in networks and directed networks, with road closures and required stops.

In a weighted graph (a network), the length of a path is the total of the weights of the edges it uses. The weights might be distances, times or costs, so β€œshortest” can also mean quickest or cheapest. The shortest path between two vertices is the path with the smallest total.

For a small network, the shortest path can be found by inspection: list the sensible paths from the start to the finish, total each one, and compare. A path with fewer edges is not always shorter, so every reasonable path must be checked. A path never needs to visit a vertex twice.

In a directed network the path must follow the arrows, so the shortest path from \(A\) to \(B\) can be different from the shortest path back from \(B\) to \(A\). If the trip must pass through a particular vertex, find the shortest path to it and the shortest path on from it, then add.

Key idea. Shortest means smallest total weight, not fewest edges. List the paths in an organised order so that none is missed.
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\). The path \(A\text{–}B\text{–}D\text{–}F\) has fewer edges but length \(15\).
Shortest path in a digraphArcs P to Q 3, R to P 2, Q to R 4, Q to S 6, R to S 3, S to T 5. Shortest path P Q S T (14) in red. P Q R S T 3 2 4 6 3 5
In a digraph, follow the arrows. From \(P\) to \(T\) the shortest path is \(P\text{–}Q\text{–}S\text{–}T\) (\(14\)). From \(R\) to \(Q\) you must go round through \(P\): \(R\text{–}P\text{–}Q\) (\(5\)).

The length of a path is the total of its edge weights:

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

When the trip must pass through a vertex \(V\) on the way from \(S\) to \(T\):

\[\text{shortest } S \to T \text{ via } V = (\text{shortest } S \to V) + (\text{shortest } V \to T)\]
dST=dSV+dVT
Distance to time. If the weights are distances and the speed is constant, the shortest path is also the quickest: time \(= \dfrac{\text{distance}}{\text{speed}}\).

How to find the shortest path by inspection

  1. Mark the start and finish. Note the edges leaving the start and arriving at the finish (in a digraph, only arrows pointing the right way).
  2. List the paths in an organised way, for example by the first edge used. Do not revisit a vertex.
  3. Total each path, one per line. Stop extending a path once its running total passes the best total found so far.
  4. Answer with the path written as a list of vertices and its length with units. Check every edge really exists (and points the right way).

For a network with many vertices, Dijkstra’s algorithm does the same job in a systematic table.

Example 1 β€” List every path
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 1 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 1 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 2 β€” A charity ride and a closed track
Riders in a Bendigo 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 across the network 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.

Example 3 β€” There and back in a digraph
One-way streets in central Shepparton join home \(H\) and work \(W\). Times are in minutes. Find the quickest route (i) from \(H\) to \(W\), (ii) from \(W\) back to \(H\).
Solution

Follow the arrows only. List every directed path.

One-way streets between home and workArcs H to A 4, A to C 3, C to W 5, A to B 2, B to C 7, C to D 4, W to D 3, D to B 6, B to H 2 (minutes). H A B C D W 4 3 5 2 6 3 2 4 7

(i) From \(H\) the only arc goes to \(A\):

\(H\text{–}A\text{–}C\text{–}W\)\(:\)\(4 + 3 + 5 = 12 \text{ min}\)
\(H\text{–}A\text{–}B\text{–}C\text{–}W\)\(:\)\(4 + 2 + 7 + 5 = 18 \text{ min}\)

(ii) From \(W\) the only arc goes to \(D\), then \(D \to B\), then \(B \to H\):

\(W\text{–}D\text{–}B\text{–}H\)\(:\)\(3 + 6 + 2 = 11 \text{ min}\)
12,11

(i) \(H\text{–}A\text{–}C\text{–}W\), 12 minutes. (ii) \(W\text{–}D\text{–}B\text{–}H\), 11 minutes. The routes are different because the arrows only allow one direction on each street.

Example 4 β€” A required stop
A courier drives from Geelong \(G\) to Torquay \(T\) (distances in km). (i) Find the shortest route. (ii) The courier must collect parcels from the post office \(P\) on the way. Find the shortest route now.
Solution

(ii) Split the trip: shortest \(G\) to \(P\), then shortest \(P\) to \(T\).

Roads from Geelong to Torquay via a post officeEdges GA 8, GB 6, AP 5, BP 9, AC 12, BD 10, PC 4, PD 7, CT 6, DT 5 (km). G A B P C D T 8 6 5 9 12 10 4 7 6 5

(i) The shortest route is \(G\text{–}B\text{–}D\text{–}T\): \(6 + 10 + 5 = 21\) km (every other path is longer).

(ii) \(G\) to \(P\):

\(G\text{–}A\text{–}P\)\(:\)\(8 + 5 = 13 \text{ km}\)
\(G\text{–}B\text{–}P\)\(:\)\(6 + 9 = 15 \text{ km}\)
\(G\text{–}B\text{–}D\text{–}P\)\(:\)\(6 + 10 + 7 = 23 \text{ km}\)

\(P\) to \(T\):

\(P\text{–}C\text{–}T\)\(:\)\(4 + 6 = 10 \text{ km}\)
\(P\text{–}D\text{–}T\)\(:\)\(7 + 5 = 12 \text{ km}\)
\(P\text{–}A\text{–}C\text{–}T\)\(:\)\(5 + 12 + 6 = 23 \text{ km}\)
\(\text{total}\)\(=\)\(13 + 10\)
\(\)\(=\)\(23 \text{ km}\)
23km

The shortest route through \(P\) is \(G\text{–}A\text{–}P\text{–}C\text{–}T\), 23 km, which is 2 km longer than the route in (i).

Common pitfalls

Fewest edges is not shortest. A path with fewer edges can still have a larger total. Total every reasonable path before deciding.
Missing paths. Work through the paths in order, for example by the first edge taken. Paths that cut back across the middle of a network are easy to miss.
Arrows matter. In a digraph, an arc can only be used in its own direction, so the way back may be a completely different route.

Frequently asked questions

How do you find the shortest path in a network by inspection?

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.

Is the path with the fewest edges always the shortest?

No. The shortest path has the smallest total weight. A path with more edges can be shorter if those edges have small weights.

How do you find the shortest path in a directed graph?

Do the same listing, but only follow edges in the direction of their arrows. The shortest path back can be different from the shortest path there.

How do you find the shortest path that passes through a given vertex?

Find the shortest path from the start to that vertex and the shortest path from that vertex to the finish, then add the two lengths together.

When should I use Dijkstra's algorithm instead?

Inspection works well for small networks. For bigger networks, or to find the shortest paths from one vertex to every other vertex, Dijkstra's algorithm is more reliable.