Académique Documents
Professionnel Documents
Culture Documents
Decision Maths
Networks Prims Algorithm
Click to edit Master subtitle style
Prim`s Algorithm
Wiltshire
n n n n n
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
Wiltshire
n Consider the example we looked at last lesson. n Select any node you like. n Lets select F.
Prim`s Algorithm
Wiltshire
n Connect it to the nearest node. n C and D are both 3 away so we can choose either. n Lets select C.
Prim`s Algorithm
3 away from F. n So connect D to F.
Wiltshire
Prim`s Algorithm
Wiltshire
Prim`s Algorithm
away from F. n Connect A to F.
Wiltshire
Prim`s Algorithm
n We now need to connect the last node, B. n The shortest arc is AB, which is 2. n Connect B to A.
Wiltshire
Prim`s Algorithm
n All the nodes are now connected so this is the
Wiltshire
Distance Table
between the two nodes.
Wiltshire
n The Network can also be represented as a table. n The infinity symbol () means there is no edge
Wiltshire
the distance table. n This demonstrates how a computer could apply the algorithm. n Prim`s is more suitable than Kruskal`s as computers have a problem recognising loops. n As you go through the algorithm, see if you can relate the procedure to the last example.
Wiltshire
that correspond to the node selected. Step 3 Choose the smallest number in the loop. Step 4 Delete the row that this smallest number is in. Step 5 Loop the column that corresponds to the row just deleted. Step 6 Choose the smallest number in any loop. Step 7 Repeat steps 4, 5 and 6 until all rows have been deleted and columns looped.
Wiltshire
Wiltshire
n Delete the smallest number in any loop that is not Select row C. n crossed out. C. Loop column
Wiltshire
n Delete the smallest number in any loop that is not Select row D. n crossed out. D. Loop column
Wiltshire
n Delete the smallest number in any loop that is not Select row E. n crossed out. E. Loop column
Wiltshire
n Delete the smallest number in any loop that is not Select row A. n crossed out. A. Loop column
Wiltshire
Wiltshire
been looped and the rows crossed out. n The circles show the edges in the minimum connector.
Wiltshire
n In this case they are AB, DE, AF, CF, DF n Can you explain why this procedure is exactly the same