You are on page 1of 8

Algorithm for generating minimum spanning tree:

1. Prism algorithm
2. Kruskals algorithm
3. Round robin algorithm
Prism algorithm:
In prism algorithm, we start with an arbitrary vertex of given graph. Let the arbitrary vertex
be V .Then we find all the adjacent vertices of V and make a set of consisting of these vertex
pair. After that we select the vertex pair with the least weight from this set and add the vertex
pair to the tree to be formed. Let this vertex pair be (u,w). Again we find all the adjacent pair
of w and add these vertex pair to the previous set such that a new set of pair of vertices is
formed. Then we select a vertex pair with least weight from this newly formed set and add it
to the tree to be formed .while adding vertex pair to the tree, if any vertex pair with minimum
weight forms a cycle, we discard it and move to the vertex pair with next minimum weight in
the set.
1. Find the minimum spanning tree from the following graph.

Step 1:
Let the arbitrary vertex be V1
The adjacent vertex of V1 are v2,v3,v4 and v5
Hence the set of these pair of vertices is
(v1,v2)=5
(v1,v3)=4
(v1,v4)=9
(v1,v5)=6
Since the vertex pair (v1,v3)=4 is the vertex pair with least weight, it is added to the tree
and removed it from the set.

Step 2:
Now adjacent node of v3 are v1,v2,v5.Therefore, add these adjacent pair into the set ,Then
the set becomes,
(v1,v2)=5

KASHIRAM POKHAREL
HCOE Page 1
(v1,v4)=9
(v1,v5)=6
(v3,v2)=8
(v3,v5)=12
Since the vertex pair (v1,v2)=5 is the vertex pair with least weight, it is added to the tree
and removed it from the set.

Step 3:

Now the adjacent node of v2 are all included in the set. Hence , choose another minimum value from
the set. Here (v1,v5)=6 is the minimum .so , (v1,v5)=6 is included in the tree and removed from set.

Then set becomes


(v1,v4)=9
(v3,v2)=8
(v3,v5)=12
Step 4:
Again the adjacent node of v5 are v3,v1,v4,v6.hence the set consisting of these adjacent pair is
(v1,v4)=9
(v3,v2)=8
(v3,v5)=12
(v5,v4)=10
(v5,v6)=15
Here the adjacent pair (v3,v2)=8 is minimum but it forms the cycle.Hence discard it.
Again the minimum weight of vertex pair is (v1,v4)=9 .which doesn,t form any
cycle.Hence it is added to the tree.
Now the tree becomes

KASHIRAM POKHAREL
HCOE Page 2
Now adjacent node of v4 are v6,v5,v1 and (v1,v4)is already in set hence discard it. Therefore new set is

(v3,v5)=12
(v5,v4)=10
(v5,v6)=15
(v4,v6)=20
Here ,minimum weight of vertex pair is (v5,v4)=10 which forms a cycle and hence
discard it.
Again , minimum weight of a set is (v3,v5)=12 which agains forms a cycle and hence
discard it.
Again minimum weight of vertex pair in a set is (v5,v6)=15 .so include this vertex pair in a
tree.

The adjacent node of v6 are v4 and v5 which are already in tree so discard them.
Now choose minimum weighted vertex pair in a set i.e. (v4,v6)=20 which also forms a
cycle hence discard it.
Now the final minimum spanning tree is

Kruskals algorithm:
In kruskals algorithm, we first list all the pair of vertices in ascending order of their
weights. i.e. The vertex pair with least weight is the first pair of the list, the vertex pair
KASHIRAM POKHAREL
HCOE Page 3
with the next minimum weight is the second pair of the list and so on. Then we take the
vertex pair with the least minimum weight from this list and add it to the tree to be
formed .During the process of adding vertex pair to the tree, if any vertex pair with
minimum weight forms a cycle, we discard it and moves to the vertex pair with minimum
weight in the list. This process is continued until all the vertex pairs from the list are
added to the tree. when the list becomes empty,the resulting tree will be the minimum
spanning tree.
Find the minimum spanning tree from the following graph:

