Minimum spanning trees
A minimum connector joins all vertices with no cycle and least total edge weight. Prim’s algorithm grows one tree by repeatedly selecting the lightest edge crossing from reached to unreached vertices
- Use n minus 1 edges A tree with n vertices has exactly n minus 1 edges \(\displaystyle n=5\Rightarrow |E(T)|=n-1=4\)
- Grow from the current tree Prim's algorithm selects the lightest edge joining a tree vertex to a vertex outside the tree \(\displaystyle T=\{A\},\quad w(AB)=3<w(AC)=6\Rightarrow AB\)
- Keep the current cut An eligible edge has exactly one endpoint in the reached set. An internal edge creates a cycle; a detached edge does not grow the current tree. Among eligible edges, choose a minimum weight
- Add the selected weights The minimum spanning-tree total is the sum of the weights in the selected tree \(\displaystyle W(T)=\sum_{e\in T}w(e)\)
Worked example
A network has vertices A, B, C, D and E with the edge weights shown below. Use Prim’s algorithm starting at A to find the minimum spanning-tree total
- \(\displaystyle T=\{A\},\quad AB:2<AC:4\)The eligible links from A are AB and AC. Select AB and reach B
- \(\displaystyle T=\{A,B\},\quad BC:3<AC:4<BD:7\)Select BC. AC is now internal to the reached set and is no longer an eligible crossing edge
- \(\displaystyle T=\{A,B,C\},\quad CD:5<BD:7<CE:8\)Select CD, then select DE of weight 6 rather than CE of weight 8 to reach E
- \(\displaystyle 2+3+5+6=16\)Four selected edges connect all five vertices without a cycle, with minimum total 16
Common mistakes
Difficulty levels
Questions about this topic
What is the difference between a spanning tree and a minimum spanning tree?+
A spanning tree reaches every vertex without cycles. A minimum spanning tree is the spanning tree with the least total edge weight
Which edges are eligible in Prim’s algorithm?+
Exactly those with one endpoint in the current tree and one outside it. The cheapest detached edge is not eligible yet, and an edge with both endpoints already reached is not eligible
Why must a cycle-closing edge be rejected?+
A tree has no cycles. Accepting an edge that closes a cycle means the selected edges cannot be a spanning tree
Can I use a calculator?+
A calculator is allowed unless a question is marked no calculator
Which year level and chapter is this?+
Year 12, VCE Units 3 & 4, General Mathematics, chapter 13: Graphs and networks