Library Further Decision Mathematics 1 WDM11 Minimum Spanning Trees
AS Level · Further Decision Mathematics 1 WDM11

Minimum Spanning Trees

Revise Minimum Spanning Trees for Further Decision Mathematics 1 WDM11 (AS Level) — revision notes and instant AI marking. Free to start.

📖 Revision notes · preview
  Edexcel A Level Further Maths · Decision 1

Minimum Spanning Trees

The big idea: when you need to connect a bunch of places together as cheaply as possible — with no wasted extra connections and no wasted loops — you're looking for a minimum spanning tree, and Kruskal's and Prim's algorithms are just two different systematic ways of building one.

SummaryEverything in this chapter, at a glance
  • A network is a weighted graph — vertices (nodes) joined by edges (arcs) that carry a "weight" like distance, cost, or time.
  • Networks can be represented as adjacency matrices (counts of direct connections) or distance matrices (weights of connections).
  • A spanning tree connects every vertex in a network using the fewest possible edges, with no cycles.
  • A minimum spanning tree (MST) is the spanning tree with the smallest possible total weight.
  • Kruskal's algorithm builds the MST by sorting all edges by weight and greedily adding the cheapest one that doesn't create a cycle — it works well from a list of edges or a graph.
  • Prim's algorithm builds the MST by growing outward from a single starting vertex, always adding the cheapest edge that connects the "grown" tree to a new vertex — it works well from a graph a matrix.
  • Both algorithms always find minimum spanning tree — they might select edges in a different order, but the total weight will be the same.
  • The number of edges in any spanning tree of a network with n vertices is always n − 1.
1. Networks & MatricesThe language you need before you touch an algorithm

What is a network?

Think of a network as a map. The dots on the map are called vertices (or nodes) — these might represent towns, computers, or buildings. The lines connecting the dots are called edges (or arcs) — these represent a road, a cable, a flight route, whatever links two places together.

What makes a network special (compared to just any graph) is that every edge has a weight attached to it — a number representing something real, like distance in km, cost in £, or time in minutes. That's why a network is formally called a weighted graph.

Analogy

Imagine a road map of five towns where every road has a "toll price" written on it. That map — towns as dots, roads as lines, toll prices as weights — a network. Everything in this chapter is really just: "what's the cheapest way to connect all five towns using some of these roads?"

Adjacency matrix vs. distance matrix

A matrix is just a table used to store all the connection information about a network in a grid, instead of drawing it out. There are two matrix types you need to tell apart:

Adjacency matrix

This tells you how many direct connections exist between each pair of vertices — it does care about weight, only about "is there a link, and if so how many?" Every vertex is listed as both a row heading and a column heading, so the matrix is always square.

  • An entry of 0 means no direct connection between that pair of vertices.
  • In a simple graph, entries are only ever 0 or 1.
  • A loop (an edge that starts and ends at the same vertex) shows up on the leading diagonal (top-left to bottom-right). In an matrix this value is 2, because you can travel round the loop in two directions. In a matrix it's 1, because the loop only goes one way.
  • An undirected graph's adjacency matrix is always symmetrical about the leading diagonal — the connection from A to B is identical to the connection from B to A.

Distance matrix

This is the one you'll use for MST problems. Instead of counting connections, each cell holds the weight of the edge between that pair of vertices (distance, cost, time — whatever the network measures). An empty cell means there's no direct edge between those two vertices at all.

A directed network's distance matrix will be symmetrical, because travelling A→B might cost something different from travelling B→A. When you're asked to draw a network from a distance matrix, check carefully: if the two "mirror" cells between a pair of vertices hold different numbers, you need two separate directed edges between them, each labelled with its own weight and arrow.

Worked example

Given the adjacency matrix below (for graph with vertices A–E), the value 2 on E's row/column diagonal tells you E has an undirected loop. The value 0 in row B, column C tells you there's no direct edge B→C.

