Resources For Teachers For Tutors For Students & Parents AI New Books Pricing
Year 11 (2026) Maths Standard (2026) Networks, Paths and Trees

Shortest Path

20 practice questions 1 video lesson Theory + worked examples
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 weighted network is the route with the smallest total distance, time or cost. This Year 11 Mathematics Standard page shows how to find it by inspection and by labelling each vertex with its shortest distance from the start, from a diagram, a list or a table, and how to deal with closed roads and routes that are shorter but slower.

In a weighted network, the length of a path is the total of the weights on its edges. The shortest path between two vertices is the path with the smallest total weight. The weights may be distances, travel times or costs (such as tolls), so the shortest path can also be the quickest or the cheapest route.

The shortest path is not always the one with the fewest edges. Three short roads can add to less than one long road.

There are two ways to find it:

  • By inspection: list the possible routes, add the weights along each one and compare the totals. This suits small networks.
  • By labelling the vertices: work outwards from the start, labelling each vertex with its shortest distance from the start. A vertex's label is the smallest of (the label of a vertex already labelled + the weight of the edge joining them). The label on the finishing vertex is the length of the shortest path. This suits larger networks and networks given as a list or a table.

Real problems add a twist: a road may be closed (remove that edge and label again), or the shortest distance may not be the quickest once speeds are taken into account.

Labelling each vertex with its shortest distanceNetwork S, A, B, C, T with edges SA 4, SB 2, AB 1, AC 5, BC 8, CT 3, BT 10. Boxed labels: S 0, A 3, B 2, C 8, T 11. The shortest path S-B-A-C-T is highlighted. 4 2 1 5 8 3 10 S A B C T 0 3 2 8 11
Each boxed number is the shortest distance from \(S\). \(A=\min(4,\,2+1)=3\), so the shortest path to \(T\) is \(S\)-\(B\)-\(A\)-\(C\)-\(T=11\), even though \(S\)-\(B\)-\(T\) has fewer edges (\(12\)).
The shortest route is not always the quickestTwo routes from home H to work W: through town, 12 km at 40 km/h, which takes 18 minutes; by motorway, 20 km at 100 km/h, which takes 12 minutes. 12 km at 40 km/h 20 km at 100 km/h H W through town: 18 minmotorway: 12 min
Through town is shorter (12 km) but takes \(\dfrac{12}{40}\text{ h}=18\) min. The motorway is longer (20 km) but takes \(\dfrac{20}{100}\text{ h}=12\) min.
\[\text{length of a path}=\text{total of the weights on its edges}\]
length of a path equals the total of the weights on its edges

Labelling a vertex \(D\) that is joined to labelled vertices \(B\) (label 5, edge 9) and \(C\) (label 7, edge 6):

\[D=\min(5+9,\,7+6)=13\]
D equals the minimum of 5 plus 9 and 7 plus 6, which is 13

\(\min(\ldots)\) means “the smallest of”. To compare a shortest distance with a quickest time:

\[\text{time}=\dfrac{\text{distance}}{\text{speed}}\]
time equals distance divided by speed
Hours to minutes: multiply by 60. For example \(\dfrac{15}{45}\text{ h}=\dfrac{1}{3}\text{ h}=\dfrac{1}{3}\times 60=20\) min.

By inspection

  1. List the routes from the start to the finish that do not pass through a vertex twice.
  2. Add the weights along each route.
  3. Compare the totals and write \(\therefore\) the shortest path has length …

By labelling the vertices

  1. Label the start 0. The vertex joined to it by the shortest edge is labelled with that edge's weight.
  2. Work outwards. For each new vertex, look at every edge into it from a vertex already labelled. Its label is the smallest of (that label + edge weight), for example \(C=\min(8,\,5+2)=7\).
  3. Carry on until the finishing vertex is labelled. Its label is the length of the shortest path.
  4. Trace back from the finish, each time along the edge that gave the label, to write the path. Check by adding its weights.

Practical problems

  1. From a list or table: read off each direct road first. A dash in a table means there is no direct road.
  2. Road closed: remove that edge and label the network again.
  3. Quickest route: find the time for each route using time \(=\) distance \(\div\) speed, then compare.
