Minimum Spanning Tree (AI HL)

A minimum spanning tree connects every vertex in a weighted graph as cheaply as possible, using no more edges than it needs and never forming a cycle. This page covers how Kruskal's and Prim's algorithms build one, with worked examples and the mistakes that lose marks. It's part of the broader Graph Theory topic.

19 questions on this sub-topic.

Practise minimum spanning trees → Try exam-style questions

Building a minimum spanning tree

Covered under IB syllabus reference AHL3.16: minimum spanning tree algorithms (Kruskal's and Prim's), part of the wider unit on walks, trails, paths, circuits and cycles.

Tree edge count

A spanning tree on \(n\) vertices always has \(n-1\) edges.

Not in the formula booklet - it's a direct consequence of a tree having no cycles. Use it to check your working: if you've kept more or fewer than \(n-1\) edges, you've made an error.

Kruskal's vs Prim's

Kruskal's: sort all edges by weight, add the cheapest one at a time, skipping any that would create a cycle.
Prim's: start at one vertex and repeatedly add the cheapest edge connecting the growing tree to a new vertex.

Not in the formula booklet - these are algorithms you apply by hand, showing your working at each step. Both always reach the same minimum total weight.

Want the full syllabus wording, the Chinese postman problem, and the travelling salesman algorithms? See Graph Theory.

Worked examples

1
Hard
GDC
[3 marks]

Using Kruskal's algorithm on the weighted graph, find the minimum spanning tree and its total weight.

Worked solution

Sorted: AC 3, CD 4, AB 5, BD 6, AD 7. Add AC, CD, AB (no cycle, 4 vertices connected). M1
MST = {AC, CD, AB}. A1
Total \(= 3 + 4 + 5 = 12.\) A1

M1 Attempt: sort and add edges avoiding cycles A1 MST A1 Correct answer of \(12\)
2
Hard
GDC
[3 marks]

Apply Prim's algorithm starting at vertex A to the same network, listing the order edges are added.

Worked solution

Start A. AC(3), then CD(4), then AB(5) (vs BD 6). M1
Order: AC, CD, AB. A1
Total \(= 12\) (same MST as Kruskal). A1

M1 Attempt Prim's algorithm from A A1 Order A1 Correct answer of \(12\)

Common mistakes

Ready to practise properly?

20 minimum spanning tree questions, marked instantly like the real exam.

Quick answers

How many edges does a minimum spanning tree have?

A spanning tree on \(n\) vertices always has exactly \(n-1\) edges - enough to connect every vertex with no cycles, and no more.

Do Kruskal's and Prim's algorithms always give the same minimum spanning tree?

They always produce a tree of the same minimum total weight, but if two or more edges tie in weight the two methods can pick a different set of edges to reach it.

← Back to Applications & Interpretation HL topics