Professional Documents
Culture Documents
Prim`s Algorithm
Wiltshire
which was used to solve minimum connector problems. Another method that can be used is Prim`s algorithm. Step 1 Select any node Step 2 Connect it to the nearest node Step 3 Connect one node already selected to the nearest unconnected node. Step 4 Repeat 3 until all nodes are connected.
Prim`s Algorithm
Select any node you like.
Lets select F.
Wiltshire
Prim`s Algorithm
Connect it to the nearest node.
Wiltshire
Prim`s Algorithm
only 3 away from F. So connect D to F.
Wiltshire
Prim`s Algorithm
So connect E to D.
Wiltshire
Prim`s Algorithm
5 away from F. Connect A to F.
Wiltshire
Prim`s Algorithm
We now need to connect the last node, B.
Wiltshire
Prim`s Algorithm
Wiltshire
Distance Table
Wiltshire
Wiltshire
the distance table. This demonstrates how a computer could apply the algorithm. Prim`s is more suitable than Kruskal`s as computers have a problem recognising loops. As you go through the algorithm, see if you can relate the procedure to the last example.
Wiltshire
Select any arbitrary node. Delete the row and loop the column that correspond to the node selected. Choose the smallest number in the loop. Delete the row that this smallest number is in. Loop the column that corresponds to the row just deleted. Choose the smallest number in any loop. Repeat steps 4, 5 and 6 until all rows have been deleted and columns looped.
Wiltshire
Wiltshire
Loop column C.
Wiltshire
Loop column D.
Wiltshire
Loop column E.
Wiltshire
Loop column A.
Wiltshire
Loop column B.
Wiltshire
been looped and the rows crossed out. The circles show the edges in the minimum connector.
Wiltshire