Introduction to Prim's Algorithm
What is Prim's algorithm?
- Prim's algorithm is another method of finding a minimum spanning tree in a network
- It can be used when the information for a network is given as a graph or in a matrix
Author
Naomi CLast updated
Start at any vertex and choose the edge of least weight that is connected to it
If there is a choice of edges of equal weight, either can be selected
Repeat STEP 2 until all of the vertices are added to the tree
Consider the network, G, below.
Using Prim’s algorithm, find a minimum spanning tree for G.
Edges added in the order: AB (15), BC (13), CE (12), BD (17)
State the total weight of the minimum spanning tree.
Add up the weight of the edges in the minimum spanning tree
15 + 13 + 12 + 17 = 57
The adjacency matrix of a network, is shown below.
A | B | C | D | E | |
A | - | 15 | 22 | 18 | 25 |
B | 15 | - | 13 | 17 | 24 |
C | 22 | 13 | - | 30 | 12 |
D | 18 | 17 | 30 | - | 21 |
E | 25 | 24 | 12 | 21 | - |
AB (15)
AB (15), BC (13)
AB (15), BC (13), CE (12)
AB (15), BC (13), CE (12), BD (17)
All vertices have been selected
You should have a list of the order in which the edges were selected
Edges added in the order: AB (15), BC (13), CE (12), BD (17)
the (exam) results speak for themselves:
Did this page help you?
Expertise: Maths
Naomi graduated from Durham University in 2007 with a Masters degree in Civil Engineering. She has taught Mathematics in the UK, Malaysia and Switzerland covering GCSE, IGCSE, A-Level and IB. She particularly enjoys applying Mathematics to real life and endeavours to bring creativity to the content she creates.