# Lecture 24 Network models : Minimal Spanning Tree problem 24.1 ```Lecture 24
Network models : Minimal Spanning Tree problem
24.1 Minimal Spanning Tree Problem
A tree is defined to be an undirected, acyclic and connected graph. A spanning tree is a subgraph
of G (undirected, connected graph), is a tree and contains all the vertices of G. A minimum
spanning tree is a spanning tree but has weights or lengths associated with edges and the total
weight is at the minimum.
Prim’s Algorithm
 It starts at any vertex (say A) in a graph and finds the least cost vertex (say B) connected
to the start vertex.
 Now either from A or B, it will find the next least costly vertex connection, without
creating cycle (say C)
 Now either from A, B or C find the next least costly vertex connection, without creating a
cycle and so on.
 Eventually all the vertices will be connected without any cycles and a minimum spanning
tree will be the result.
Example 1
Suppose it is desired to establish a cable communication network that links major cities, which is
shown in the figure. Determine how the cities are connected such that the total cable mileage is
minimized.
Solution
C = {LA}
C = {LA, SE}
C = {LA, SE, DE}
C = {LA, SE, DE, DA}
C = {LA, SE, DE, DA, EH}
C = {LA, SE, DE, DA, EH, NY}
C = {LA, SE, DE, DA, EH, NY, DC}
C' = {SE, DE, DA, EH, NY, DC}
C' = {DE, DA, EH, NY, DC}
C' = {DA, EH, NY, DC}
C' = {EH, NY, DC}
C' = {NY, DC}
C' = {DC}
C' = { }
The resultant network is
1
Thus the total cable mileage is 1100 + 1300 + 780 + 900 + 800 + 200 = 5080
Example 2
For the following graph obtain the minimum spanning tree. The numbers on the branches
represent the cost.
Solution
C = {A}
C = {A, D}
C = {A, D, B}
C = {A, D, B, C}
C = {A, D, B, C, G}
C = {A, D, B, C, G, F}
C = {A, D, B, C, G, F, E}
C' = {B, C, D, E, F, G}
C' = {B, C, E, F, G}
C' = {C, E, F, G}
C' = {E, F, G}
C' = {E, F}
C' = {E}
C' = { }
The resultant network is
2
Cost = 2 + 1 + 4 + 3 + 3 + 5 = 18 units
3
```