Prim’s Algorithm from a matrix A cable TV company is installing a system of cables to connect all...
-
Upload
olivia-burns -
Category
Documents
-
view
212 -
download
0
Transcript of Prim’s Algorithm from a matrix A cable TV company is installing a system of cables to connect all...
![Page 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/1.jpg)
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
CB
E
F
10
812 15
12
20
13
19
14
![Page 2: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/2.jpg)
Prim’s Algorithm from a matrix
Show this graph in matrix form
A
D
CB
E
F
10
812 15
12
20
13
19
14
![Page 3: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/3.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
A dash (-) in the table means that there is no direct connection between these vertices.
![Page 4: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/4.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
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
![Page 5: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/5.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
2. Label column B with a 2. Delete row B. Now choose the smallest uncovered value from columns A or B
1 2
![Page 6: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/6.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
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
![Page 7: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/7.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
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 3 4
![Page 8: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/8.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
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 3 45
![Page 9: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/9.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
5. Label column F with a 6. We now have connected all the vertices into the spanning tree.
1 2 3 45 6
![Page 10: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/10.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
Length of the cabling = 8 + 10 + 12 + 13 + 19 = 62 miles
1 2 3 45 6
![Page 11: 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.](https://reader036.fdocuments.net/reader036/viewer/2022072005/56649ce25503460f949ae008/html5/thumbnails/11.jpg)
Prim’s Algorithm from a matrix
A B C D E FA - 8 - 10 - -B 8 - 14 12 - -C - 14 - 15 13 -D 10 12 15 - 12 20E - - 13 12 - 19F - - - 20 19 -
Length of the cabling = 8 + 10 + 12 + 13 + 19 = 62 miles
1 2 3 45 6
AB
D
C
E
F
8
10
12
13
19