ABCDE
A01101
B10000
C10111
D00001
E21112
Practice Question
A distance matrix has the value 20 in row B, column C, and also the value 20 in row C, column B. What does this tell you about the edge between B and C, and how should you draw it?
2. Spanning Trees & The GoalWhat are we actually trying to build?

Spanning tree vs. minimum spanning tree

A spanning tree of a network is a subset of the edges that:

  • connects every single vertex in the network (nothing gets left out), and
  • contains no cycles (no loops — you can't go round in a circle and come back to where you started using only tree edges).

Because a tree with n vertices and no cycles always has exactly n − 1 edges, there's a really useful check built in: if you ever end up with more than n − 1 edges, you've made a mistake (you've allowed a cycle in). If you end up with fewer, you haven't finished — some vertex still isn't connected.

There are usually possible spanning trees for a given network. The minimum spanning tree (MST) is simply the one out of all those possibilities whose edges add up to the smallest total weight.

Key Rule
Number of edges in a spanning tree = n − 1, where n = number of vertices.
In plain words: if a network has 6 towns, any spanning tree connecting all of them will use exactly 5 roads — never more, never fewer.
Why this matters

MSTs model real situations like: laying the least amount of cable to connect every building on a campus to the network, or building the cheapest possible set of roads that still lets you get from any town to any other town. You don't need possible road — just enough to connect everything, as cheaply as possible.

3. Kruskal's AlgorithmSort everything, then greedily grab the cheapest safe edge

How it works

Kruskal's algorithm takes a completely different approach from "building outward" — instead, it looks at every edge in the whole network at once, sorted from cheapest to most expensive, and just keeps grabbing the next cheapest one . "Safe" means it doesn't close a loop with the edges you've already picked.

The steps

  1. Step 1: List every edge in the network in order of increasing weight (cheapest first).
  2. Step 2: Select the edge of least weight. Add it to your tree.
  3. Step 3: Look at the next-cheapest edge that you haven't already considered.
    • If adding it would create a cycle with edges already in your tree → reject it.
    • Otherwise → add it to your tree.
  4. Step 4: Repeat Step 3 until all vertices are connected (i.e. until you have n − 1 edges).
  5. Step 5: List the edges of your finished MST in the order you added them — this is what examiners want to see as "working."
The key intuition

Kruskal's algorithm doesn't care where in the network an edge is — it can pick up an edge on the "far side" of the network before it's even touched the "near side." This means your tree can be split into several disconnected pieces partway through the algorithm — that's completely normal and expected. It only needs to be one single connected tree by the very end.

Worked example

Consider this network with vertices A, B, C, D, E, F, G, H and these edges: AB(4), AD(9), AE(11), BC(6), BF(7), CD(8), CG(15), DH(2), EF(5), EH(1), FG(5), GH(6).

Step 1 — sorted by weight: EH(1), DH(2), AB(4), EF(5), FG(5), GH(6), BC(6), BF(7), CD(8), AD(9), AE(11), CG(15) Step 2 — add EH (1) ✓ tree: {EH} Step 3 — add DH (2) ✓ tree: {EH, DH} add AB (4) ✓ tree: {EH, DH, AB} add EF (5) ✓ tree: {EH, DH, AB, EF} add FG (5) ✓ tree: {EH, DH, AB, EF, FG} GH (6) → REJECT ✗ would close a cycle (E-H-G-F-E already connected) add BC (6) ✓ tree: {EH, DH, AB, EF, FG, BC} add BF (7) ✓ tree: {EH, DH, AB, EF, FG, BC, BF} ← 7 edges, 8 vertices, DONE Total weight = 1+2+4+5+5+6+7 = 30
Practice Question
In the worked example above, why was the edge GH(6) rejected even though it's cheaper than BC(6) or BF(7)?
Practice Question
A network has 10 vertices. How many edges will its minimum spanning tree contain, and how would you know if you'd made an error and accidentally included a cycle?
4. Prim's AlgorithmStart small, grow outward, one edge at a time

Prim's algorithm using a graph

Where Kruskal's algorithm scans the network for the cheapest safe edge anywhere, Prim's algorithm is much more local: it starts at one vertex and grows the tree outward like a plant, always reaching for the cheapest edge that's directly touching the tree it's already built.

The steps (using a graph)

  1. Step 1: Start at any vertex and choose the edge of least weight that's connected to it.
  2. Step 2: Choose the edge of least weight that is incident (connected) to any vertex already in the tree, but which connects to a vertex not yet in the tree. (If there's a tie for cheapest, either can be picked.)
  3. Step 3: Repeat Step 2 until every vertex has been added.
The key difference from Kruskal's

Prim's tree is always one single connected blob at every stage — it can never be split into separate pieces the way Kruskal's can. Every new edge must attach directly onto the tree you already have, like adding a new branch onto a growing plant, never planting a second plant somewhere else in the garden.

Worked example (using a graph)

Network with vertices A, B, C, D, E and edges: AB(15), AC(22), AD(18), AE(25), BC(13), BD(17), BE(24), CD(30), CE(12), DE(21). Starting at A:

Start at A → cheapest edge from A is AB(15) tree: {A,B} edges: AB(15) Cheapest edge touching {A,B} is BC(13) tree: {A,B,C} edges: AB(15), BC(13) Cheapest edge touching {A,B,C} is CE(12) tree: {A,B,C,E} edges: AB(15),BC(13),CE(12) Cheapest edge touching {A,B,C,E} is BD(17) tree: {A,B,C,D,E} — all vertices in! Edges added in order: AB(15), BC(13), CE(12), BD(17) Total weight = 15+13+12+17 = 57
Watch out

At each step you must check every edge coming out of the whole current tree — not just edges from the vertex you added last! For example after adding C, the next cheapest option could come from A, B, C — you always compare against the entire tree so far.

Prim's algorithm using a matrix

This is the version you'll use when the network is given as a table rather than a drawing — and it's the method examiners often expect for matrix-based questions, since Kruskal's is awkward to apply directly from a table.

The steps (using a matrix)

  1. Step 1: Pick any starting vertex. Cross out the values in the column for that vertex, and label its row with the number 1.
  2. Step 2: Circle the lowest value in any cell along that labelled row. Add that edge to your tree. Cross out the remaining values in the column of the cell you just circled.
  3. Step 3: Label the row that corresponds to the same vertex as the column you just crossed out, with the next number (2, then 3, and so on).
  4. Step 4: Circle the lowest value in any cell along any labelled row (there may now be several labelled rows to check). Add the edge, cross out that column.
  5. Step 5: Repeat Steps 3–4 until every vertex has been added to the tree.
Why "cross out the column"?

Crossing out the column stops you from ever selecting an edge that leads back a vertex that's already safely in your tree — which is exactly how the matrix method avoids creating cycles, without you having to manually check for loops the way you do in Kruskal's.

Worked example

Distance matrix for A–E (same network as above), starting at A:

ABCDE
A15221825
B15131724
C22133012
D18173021
E25241221
① Row A labelled 1, cross out column A. Lowest value in row 1 → AB(15). Circle it, cross out column B. ② Row B labelled 2. Lowest value across rows 1–2 → BC(13). Cross out column C. ③ Row C labelled 3. Lowest value across rows 1–3 → CE(12). Cross out column E. ④ Row E labelled 4. Lowest value across rows 1–4 → BD(17). Cross out column D. All 5 vertices now selected → done. Edges added in order: AB(15), BC(13), CE(12), BD(17) Total weight = 15+13+12+17 = 57
Practice Question
Using Prim's algorithm with a matrix, why do we cross out the column (not the row) once a vertex has been added to the tree?
Practice Question
Using the same matrix above, if you started Prim's algorithm at vertex D instead of A, would the total weight of the MST change?
5. Comparing Kruskal's & Prim'sWhich one should you reach for?

Choosing the right algorithm

Both algorithms are guaranteed to find minimum spanning tree for the network — they might pick edges in a different order, and even choose slightly different tied-weight edges, but the total weight of the finished tree will always come out the same.

  • Prim's algorithm can be used on a network given as a graph or as a matrix. If your question gives you a table/matrix, Prim's is the natural choice.
  • Kruskal's algorithm works best when the network is given as a graph, or as a straightforward list of edges. If you only have a matrix, you'd normally sketch the graph first before applying Kruskal's.
  • Kruskal's lets you add arcs in any order across the whole network — the tree can be split into separate unconnected pieces mid-algorithm. Prim's always builds one connected blob from the start.
  • Prim's is sometimes considered more efficient, because it doesn't require sorting every edge up front, and it doesn't need an explicit cycle-check at each step (the "cross out the column" trick handles that automatically).
Quick decision rule
Table/matrix given → use Prim's. Graph or edge-list given → either works, but Kruskal's is usually quicker to apply by eye.
An exam question will usually just tell you which method to use — follow the instruction exactly, since marks are awarded for correct method as well as correct answer.
Exam trap to know

A common question style says "certain edges be included in the network" (e.g. because a road is already built). The trick: draw those required edges in first, then complete the rest of the tree using Kruskal's algorithm on the remaining edges — this is much easier to adapt than Prim's when specific starting edges are forced on you.

What to MemoriseThe essentials for quick-fire recall
Network
A weighted graph — vertices joined by edges, each edge carrying a numerical weight (distance/cost/time).
Adjacency matrix
Square table showing the number of direct connections between each pair of vertices. Loops appear on the leading diagonal.
Distance matrix
Square table where each cell holds the weight of the edge between that pair of vertices. Undirected networks are symmetrical about the diagonal.
Spanning tree
A set of edges connecting every vertex in the network, with no cycles, using exactly n − 1 edges.
Minimum spanning tree (MST)
The spanning tree with the lowest possible total edge weight.
Kruskal's algorithm
Sort all edges by weight; repeatedly add the cheapest edge that doesn't create a cycle, anywhere in the network.
Prim's algorithm
Start at one vertex; repeatedly add the cheapest edge that connects the growing (single, connected) tree to a new vertex.
n − 1 rule
Any spanning tree on n vertices contains exactly n − 1 edges — a built-in check for your working.
Concepts ChecklistTick off each idea once you're confident with it
Exam TipsWhat examiners are actually looking for
1
Always show the order edges are added. Whichever algorithm you use, list the edges in the exact order you selected them (e.g. "EH(1), DH(2), AB(4), ..."). This is where the method marks live — a correct final tree with no working shown can lose marks.
2
Draw as you go. Sketching the tree edge-by-edge (rather than trying to hold it all in your head) makes it far easier to spot when an edge would create a cycle in Kruskal's algorithm.
3
Don't confuse Prim's algorithm with the Nearest Neighbour algorithm. They can look superficially similar (both "grow" from a starting point) but Nearest Neighbour is used for a completely different problem — finding a route that visits every vertex (like the travelling salesman problem), not a minimum-weight connecting tree.
4
Spot the keyword. If a question talks about minimising the total cost/length/time to all locations in a network, that's your cue: they want a minimum spanning tree, even if the words "minimum spanning tree" never appear.
5
Watch for tied weights. If two edges have equal weight and both are valid options, either one can be picked — the mark scheme will usually accept both, but be consistent and state clearly which one you chose.
6
Count your final edges. Before submitting an answer, check you have exactly n − 1 edges in your tree. Too many means you've let a cycle slip through; too few means a vertex got missed.
7
Matrix questions almost always want Prim's. If the exam gives you a table of distances rather than a drawn graph, reach for Prim's algorithm using the row-label/column-cross-out method — it's built for exactly this format.
What's inside
📖 Revision notes ✦ AI flashcards ✓ Instant AI marking

Read the full Minimum Spanning Trees notes free

That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.

Unlock the full notes free →

More Further Decision Mathematics 1 topics