You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A spanning tree of a connected graph is a subgraph that is a tree and includes all vertices. A minimum spanning tree (MST) is a spanning tree whose total edge weight is as small as possible. This lesson covers two classic algorithms: Kruskal's and Prim's.
| Term | Definition |
|---|---|
| Spanning tree | A connected, acyclic subgraph containing all vertices |
| Minimum spanning tree | A spanning tree with minimum total edge weight |
| Properties | A spanning tree of n vertices has exactly n−1 edges |
Applications: laying cable networks, connecting computer nodes, pipe networks — any situation where you need to connect all points at minimum cost.
Strategy: Build the MST by adding the cheapest available edge that does not create a cycle.
Graph with vertices A, B, C, D, E and edges:
| Edge | Weight |
|---|---|
| AB | 3 |
| AC | 5 |
| AD | 8 |
| BC | 4 |
| BD | 6 |
| CD | 2 |
| CE | 7 |
| DE | 1 |
Sorted: DE(1), CD(2), AB(3), BC(4), AC(5), BD(6), CE(7), AD(8).
| Step | Edge | Action | Reason |
|---|---|---|---|
| 1 | DE(1) | Add | No cycle |
| 2 | CD(2) | Add | No cycle |
| 3 | AB(3) | Add | No cycle |
| 4 | BC(4) | Add | No cycle (connects {A,B} to {C,D,E}) |
| 5 | AC(5) | Reject | Creates cycle A-B-C-A |
MST edges: DE, CD, AB, BC. Total weight: 1 + 2 + 3 + 4 = 10.
We have 4 edges connecting 5 vertices — a valid spanning tree.
Exam Tip: Show your sorted edge list and justify each "add" or "reject" decision. Mark which cycle would be created when rejecting an edge.
Strategy: Grow the tree from a starting vertex by always adding the cheapest edge that connects a vertex in the tree to a vertex not yet in the tree.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.