Solution:
The list of vertex pairs in ascending order of their weight
(V2,V3)=5
(V1,V3)=6
(V1,V2)=8
(V1,V4)=10
(V5,V7)=10
(V4,V3)=12
(V3,V6)=15
(V4,V6)=20
(V4,V5)=22
(V5,V6)=25
(V6,V7)=30

Since ,the vertex pair (V2,V3)=5 is the pair with least weight .so it is added to the tree.

Step 2:
The vertex pair in ascending order (V1,V3)=6 is minimum weight ,so it is added to the tree

KASHIRAM POKHAREL
HCOE Page 4
Step 3:

The least weighted vertex pair in the list is (V1,V2)=8 but it generates cycle.so discard it .
Again ,the least weight vertex pair in the list is (V1,V4)=10 .so it is added to the list.

Step iv:
The least weight vertex pair in the list is (V5,V7)=10 Hence it is added to the tree now the
tree becomes

STEP V:
The next least weight vertex pair in the list is (V4,V3)=12 but which generates the cycle in
the list so discard it
Again , the next least weight vertex pair in the list is (V3,V6)=15 hence it is added to the
tree.

KASHIRAM POKHAREL
HCOE Page 5
STEP VI:
The next least weighted vertex pair in the list is (V4,V6)=20 but which forms a cycle
hence discard it.
Again, the next least weighted vertex pair is (V4,V5)=22. Hence it is added to the tree.

Step vii:
The remaining weighted vertex pair in the list forms a cycle .Hence discard them .
Now the total weight of the tree is w=5+6+10+15+22+10=………..

Round robin algorithm:


It is an algorithm to find minimum spanning tree ,provides the better performance when
the number of edge is low. It is similar to kruskals algorithm except that there is a priority
queue of arcs associated with each partial tree rather than the one global priority queue of
all unexamined arcs.

Algorithm:
1. Initialize all the vertices in a priority queue
a. Each vertex is in it’s own set called partial tree and maintained in a queue
arbitrarily.
b. Maintain each edge associated with each node or partial tree in priority queue
ordered by the weight of the edges
2. Select a partial tree from queue and find the minimum weighted edge incident to the
partial tree from priority queue.
3. Find the partial tree that is connected by minimum path edge .remove two sub tree
joining by the edge and combine into a single new tree and add to rear of the queue.
a. Combine two priority queue of the node A and B (partial tree A and B) and
delete the edge connecting them from queue.
4. Repeat the algorithm until a queue contains a single tree which is called minimum
spanning tree.
Find the minimum spanning tree using Round robin algorithm:

KASHIRAM POKHAREL
HCOE Page 6
STEP 1:
1. Insert all the nodes in the queue(sequentially or randomly)
Queue: A, B, C, D, E, F
2. Now A can be removed from the queue. Select a minimum weighted edge of
partial tree of A. Here, AB=2 is the shortest edge connected with the node A. so
B is also removed from the queue .Now ,AB is a single partial tree and is inserted
from rear of the queue.
Queue: C,D,E,F,AB
Tree:

3. C can be removed from queue. select a minimum weighted edge of partial tree of
C. CF=2 is the shortest edge connected with C. so F is also removed from queue.
Now CF is a single partial tree and is inserted at the rear of the queue.
Queue: D,E,AB,CF
Tree:

4. D can be removed from queue. select a minimum weighted edge of partial tree of
D. Here, (D, AB)=1 is the shortest edge connected with D. so AB also removed
from queue. now, DAB is a single partial tree and is inserted at the rear of the
queue.
Queue: E, CF, DAB
Tree:

KASHIRAM POKHAREL
HCOE Page 7
5. Remove vertices E,CF and insert at rear of queue ECF
Queue: DAB,ECF
Tree:

6. DAB partial can be removed from queue, select a minimum weighted edge of
partial tree of DAB with another partial tree .Here DAB,ECF=3 is the shortest
edge so, insert at the rear of queue ABDECF
Queue: ABDEFC
Tree:

Which is the required minimum spanning tree.


And
Weight=10

KASHIRAM POKHAREL
HCOE Page 8

You might also like