Example 1 — Shortest path by inspection
The network shows the roads between five towns, with distances in km. Find the length of the shortest path from \(A\) to \(E\).
Road network for Example 1Edges AB 8, AC 3, BC 4, BE 6, CD 9, DE 2, in kilometres. 8 3 4 6 9 2 A B C D E
Solution

Compare the lengths of the possible routes:

\(A\text{-}C\text{-}B\text{-}E\)\(=\)\(3+4+6=13\)
\(A\text{-}B\text{-}E\)\(=\)\(8+6=14\)
\(A\text{-}C\text{-}D\text{-}E\)\(=\)\(3+9+2=14\)
\(A\text{-}B\text{-}C\text{-}D\text{-}E\)\(=\)\(8+4+9+2=23\)
A C B E equals 3 plus 4 plus 6 equals 13; A B E equals 14; A C D E equals 14; A B C D E equals 23
Shortest path for Example 1The shortest path A-C-B-E, of length 13, is highlighted. 8 3 4 6 9 2 A B C D E

\(\therefore\) the shortest path is \(A\)-\(C\)-\(B\)-\(E\), with length \(\mathbf{13}\) km. It has three edges but is shorter than the two-edge route \(A\)-\(B\)-\(E\).

Example 2 — Labelling from a table
The table shows the lengths, in km, of the direct roads between six towns. A dash means there is no direct road.
\(P\)\(Q\)\(R\)\(S\)\(T\)\(U\)
\(P\)–59–––
\(Q\)5–38––
\(R\)93–410–
\(S\)–84–29
\(T\)––102–5
\(U\)–––95–
Find the length of the shortest path from \(P\) to \(U\), and the route it takes.
Solution

Read the direct roads from the table, then label each town with its shortest distance from \(P\):

\(Q\)\(=\)\(5\)
\(R\)\(=\)\(\min(9,\,5+3)=8\)
\(S\)\(=\)\(\min(5+8,\,8+4)=12\)
\(T\)\(=\)\(\min(8+10,\,12+2)=14\)
\(U\)\(=\)\(\min(12+9,\,14+5)=19\)
Q equals 5; R equals min of 9 and 5 plus 3, which is 8; S equals min of 13 and 12, which is 12; T equals min of 18 and 14, which is 14; U equals min of 21 and 19, which is 19

Trace back from \(U\): \(U\) came from \(T\), \(T\) from \(S\), \(S\) from \(R\), \(R\) from \(Q\).

\(P\text{-}Q\text{-}R\text{-}S\text{-}T\text{-}U\)\(=\)\(5+3+4+2+5\)
\(=\)\(19\)
P Q R S T U equals 5 plus 3 plus 4 plus 2 plus 5 equals 19
Network drawn from the table in Example 2Edges PQ 5, PR 9, QR 3, QS 8, RS 4, RT 10, ST 2, SU 9, TU 5. Labels P 0, Q 5, R 8, S 12, T 14, U 19. Shortest path P-Q-R-S-T-U highlighted. 5 9 3 8 4 10 2 9 5 P Q R S T U 0 5 8 12 14 19

\(\therefore\) the shortest path is \(P\)-\(Q\)-\(R\)-\(S\)-\(T\)-\(U\), \(\mathbf{19}\) km.

Example 3 — Shortest or quickest?
Jai drives to the airport. The shortest path is \(22\text{ km}\) through the suburbs, where his average speed at 7 am is \(33\text{ km/h}\). Another route is \(30\text{ km}\) by motorway, where his average speed is \(90\text{ km/h}\). Which route is quicker at 7 am, and by how many minutes?
Solution

Use time \(=\dfrac{\text{distance}}{\text{speed}}\) for each route:

\(\text{Suburbs: } t\)\(=\)\(\dfrac{22}{33}=\dfrac{2}{3}\text{ h}\)
\(=\)\(\dfrac{2}{3}\times 60=40\text{ min}\)
\(\text{Motorway: } t\)\(=\)\(\dfrac{30}{90}=\dfrac{1}{3}\text{ h}\)
\(=\)\(\dfrac{1}{3}\times 60=20\text{ min}\)
suburbs time equals 22 over 33, which is two thirds of an hour, or 40 minutes; motorway time equals 30 over 90, which is one third of an hour, or 20 minutes
\(40-20\)\(=\)\(20\text{ min}\)
40 minus 20 equals 20 minutes

\(\therefore\) the motorway is quicker by \(\mathbf{20}\) minutes, even though it is \(8\text{ km}\) longer. The shortest path is not always the quickest.

Example 4 — A road is closed
The network shows the roads between seven towns. The distances are in km.
Road network for Example 4Edges AB 5, AC 8, BC 2, BD 9, CD 6, CE 12, DE 3, DF 7, EF 2, EG 10, FG 6, in kilometres. 5 8 2 9 6 12 3 7 2 10 6 A B C D E F G
(i) Find the shortest path from \(A\) to \(G\).
(ii) The road between \(D\) and \(E\) is closed for repairs. Find the shortest path from \(A\) to \(G\) now.
Solution

(i) Label each town with its shortest distance from \(A\):

\(B\)\(=\)\(5\)
\(C\)\(=\)\(\min(8,\,5+2)=7\)
\(D\)\(=\)\(\min(5+9,\,7+6)=13\)
\(E\)\(=\)\(\min(7+12,\,13+3)=16\)
\(F\)\(=\)\(\min(13+7,\,16+2)=18\)
\(G\)\(=\)\(\min(16+10,\,18+6)=24\)
B 5, C 7, D 13, E 16, F 18, G 24

Path: \(A\)-\(B\)-\(C\)-\(D\)-\(E\)-\(F\)-\(G=5+2+6+3+2+6=24\)

Shortest path from A to GLabels A 0, B 5, C 7, D 13, E 16, F 18, G 24. Shortest path A-B-C-D-E-F-G highlighted. 5 8 2 9 6 12 3 7 2 10 6 A B C D E F G 5 7 13 16 18 24

\(\therefore\) the shortest path is \(\mathbf{24}\) km.

(ii) Remove edge \(DE\), then label again. \(B\), \(C\) and \(D\) do not change:

\(E\)\(=\)\(7+12=19\)
\(F\)\(=\)\(\min(13+7,\,19+2)=20\)
\(G\)\(=\)\(\min(19+10,\,20+6)=26\)
E equals 7 plus 12 equals 19; F equals min of 20 and 21, which is 20; G equals min of 29 and 26, which is 26

Without \(DE\), the closest way to reach \(E\) is from \(C\).

Path: \(A\)-\(B\)-\(C\)-\(D\)-\(F\)-\(G=5+2+6+7+6=26\)

Shortest path with road DE closedRoad DE is closed (dashed). Labels A 0, B 5, C 7, D 13, E 19, F 20, G 26. Shortest path A-B-C-D-F-G highlighted. 5 8 2 9 6 12 3 7 2 10 6 A B C D E F G 5 7 13 19 20 26

\(\therefore\) with the road closed, the shortest path is \(\mathbf{26}\) km (\(2\text{ km}\) longer).

Common pitfalls

Fewest edges is not the same as shortest. Always add the weights: a route with more roads can still be shorter.
Keep the smallest, not the first. When labelling a vertex, check every edge into it from a labelled vertex and take the smallest total.
Give the route when it is asked for. Trace back from the finish along the edges that gave each label, and check that the weights add to the final label.
Shortest distance is not always quickest. If speeds are given, find each time with time \(=\) distance \(\div\) speed, and change hours to minutes by multiplying by 60.
A closed road changes the labels after it. Labels found before the closed road stay the same; check every label that might have used the closed road.

Frequently asked questions

How do you find the shortest path in a network?

For a small network, list the possible routes and add the weights along each one. For a bigger network, label each vertex with its shortest distance from the start, working outwards, then trace the path back from the finish.

Is the shortest path always the one with the fewest edges?

No. The length is the total of the weights, so a route with more edges can be shorter if its edges have smaller weights.

What does labelling the vertices mean?

Each vertex is given a number equal to its shortest distance from the start. A label is the smallest of (the label of a neighbouring labelled vertex + the weight of the edge between them), for example \(\min(5+9,\,7+6)=13\).

What is the difference between a shortest path and a minimum spanning tree?

A shortest path is the best route between two particular vertices. A minimum spanning tree is the cheapest set of edges that joins every vertex. They usually use different edges.

Is the shortest route always the quickest?

Not always. A longer route on faster roads can take less time. Work out time \(=\) distance \(\div\) speed for each route and compare.