aimnova.
DashboardMy LearningPaper MasteryStudy Plan

Stay in the loop

Study tips, product updates, and early access to new features.

aimnova.

AI-powered IB study platform with personalised plans, instant feedback, and examiner-style marking.

IB Subjects
  • All IB Subjects
  • IB Diploma
  • IB ESS
  • IB Economics
  • IB Business Management
  • IB Math AI
  • IB Math AA
Question Banks
  • ESS Question Bank
  • Economics Question Bank
  • Business Management Question Bank
  • Math AI Question Bank
  • Math AA Question Bank
Predicted Topics 2026
  • ESS Predictions 2026
  • Economics Predictions 2026
  • Business Management Predictions 2026
  • Math AI Predictions 2026
  • Math AA Predictions 2026

Study Resources

  • Free Study Notes
  • Mock Exams
  • Revision Guide
  • Flashcards
  • Exam Skills
  • Command Terms
  • Past Paper Feedback
  • Grade Calculator
  • Exam Timetable 2026

Company

  • Features
  • Pricing
  • About Us
  • Blog
  • Contact
  • Terms
  • Privacy
  • Cookies

© 2026 Aimnova. All rights reserved.

Made with 💜 for IB students worldwide

v0.1.898
NotesMath AI HLTopic 3.16Spanning trees & shortest path
Back to Math AI HL Topics
3.16.12 min read

Spanning trees & shortest path

IB Mathematics: Applications and Interpretation • Unit 3

7-day free trial

Know exactly what to write for full marks

Practice with exam questions and get AI feedback that shows you the perfect answer — what examiners want to see.

Start Free Trial

Contents

  • Minimum spanning tree: Kruskal's algorithm
  • Prim's algorithm (and why it agrees)
Cheapest cables that still reach every house: Picture a town wanting to lay fibre cable so every building is connected, using the least total length of cable.

You never need a loop (a cycle) — that would be wasted cable. The cheapest connecting network with no cycle is a minimum spanning tree (MST).

For a graph with n vertices, the MST always has exactly n − 1 edges.

Kruskal's algorithm: sort all edges from cheapest to dearest, then add them one at a time — but skip any edge that would create a cycle — until every vertex is joined.
A spanning tree touches every vertex and contains no cycle.

IB-style question — Kruskal's algorithm

A town wants to connect 5 buildings A, B, C, D, E with fibre cable. The possible links and their lengths (in hundreds of metres) are:

AB = 6, AC = 9, BC = 4, BD = 8, CD = 5, CE = 11, DE = 7.

Use Kruskal's algorithm to find the minimum spanning tree and its total length.

Step by step

  1. Sort the edges from cheapest to dearest.
  2. Add BC (4): joins B–C. No cycle.
  3. Add CD (5): joins D to B–C. No cycle.
  4. Add AB (6): joins A. No cycle.
  5. Add DE (7): joins E. Now all 5 vertices are connected with 4 edges — stop.
  6. (The next edge BD = 8 would make the cycle B–C–D–B, so it would be skipped anyway.)

Final answer

MST edges BC, CD, AB, DE; total length 22 (i.e. 2200 m of cable).

Grow the tree outward from one vertex: Prim's algorithm builds the same minimum spanning tree, but a different way — it grows one connected tree:

1. Start at any vertex. 2. Look at every edge that leaves the tree you have so far, and add the cheapest one that reaches a new vertex. 3. Repeat until all vertices are in the tree.

Because you only ever reach new vertices, you can never form a cycle. Prim's and Kruskal's always give the same total weight (and usually the same tree when the weights are all different).
From a distance table: In the exam the graph is often given as a distance table (a matrix). Prim's on a table: cross out the start column, ring the smallest entry in the start row, then keep ringing the smallest entry in any ringed row that reaches an un-ringed column.

IB-style question — Prim's algorithm

Use Prim's algorithm, starting at vertex A, to find the minimum spanning tree of the same network (AB = 6, AC = 9, BC = 4, BD = 8, CD = 5, CE = 11, DE = 7).

Step by step

  1. Start at A. Cheapest edge from A is AB = 6 — add it. Tree = {A, B}.
  2. Edges leaving {A,B} to new vertices: AC = 9, BC = 4, BD = 8. Cheapest is BC = 4.
  3. Edges to new vertices: BD = 8, CD = 5, CE = 11. Cheapest is CD = 5.
  4. Edges to E: CE = 11, DE = 7. Cheapest is DE = 7.
  5. All 5 vertices included.

Final answer

Same MST as Kruskal — edges AB, BC, CD, DE; total weight 22. (Order added differs; the tree is the same.)

Try an IB Exam Question — Free AI Feedback

Test yourself on Spanning trees & shortest path. Write your answer and get instant AI feedback — just like a real IB examiner.

A water authority can lay pipes between 4 pumping stations P, Q, R, S. Lengths (km): PQ = 3, PR = 7, QR = 2, QS = 6, RS = 4. Use Kruskal's algorithm to find the minimum spanning tree and its total length. [2 marks]

Related Math AI HL Topics

Continue learning with these related topics from the same unit:

3.1.1Distance & midpoint in 2D
3.1.2Distance & midpoint in 3D
3.1.3Volume and Surface Area of 3D Solids
3.10.1Vector definitions
View all Math AI HL topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Math AI HL

Previous
3.15.1Adjacency matrices
Next
Route inspection & travelling salesman3.16.2

11 questions to test your understanding

Reading is just the start. Students who tested themselves scored 82% on average — try IB-style questions with AI feedback.

Start Free TrialView All Math AI HL Topics