Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prim’s Algorithm from a matrix A cable TV company is installing a system of cables to connect all the towns in the region. The numbers in the network are.

Similar presentations


Presentation on theme: "Prim’s Algorithm from a matrix A cable TV company is installing a system of cables to connect all the towns in the region. The numbers in the network are."— Presentation transcript:

1 Prim’s Algorithm from a matrix 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. A D C B E F 10 8 12 15 12 20 13 19 14

2 Prim’s Algorithm from a matrix Show this graph in matrix form A D C B E F 10 8 12 15 12 20 13 19 14

3 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- A dash (-) in the table means that there is no direct connection between these vertices.

4 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- 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

5 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- 2. Label column B with a 2. Delete row B. Now choose the smallest uncovered value from columns A or B 12

6 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- 3. Label column D with a 3. Delete row D. Now choose the smallest uncovered value from columns A or B or D 123

7 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- 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 1234

8 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- 5. Label column C with a 5. Delete row C. Now choose the smallest uncovered value from columns A, B, D, E, or C 12345

9 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- 5. Label column F with a 6. We now have connected all the vertices into the spanning tree. 123456

10 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- Length of the cabling = 8 + 10 + 12 + 13 + 19 = 62 miles 123456

11 Prim’s Algorithm from a matrix ABCDEF A-8-10-- B8-1412-- C-14-1513- D101215-1220 E--1312-19 F---2019- Length of the cabling = 8 + 10 + 12 + 13 + 19 = 62 miles 123456 A B D C E F 8 10 12 13 19


Download ppt "Prim’s Algorithm from a matrix A cable TV company is installing a system of cables to connect all the towns in the region. The numbers in the network are."

Similar presentations


Ads by Google