(Latest Revision: Nov 04, 2021)

MST Problems


An Example of An MST Problem:

G1=(V,E) is a connected undirected graph whose vertex set V is equal to {1,2,3,4,5,6,7}. The edges and weights of G1 are as follows, sorted by increasing weight.
edge  weight

{6, 7}   1  
{1, 6}   2
{1, 7}   3  
{4, 7}   4  
{1, 4}   5  
{5, 7}   6  
{4, 5}   7  
{5, 6}   8  
{2, 3}   9  
{3, 5}  10  
{2, 5}  11
{1, 2}  12
{2, 7}  13
{3, 6}  14
{2, 4}  15
We can use Kruskal's algorithm to determine the edges of a minimum cost spanning tree of G1. The first step of the algorithm is to sort the edges by weight, but the edges above are already sorted. The second step is to go through the list in order and either accept or reject each edge, until the number of accepted edges is the number of vertices (nodes) minus one. We keep track of the sets of vertices that have been connected with the accepted edges. The next edge is accepted if the two ends are not already in the same set, otherwise the edge is rejected.

The work of the algorithm looks like this:
WORK SET ONE
------------------------------------------------------
Kruskal List
Initial singleton sets {1} {2} {3} {4} {5} {6} {7} 

{6, 7}  1  accept {1} {2} {3} {4} {5} {6,7}
{1, 6}  2  accept {2} {3} {4} {5} {1,6,7}
{1, 7}  3  reject {2} {3} {4} {5} {1,6,7}
{4, 7}  4  accept {2} {3} {5} {1,4,6,7} 
{1, 4}  5  reject {2} {3} {5} {1,4,6,7}
{5, 7}  6  accept {2} {3} {1,4,5,6,7}
{4, 5}  7  reject {2} {3} {1,4,5,6,7}
{5, 6}  8  reject {2} {3} {1,4,5,6,7}
{2, 3}  9  accept {2,3} {1,4,5,6,7}
{3, 5} 10  accept {1,2,3,4,5,6,7}
{2, 5} 11
{1, 2} 12
{2, 7} 13
{3, 6} 14
{2, 4} 15
------------------------------------------------------
Note that the execution of the algorithm stopped when the number of accepted edges was 6, the number of nodes, minus one.

Second MST Problem:

We can use the list of edges ordered by weight, plus a version of Prim's algorithm to determine the edges in a minimum cost spanning tree of G1. Assume that node #1 is the start node. Recall that Prim's algorithm works by maintaining a single tree, to which it adds one edge at a time. To add a new edge to the current subtree T, we pick a cheapest edge that leaves T. We start with just node #1, and use the list to find the cheapest edge that "leaves 1," which is clearly the first edge in the list having 1 as one of its ends. So that tells us that {1,6} is the first edge chosen by Prim's algorithm. Below we show the list with the first edge labeled, and we also show the set S of nodes currently connected by the tree Prim's algorithm builds.
{6, 7}  1
{1, 6}  2  Prim #1 (cheapest edge leaving S={1}) Now S = {1,6}
{1, 7}  3  
{4, 7}  4
{1, 4}  5
{5, 7}  6
{4, 5}  7  
{5, 6}  8  
{2, 3}  9
{3, 5} 10
{2, 5} 11
{1, 2} 12
{2, 7} 13
{3, 6} 14
{2, 4} 15
The next edge that Prim's algorithm will choose is a cheapest edge that has one end in S = {1,6} and one end not in S = {1,6}. We can find that edge by just going down the list, starting from the top, and selecting the first edge that has one end in S = {1,6} and one end not in S = {1,6}. In this case, we find the edge right away: {6,7}. Below we show the list with the first two edges labeled, and we also show the set S of nodes currently connected by the tree.

{6, 7}  1  Prim #2 (cheapest edge leaving S={1,6}) Now S = {1,6,7}
{1, 6}  2  Prim #1 (cheapest edge leaving S={1}) Now S = {1,6}
{1, 7}  3  
{4, 7}  4
{1, 4}  5
{5, 7}  6
{4, 5}  7  
{5, 6}  8  
{2, 3}  9
{3, 5} 10
{2, 5} 11
{1, 2} 12
{2, 7} 13
{3, 6} 14
{2, 4} 15
Going on in the same way until we have connected all the nodes, the work we perform looks like this:
WORK SET TWO
------------------------------------------------------
Prim List
{6, 7}  1  Prim #2 (cheapest edge leaving S={1,6}) Now S = {1,6,7}
{1, 6}  2  Prim #1 (cheapest edge leaving S={1}) Now S = {1,6}
{1, 7}  3  
{4, 7}  4  Prim #3 (cheapest edge leaving S={1,6,7}) Now S = {1,4,6,7}
{1, 4}  5  
{5, 7}  6  Prim #4 (cheapest edge leaving S={1,4,6,7}) Now S = {1,4,5,6,7}
{4, 5}  7  
{5, 6}  8  
{2, 3}  9  Prim #6 (cheapest edge leaving S={1,3,4,5,6,7}) Now S = {1,2,3,4,5,6,7}  
{3, 5} 10  Prim #5 (cheapest edge leaving S={1,4,5,6,7}) Now S = {1,3,4,5,6,7}
{2, 5} 11
{1, 2} 12
{2, 7} 13
{3, 6} 14
{2, 4} 15
------------------------------------------------------
Your Homework Problem:

G2=(V,E) is a connected undirected graph whose vertex set V is equal to {1,2,3,4,5,6,7,8,9,10,11,12}. The edges of G2 are as follows, sorted by increasing weight.
edge  weight

{02,03}  01
{02,09}  02
{04,06}  03
{07,08}  04
{09,10}  05
{03,12}  06
{10,12}  07
{11,12}  08
{10,11}  09
{01,02}  10
{01,03}  11
{01,11}  12
{05,06}  13
{04,05}  14
{05,12}  15
{01,04}  16
{06,10}  17
{03,07}  18
{04,07}  19
{08,11}  20
{05,08}  21
{08,09}  22
{07,09}  23
{02,06}  24
In the same manner as in the examples above (Work Set One and Work Set Two) Use Kruskal's algorithm and then Prim's algorithm to determine the edges in a minimum cost spanning tree.

Directions For Submitting Solution: