Title: Prims Algorithm for finding a minimum spanning tree
1Prims Algorithmfor finding a minimum spanning
tree
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
Starting at vertex A, choose the edge of least
weight. Your choices are shown in green.. The
edge with least weight 25 will be the first edge
in the tree.
2From now on, the tree will be marked in blue.
Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Choose the one of least weight and add it
to the tree. That is the edge marked with weight
30.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
3Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Notice that one edge of weight 70 now has
both ends in the tree, so it is no longer a
choice. Choose the one of least weight and add it
to the tree. The least weight edge is marked with
50.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
4Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. As we continue adding edges to the tree,
some green edges are changed back to black
because they have both ends in the tree. Choose
the one of least weight and add it to the tree.
The least weight edge is marked with 40.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
5Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Choose the one of least weight and add it
to the tree. The least weight edge is marked with
55.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
6Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Choose the one of least weight and add it
to the tree. The least weight edge is marked with
70.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
7Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Choose the one of least weight and add it
to the tree. The least weight edge is marked with
38.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
8Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Choose the one of least weight and add it
to the tree. The least weight edge is marked with
20.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
9Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Choose the one of least weight and add it
to the tree. The least weight edge is marked with
32.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
10Consider all edges with one end in the blue tree
so far and one end outside. Your choices are in
green. Choose the one of least weight and add it
to the tree. The least weight edge is marked with
35.
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70
11Done!
Now the blue tree contains all the vertices of
the graph, so it is a spanning tree. The total
weight is 395
115
90
52
35
45
55
20
40
110
120
100
32
50
60
38
88
30
25
70
A
70