aımnova
DashboardMy LearningCrash CoursesStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Crash Courses
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Teachers
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aımnova

IB study, practice and feedback built around the real exam.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.c1e448f

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesMath AI HLTopic 3.16Spanning trees & shortest path
Back to Math AI HL Topics
3.16.14 min read

Spanning trees & shortest path (Math AI HL)

IB Mathematics: Applications and Interpretation · Unit 3

Your first topic is free to keep

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

Contents

  1. 1Minimum spanning tree: Kruskal's algorithm
  2. 2Prim's algorithm (and why it agrees)
Cheapest cables that still reach every house: A minimum spanning tree (MST) connects every vertex using the least total length, with no cycle.
The cable problem: 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.
Edge count: For a graph with n vertices, the MST always has exactly n − 1 edges.

Kruskal's algorithm

1

Sort

Sort all edges from cheapest to dearest.

2

Add

Add them one at a time.

3

Skip cycles

Skip any edge that would create a cycle.

4

Stop

Stop when every vertex is joined.

Sort → add → skip cycles

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).

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
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.

Prim's algorithm

1

Start

Start at any vertex.

2

Add the cheapest edge out

Look at every edge that leaves the tree you have so far, and add the cheapest one that reaches a new vertex.

3

Repeat

Repeat until all vertices are in the tree.

Why it works

  • 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 connected graph has vertices.

Write down the number of edges in any spanning tree of the graph. [1 mark]

Related Math AI HL Topics

Continue learning with these related topics from the same unit:

3.1.1Distance & midpoint in 2D3.1.2Distance & midpoint in 3D3.1.3Volume and Surface Area of 3D Solids3.10.1Vector definitions
View all Math AI HL topics
Improve your exam techniqueCommand terms, paper structure, and mark-scheme tips for Math AI HL
Previous3.15.1Adjacency matricesNextRoute inspection & travelling salesman3.16.2

76 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 FreeView All Math AI HL Topics