130 likes | 385 Views
A cable TV company is installing a system of cables to connect all the towns in the region. The numbers in the network are distances in miles. F. Prim’s Algorithm from a matrix. 20. 19. 12. D. E. 10. 15. 13. 12. 8. 14. A. C. B. Show this graph in matrix form. F.
E N D
A cable TV company is installing a system of cables to connect all the towns in the region. The numbers in the network are distances in miles. F Prim’s Algorithm from a matrix 20 19 12 D E 10 15 13 12 8 14 A C B
Show this graph in matrix form F Prim’s Algorithm from a matrix 20 19 12 D E 10 15 13 12 8 14 A C B
Prim’s Algorithm from a matrix A dash (-) in the table means that there is no direct connection between these vertices.
1 Prim’s Algorithm from a matrix 1. Choose a starting vertex say A. Delete row A and label column A with 1. Look for the smallest entry in column A
1 2 Prim’s Algorithm from a matrix 2. Label column B with a 2. Delete row B. Now choose the smallest uncovered value from columns A or B
1 2 3 Prim’s Algorithm from a matrix 3. Label column D with a 3. Delete row D. Now choose the smallest uncovered value from columns A or B or D
1 2 3 4 Prim’s Algorithm from a matrix 4. Label column E with a 4. Delete row E. Now choose the smallest uncovered value from columns A or B or D or E
1 2 5 3 4 Prim’s Algorithm from a matrix 5. Label column C with a 5. Delete row C. Now choose the smallest uncovered value from columns A, B, D, E, or C
1 2 5 3 4 6 Prim’s Algorithm from a matrix 5. Label column F with a 6. We now have connected all the vertices into the spanning tree.
1 2 5 3 4 6 Prim’s Algorithm from a matrix Length of the cabling = 8 + 10 + 12 + 13 + 19 = 62 miles
1 2 5 3 4 6 F Prim’s Algorithm from a matrix 19 D 12 E 10 13 C A 8 B Length of the cabling = 8 + 10 + 12 + 13 + 19 = 62 miles