
About this chapter
This chapter applies three algorithms to networks: Kruskal’s and Prim’s for a minimum spanning tree, and Dijkstra’s for the shortest path from one vertex to another. The marks are for following each algorithm visibly, not just for the final tree or route. The October 2021 examiners advised against layouts that need values crossed out, because the working values are what show the algorithm was applied.
This chapter covers Kruskal’s algorithm, Prim’s algorithm on a network and on a matrix, the weight of a tree, equal weights, Dijkstra’s algorithm, working values, tracing the route back, and reusing final values. The later questions close a footpath, force a route through a depot, and give one arc an unknown weight x.
The ten questions
- Q1 (6 marks): Kruskal on a cable network, listing each arc as included or rejected, and the minimum cost.
- Q2 (6 marks): Prim from A on a network, the tree’s weight, and one advantage over Kruskal.
- Q3 (6 marks): Prim from A on a distance table for six towns, the tree and its length.
- Q4 (6 marks): Dijkstra from a summit to a town, and the quickest route.
- Q5 (6 marks): Kruskal with equal weights, giving a second different minimum spanning tree.
- Q6 (10 marks): Dijkstra from A to H, then the new shortest route when one footpath closes.
- Q7 (10 marks): Prim on seven cabins, why Kruskal suits a table less well, and the best tree that must include AF.
- Q8 (10 marks): Kruskal with an arc of weight x: the tree when x = 12, and the values of x that change it.
- Q9 (10 marks): Dijkstra across eight depots, then the shortest route that must pass through E.
- Q10 (10 marks): Kruskal and Dijkstra on the same network, and why the shortest route is not in the tree.
Key skills tested
Kruskal. Take the arcs in order of weight, adding each unless it makes a cycle. Record every arc looked at, saying included or rejected.
Prim on a network. Start at the given vertex and keep adding the shortest arc that joins a new vertex to the tree. List arcs in the order chosen.
Prim on a matrix. Number each chosen column, delete its row, and pick the smallest entry in the numbered columns. Write each arc as you choose it.
Weight of the tree. Add the arcs of the tree. With n vertices there are always n − 1 arcs.
Equal weights. When two arcs have the same weight, either may be chosen first, which can give a different tree of the same total weight.
Dijkstra. Give each vertex a box: order of labelling, final value and working values. Make the smallest working value permanent each time.
Working values. Write every temporary value, in order, without crossing anything out. Examiners use them to check the method.
Tracing the route. Work back from the destination, using arcs whose weight equals the difference between two final values.
Using final values. The final value at each vertex is its shortest distance from the start, so later parts can reuse them.

Worked example
Question 3 from this chapter. A distance table gives the distances between six towns, A to F. (a) Use Prim’s algorithm, starting at A, listing arcs in order. (b) State the total length.
(a) From A the shortest arc is AC (18). From A and C, the shortest to a new town is CB (15), then CE (19), then EF (17), then BD (20). The arcs in order are AC, CB, CE, EF, BD.
(b) 18 + 15 + 19 + 17 + 20 = 89 km.
The order matters: EF (17) is shorter than CE but cannot be chosen until E is in the tree.
Seen on real papers
Every question in our booklets is original. These are the recent papers where each question type has appeared.
- January 2025, Q2 and Q6: Dijkstra’s algorithm with careful working values, and Prim’s algorithm on a table starting at A, as in Q3, Q4 and Q6.
- June 2023, Q6 and Q7: Dijkstra with the shortest path and its length, then Prim on a matrix with the arcs in order, as in Q3, Q7 and Q9.
- October 2021, Q1: Dijkstra with boxes completed at every vertex, then a related shortest path, as in Q4 and Q6.
Where marks are lost
- Arcs out of order. In June 2023 it was not uncommon to lose marks for listing Prim’s arcs in the wrong order or missing one; writing each arc as its column is numbered helps.
- Prim confused with nearest neighbour. The same paper saw an extra arc added to return to A, and January 2025 saw some start at a vertex other than A.
- Labelling order. October 2021 and June 2023 saw Dijkstra labels repeated at two vertices, and working values missing or out of order.
- Working values. In January 2025 the ordering within the working values was where most lost marks came from.
Common questions
When should I use Prim rather than Kruskal?
Prim works well on a distance table, because it never needs the arcs sorted first, and it never risks a cycle.
What counts as a working value?
Every value a vertex is given before it becomes permanent, including ones later beaten, in the order they arose.
Why is the shortest route not part of the minimum spanning tree?
The tree minimises the total of all arcs; the shortest route minimises one journey. They solve different problems.
Where this chapter leads
- Decision 1 Chapter 5: The Travelling Salesman Problem: minimum spanning trees give upper and lower bounds.
- Decision 1 Chapter 4: Route Inspection: shortest paths between odd vertices.

