All revision notes topics

Minimum spanning treesEdexcel International A Level Maths: Revision notes

Section 1

Trees and the minimum connector problem

A tree is a connected network with no cycles. A spanning tree of a network is a tree that includes every vertex, using some of the original arcs. A network with nn vertices has a spanning tree with exactly n−1n-1 arcs. If you add one more arc you create a cycle, and if you take one away a vertex is cut off. The minimum spanning tree (MST), also called the minimum connector, is the spanning tree with the smallest total weight. It solves problems such as connecting every site to a water, cable or road network at least cost. A network can have more than one MST when arcs have equal weights.

Key termstreespanning treecycleminimum spanning tree
Exam tip

Check your answer has exactly n−1n-1 arcs and no cycle. Both checks take seconds.

Section 2

Kruskal's algorithm

Kruskal's algorithm builds the MST by choosing arcs.

  1. Sort the arcs into increasing order of weight.
  2. Select the smallest arc.
  3. Select the next smallest arc, rejecting it if it would form a cycle with arcs already chosen.
  4. Repeat step 3 until n−1n-1 arcs have been selected. Example: arcs BD=3BD=3, AC=4AC=4, CE=5CE=5, BC=6BC=6, AB=7AB=7. Accept BDBD, ACAC, CECE, BCBC; reject ABAB because AA and BB are already joined through CC. Weight =3+4+5+6=18=3+4+5+6=18. Kruskal's algorithm works on the list of arcs, so it does not need a starting vertex. In the exam show the order in which you consider the arcs and write which are rejected.
Key termsKruskal's algorithmreject
Common mistake

Rejecting an arc just because it joins two vertices that already have arcs. Reject it only if the two ends are already connected to each other.

Section 3

Prim's algorithm on a network

Prim's algorithm grows a single tree from a starting vertex.

  1. Choose any vertex to start.
  2. Select the smallest-weight arc joining a vertex in the tree to a vertex not yet in the tree.
  3. Repeat until every vertex is in the tree. Example: start at AA with arcs AC=4AC=4 and AB=7AB=7: choose ACAC. From {A,C}\{A,C\}, arcs to new vertices are CE=5CE=5, BC=6BC=6, AB=7AB=7, CD=8CD=8: choose CECE, then BCBC, then BD=3BD=3. The weight is 1818 again. The tree is built outwards, so the arcs may be chosen in a different order from Kruskal's, but the total weight of the MST is the same. Prim's algorithm is easier to apply from a table or matrix because you never need to check for cycles: you only ever add a new vertex.
Key termsPrim's algorithm
Common mistake

Choosing the smallest arc anywhere in the network. Prim's arc must join the current tree to a vertex outside it.

Section 4

Prim's algorithm on a matrix

A network can be shown as a distance matrix: rows and columns are labelled with the vertices, and the entry in row XX and column YY is the weight of arc XYXY. A dash means there is no arc. The matrix is symmetrical about the leading diagonal, so each arc appears twice. To apply Prim's algorithm to the matrix:

  1. Choose a starting vertex. Label its column 1 and delete (cross out) its row.
  2. Look at the labelled columns, and in them circle the smallest entry in a row that is not yet deleted.
  3. The circled entry gives the next arc. Label the column of the new vertex with the next number, and delete its row.
  4. Repeat until all rows are deleted. The numbers 1, 2, 3, ... give the order in which the vertices are added, and the circled entries are the arcs of the MST.
Key termsdistance matrixsymmetrical
Exam tip

Ignore entries in columns that are already labelled, otherwise you will pick an arc that makes a cycle.

Section 5

Drawing a network from a matrix, and writing a matrix

To draw a network from a matrix, mark each vertex, then for each non-blank entry in the upper triangle draw one arc between those vertices and write the weight on it. Only use half of the matrix, otherwise every arc is drawn twice. To write the matrix for a network, make a square table, put each arc weight in the cell for each end (once in each triangle), and put a dash for any pair with no arc. Example: the matrix with row PP = −-, 12, 9, 15, −- gives arcs PQ=12PQ=12, PR=9PR=9 and PS=15PS=15, with no arc PTPT. The number of arcs equals half the number of non-blank entries. Matrix manipulation is not needed.

Key termsupper triangle
Common mistake

Counting every non-blank entry as a separate arc. Each arc appears twice in the matrix.

Section 6

Exam skills and checks

Always show the order in which arcs are considered or added. Marks are given for the method as well as the final weight. If two arcs have equal weight, either can be chosen, and the MST may differ but its weight will not. If an arc is forced into the tree, include it first, then continue the algorithm. The cost is at least the MST weight. When a new vertex is added, find the new MST by repeating the algorithm. Some old arcs may drop out when the new arcs offer cheaper connections.

Exam tip

Count the arcs at the end: n−1n-1 arcs for nn vertices.

That's the notes covered.

Carry on to the next subtopic.

Exam questions on Minimum spanning trees

  1. A network has five vertices AA, BB, CC, DD and EE. The arcs and their weights are AB=7AB=7, AC=4AC=4, BC=6BC=6, BD=3BD=3, CD=8CD=8, CE=5CE=5 and DE=9DE=9.
    Use Kruskal's algorithm to find a minimum spanning tree for the network. List the arcs in the order in which you consider them, stating whether each is accepted or rejected, and find the total weight of the tree.2 marks
  2. A network has five vertices PP, QQ, RR, SS and TT, shown by the following distance matrix. A dash means there is no arc. The rows, in order, are: PP: −-, 12, 9, 15, −- QQ: 12, −-, 8, −-, 14 RR: 9, 8, −-, 11, 10 SS: 15, −-, 11, −-, 6 TT: −-, 14, 10, 6, −- The columns are in the same order PP, QQ, RR, SS, TT.
    Starting at PP, use Prim's algorithm to find a minimum spanning tree. State the order in which the arcs are added and the total weight of the tree.2 marks
  3. A water company must connect six villages AA to FF with pipes. The possible pipes and their costs, in thousands of pounds, are AB=12AB=12, AC=9AC=9, BC=7BC=7, BD=15BD=15, CD=11CD=11, CE=14CE=14, DE=6DE=6, DF=10DF=10 and EF=8EF=8. Every village must be connected to every other village, directly or through other villages, at minimum total cost.
    Use Kruskal's algorithm to find a minimum spanning tree, showing the order in which you consider the arcs, and state the minimum cost.3 marks
See the full worksheet

Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).