Kruskal's Algorithm (Edexcel A-Level Further Mathematics): Revision Notes
10.3.2 Kruskal's Algorithm
Introduction to Kruskal's Algorithm
Kruskal's algorithm is a method to find a minimum spanning tree (MST) of a connected, weighted graph. The MST is a subset of edges that connects all vertices in the graph without forming cycles and has the minimum total weight.
Steps of Kruskal's Algorithm
- Sort the Edges by Weight
- Initialise the MST
- Iterate Through the Edges
- Check for Cycles
- Sort the Edges by Weight: List all edges in ascending order of their weights.
- Initialise the MST: Start with an empty set of edges for the MST.
- Iterate Through the Edges:
- Add the smallest edge to the MST, provided it does not form a cycle.
- Repeat until edges are included, where is the number of vertices.
- Check for Cycles: Use a cycle-checking method, such as disjoint sets (union-find), to ensure no cycles are formed.
Worked Example
Problem:
Find the minimum spanning tree for the following graph:
| Edge | ABAB | ACAC | ADAD | BCBC | BDBD | CDCD |
|---|---|---|---|---|---|---|
| Weight | 5 | 7 | 6 | 9 | 8 | 7 |
Step 1: Sort the Edges by Weight
List edges in ascending order:
Step 2: Initialise the MST
Start with an empty MST.
Step 3: Iterate Through the Edges
Add
-
No cycle.
-
MST = Add
-
No cycle.
-
MST = Add
-
No cycle.
-
MST = Skip
-
Adding would form a cycle. Add
-
No cycle.
-
MST =
Step 4: Check the MST
The MST includes edges.
Result:
The minimum spanning tree is:
Algorithm Complexity
Time Complexity:
- Sorting edges: , where is the number of edges.
- Cycle checking: using union-find.
- Overall:
Space Complexity:
- Union-find structures require space.
Note Summary
Common Mistakes
- Skipping Cycle Checks: Always ensure no cycles are formed when adding edges.
- Incorrect Sorting: Sorting the edges incorrectly leads to errors in the MST.
- Premature Stopping: Stop only after including edges.
- Confusion Between Trees: MST is unique only if edge weights are distinct; otherwise, multiple MSTs may exist.
- Misinterpreting Graph Connectivity: Kruskal's algorithm works only for connected graphs; otherwise, it gives a spanning forest.
Key Formulas and Concepts
-
Minimum Spanning Tree: A subset of edges connecting all vertices with no cycles and minimum total weight.
-
Number of Edges in MST: For vertices: edges.
-
Cycle Checking: Use disjoint sets (union-find) to ensure no cycles are formed while adding edges.