0% found this document useful (0 votes)
29 views40 pages

6 Minimum Spanning Tree 10-02-2023

Uploaded by

pegan22525
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views40 pages

6 Minimum Spanning Tree 10-02-2023

Uploaded by

pegan22525
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

BMEE211L

ENGINEERING OPTIMIZATION
(Winter 2022-23)

Minimum Spanning Tree Algorithm

R. SUDHAKARA PANDIAN
School of Mechanical Engineering
VIT University

1
Network Models
• There is a many of operation research situation is
modeled and solved as a network.

• There are five network model algorithms


1- Minimal spanning tree
2- shortest-route algorithms
3- maximum-flow algorithms
4- minimum cost capacitated network algorithms
5- Critical path( CPM) algorithms

2
Network Models (CONT.)
1- A minimum spanning tree is a special kind of tree that
minimizes the lengths (or “weights”) of the edges of the tree.
An example is a cable company wanting to lay fiber optic cable
line to multiple neighborhoods; by minimizing the amount of
cable laid, the cable company will save money. The objective of
the model is minimizing the cost constructing the cable line.
• The situation represented as Minimal spanning tree.

2- Determination of the shortest route between two cities in a


network of roads.
• This situation is shortest-route algorithms

3
Network Models (CONT.)
3- determination the maximum capacity (in ton per year) of a
coal slurry pipeline network
• This situation is maximum flow algorithms

4- determination of the minimum-cost flow schedule from oil


field to refineries through a pipeline network.
• This situation is minimum-cost capacitated network
algorithms

4
Network Models (CONT.)
5- determination the time schedule (start and completion date)
for activities
• This situation is (CPM) algorithms

5
Network definitions
• A network consist of set of nodes linked by arcs ( or
branches)

• The notion for describing a network is (N, A) where:


• N is set of nodes (also known as vertex)
• A set of arc (also known as edge)

6
Network definitions (cont.)
• Example
3 5
1

2 4

N ={ 1,2,3,4,5}

A={(1,2), (1,3),(2,3),(2,5),(3,4),(3,5),(4,2),(4,5)}

• Flow : the amount sent from node i to node j, over an


arc that connects them.

7
Network definitions (cont.) 3 5
1

• Directed/undirected arcs : 2 4
• when flow is allowed in one direction the arc is
directed; (that means allow positive flow in one
direction and zero flow in the opposite direction)
• When flow is allowed in two directions, the arc is
undirected.
• Path : sequence of distinct arcs that join two nodes through
other nodes regardless of the direction of flow in each arcs.
• Example: arcs (1, 2), (2, 3), (3, 4), and (4, 5) form a path
between nodes 1 and 5.
• A network is said to be connected if every two distinct nodes
are linked by at least one path.

8
Network definitions (cont.) 3 5
1

2 4

• Cycle or Loop : A path forms a cycle or a loop if it connects


a node back to itself through other nodes.
• In the Figure, arcs (2, 3), (3, 4), and (4, 2) form a cycle or a
loop.
• Cycle or Loop is directed if it consists of directed path
(2,3),(3,4) and( 4,2)

9
Network definitions (cont.)
2
2 3 1 3
1 1

3 4
4 2
4 vertices 3 vertices 4 vertices
3 Arcs 1 Arc 4 Arcs
Connected Graph Not Connected Connected Graph
Graph
Not a Tree
Tree
It has more
Conditions:
than (n-1)
n vertices,
edges.
(n-1) edges
and
connected.
10
Network definitions (cont.)
Can a graph itself be a Tree ? YES…POSSIBLE

2 3 2 3
1 1

4 4

GRAPH TREE
• The above graph itself is TREE.
• connected network that may involve only a subset of all nodes of
network without cycle.

11
Network definitions (cont.)
Can a subset of a graph could be a Tree? YES…POSSIBLE
GRAPH SPANNING TREES
2 3
2 3 2 3
1
1 1

4
4 4

TREE
• Trees will all vertices from a graph
is called as SPANNING TREES. 2 3
1
• A Graph can have more than one
spanning tree.

12
Network definitions (cont.) 1
3 5

2 4

• Tree : is connected network that may involve only a subset of all


nodes of network without cycle.

• Spanning tree : a tree that connects all the nodes in a network with
no cycle( it consists of n -1 arcs).

1 3
1 3 5
2 4
2

Tree Spanning Tree


13
Minimal Spanning tree
• If the graph is weighted, then every possible spanning
tree we could identify will have an associated weight.
The spanning tree with minimum weight is the
MINIMUM SPANNING TREE.

2 8 3
5 2 8 3 2 3
1 5 5
1 1
10 3 3
3 10

4
4 4
GRAPH (a) SPANNING TREE (b) SPANNING TREE
Minimum Spanning Tree is (a), since the total weight is less
than (b)
14
Minimal Spanning tree
• The typical application occurs in construction of paved
roads that link several towns, either directly or
passing through other towns.

• Note: The arcs are not directed for MST problem.

15
Minimal Spanning Tree Algorithm
Let N={ 1,2,…n} set of nodes of the network and define,
– 𝐶𝑘 = set of nodes that have been permanently connected at iteration
K
– 𝐶𝑘 = set of nodes yet to be connected permanently.
Iteration 0: set 𝐶0 = ∅, 𝐶0 =N
Iteration 1: start with any node 𝑖 in the unconnected set 𝐶0 ;
set 𝐶1 = 𝑖 , rendering 𝐶1 = 𝑁 − 𝑖 . Set 𝑘 = 2.
Iterative step 𝒌 : selected node 𝑗 ∗ in unconnected set 𝐶𝑘−1
that yields shortest arc to a node in the connected set 𝐶𝑘−1 .
Link 𝑗 ∗ permanently to 𝐶𝑘−1 and remove it from 𝐶𝑘−1 to obtain 𝐶𝑘
and 𝐶𝑘 , respectively.
If the set of unconnected nodes (𝐶𝑘 ) is empty stop.
Otherwise set 𝑘 = 𝑘 + 1 and repeat the iterative step.

16
Minimal Spanning Tree Algorithm
• The thin arcs provide all the candidate links
between 𝐶 and 𝐶 .
• The thick arcs are the permanent links of the
connected set C, and
• The dashed arc is the new (permanent) link
added at each iteration.

17
Example (cont.)
• Midwest TV cable company is in the process of providing
cable service to five new housing development service
areas.

Iteration 0:
𝐶0 = ∅, 𝐶0 = N = 1,2,3,4,5,6 2 3
5
1 4 6
9
1 5
7 3 1
5 0
8 6

4 3 18
Iteration 1:
Example (cont.) The algorithms start with
node 1 in the unconnected
set 𝐶0 .

Then,
𝐶1 = 1 , 𝐶1 = 2,3,4,5,6

2 3 Branch (1, 2) is the shortest


5 link 1 (= 1 Km) among all
1 4 6 the candidate branches
from node 1 to nodes 2, 3,
9 4, and 5 in the unconnected
1 5 set 𝐶1 .

7 3 1
The dashed arc is the new
5 0 (permanent) link
6 added at this iteration.
8
Hence, link (1, 2) is made
4 3 permanent.

19
Iteration 1:
Example (cont.) The algorithms start with
node 1 in the
unconnected set 𝐶0 .

Then,
𝑪𝟏
𝐶1 = 1 , 𝐶1 = 2,3,4,5,6
2 3
5 Branch (1, 2) is the
1 4 6 shortest link 1 (= 1 Km)
among all the candidate
9 branches from node 1 to
1 5 nodes 2, 3, 4, and 5 in
7 3 1 the unconnected set 𝐶1 .
𝑪𝟏 5 0
The dashed arc is the
8 6
new (permanent) link
added at this iteration.
4 3
Hence, link (1, 2) is
made permanent. 20
Iteration 1:
Example (cont.) The algorithms start with
node 1 in the unconnected
set 𝐶0 .

Then,
𝑪𝟏 𝐶1 = 1 , 𝐶1 = 2,3,4,5,6

2 3 Branch (1, 2) is the shortest


5 link 1 (= 1 Km) among all
1 4 6 the candidate branches
from node 1 to nodes 2, 3,
9 4, and 5 in the unconnected
1 5 set 𝐶1 .

7 3 1
The dashed arc connection
𝑪𝟏 5 0 nodes 1 and 2 shows that
6 this is the new (permanent)
8 link added at this iteration.

4 3 Hence, link (1, 2) is made


permanent.
21
Iteration 1:
Example (cont.) The algorithms start with
node 1 in the
unconnected set 𝐶0 .

Then,
𝐶1 = 1 , 𝐶1 = 2,3,4,5,6
2 3
5 Branch (1, 2) is the
1 4 6 shortest link 1 (= 1 Km)
among all the candidate
9 branches from node 1 to
1 5 nodes 2, 3, 4, and 5 in
7 3 1 the unconnected set 𝐶1 .
5 0
The dashed arc is the
8 6
new (permanent) link
added at this iteration.
4 3
Hence, link (1, 2) is
made permanent. 22
Iteration 2
Example (cont.) 𝐶2 = 1,2 , 𝐶2 = 3,4,5,6

𝑪𝟐

2 3 4
5
1 4 64
9
1 5
7 3 1
𝑪𝟐 5 0 2 3 5
6
8 1 46
1 9
4 3 5 3 10

7
5 6
8 23
4
3
Iteration2
Example (cont.) 𝐶2 = 1,2 , 𝐶2 = 3,4,5,6
Branch (2,5) is the shortest
link (= 3 Km) among all the
𝑪𝟐 candidate branches from
nodes 1 and 2 to nodes
3,4,5 and 6 in the
2 3 unconnected set 𝐶2 .
5
1 4 6
9
1 5
7 3 1
2 3 5
𝑪𝟐 5 0 1 46
8 6 1 9
5 3 10

7
4 3 5 6
8
4
3 24
Iteration 2
Example (cont.) 𝐶2 = 1,2 , 𝐶2 = 3,4,5,6
Branch (2,5) is the shortest
link (= 3 Km) among all the
𝑪𝟐 candidate branches from
nodes 1 and 2 to nodes
3,4,5 and 6 in the
2 3 unconnected set 𝐶2 .
5
The dashed arc is the new
1 4 6 (permanent) link added at
this iteration.
9
1 5
7 3 1
2 3 5
𝑪𝟐 5 0 1 46
8 6 1 9
5 3 10

7
4 3 5 6
8
4
3 25
Iteration 2
Example (cont.) 𝐶2 = 1,2 , 𝐶2 = 3,4,5,6
Branch (2,5) is the shortest
link (= 3 Km) among all the
candidate branches from
𝑪𝟐 nodes 1 and 2 to nodes
3,4,5 and 6 in the
unconnected set 𝐶2 .
2 3 The dashed arc is the new
5
(permanent) link added at
1 4 6 this iteration.
9 Hence, link (2,5) is made
permanent.
1 5
7 3 1
2 3 5
𝑪𝟐 5 0 1 46
8 6 1 9
5 3 10

7
4 3 5 6
8
4
3 26
Iteration 3
Example (cont.) 𝐶3 = 1,2,5 , 𝐶3 = 3,4,6
Branch (2,4) is the shortest
link (= 3 Km) among all the
𝑪𝟑 candidate branches from
nodes 1,2, and 5 to nodes
3,4 and 6 in the
2 3 unconnected set 𝐶3 .
5
The dashed arc is the new
1 4 6 (permanent) link added at
this iteration.
9 𝑪𝟑
1 Hence, link (2,4) is made
5 permanent.
7 3 1
5 0 23 5
6
8
8 1 46
1 9
4 3 5 3 10

7
5 6
8 27
4
3
Iteration 3
Example (cont.) 𝐶3 = 1,2,5 , 𝐶3 = 3,4,6
Branch (2,4) is the shortest
link (= 4 Km) among all the
𝑪𝟑 candidate branches from
nodes 1,2, and 5 to nodes
3,4 and 6 in the
2 3 unconnected set 𝐶3 .
5
The dashed arc is the new
1 4 6 (permanent) link added at
this iteration.
9 𝑪𝟑
1 Hence, link (2,4) is made
5 permanent.
7 3 1
2 3 5
5 0 1 46
8 6 1 9
5 3 10

7
4 3 5 6
8
4
3 28
Iteration 3
Example (cont.) 𝐶3 = 1,2,5 , 𝐶3 = 3,4,6
Branch (2,4) is the shortest
link (= 4 Km) among all the
𝑪𝟑 candidate branches from
nodes 1,2, and 5 to nodes
3,4 and 6 in the
2 3 unconnected set 𝐶3 .
5
The dashed arc is the new
1 4 6 (permanent) link added at
this iteration.
9 𝑪𝟑
1 Hence, link (2,4) is made
5 permanent.
7 3 1
2 3 5
5 0 1 46
8 6 1 9
5 3 10

7
4 3 5 6
8
4
3 29
Iteration 4
Example (cont.) 𝐶4 = 1,2,4,5 , 𝐶4 = 3,6
Branch (4,6) is the shortest
link (= 3 Km) among all the
𝑪𝟒 candidate branches from
nodes 1,2,4,and 5 to nodes
3 and 6 in the unconnected
2 3 set 𝐶4 .
5
The dashed arc is the new
1 4 6 (permanent) link added at
this iteration.
9
1 Hence, link (4,6) is made
5 𝑪𝟒 permanent.
7 3 1
5 0 23 5
6
8 1 46
1 9
4 33 5 3 10

7
5 6
8 30
4
3
Iteration 4
Example (cont.) 𝐶4 = 1,2,4,5 , 𝐶4 = 3,6
Branch (4,6) is the shortest
link (= 3 Km) among all the
candidate branches from
𝑪𝟒 nodes 1,2,4,and 5 to nodes
3 and 6 in the unconnected
2 3 set 𝐶4 .
5
The dashed arc is the new
1 4 6 (permanent) link added at
this iteration.
9
1 Hence, link (4,6) is made
5 𝑪𝟒 permanent.
7 3 1
2 3 5
5 0 1 46
8 6 1 9
5 3 10

7
4 3 5 6
8
4
3 31
Iteration 4
Example (cont.) 𝐶4 = 1,2,4,5 , 𝐶4 = 3,6
Branch (4,6) is the shortest
link (= 3 Km) among all the
candidate branches from
𝑪𝟒 nodes 1,2,4,and 5 to nodes
3 and 6 in the unconnected
set 𝐶4 .
2 3
5 The dashed arc is the new
1 4 6 (permanent) link added at
this iteration.
9 Hence, link (4,6) is made
1 5 𝑪𝟒 permanent.
7 3 1
2 3 5
5 0 1 46
8 6 1 9
5 3 10

7
4 3 5 6
8
4
3 32
Iteration 5
Example (cont.) 𝐶5 = 1,2,4,5,6 , 𝐶5 = 3
Tie between branch (1,3)
and (4,3) with 5km.
𝑪𝟓 Resolve the tie arbitrarily.
Let us choose (4,3).
The dashed arc is the new
2 3 (permanent) link added at
5
this iteration.
1 4 6
Link (4,3) is made
9 permanent.
1 5 𝑪𝟓
7 3 1
5 0 23 5
6
8 1 46
1 9
4 3 5 3 10

7
5 6
8 33
4
3
Iteration 5
Example (cont.) 𝐶5 = 1,2,4,5,6 , 𝐶5 = 3
Tie between branch (1,3)
and (4,3) with 5km.
𝑪𝟓 Resolve the tie arbitrarily.
Let us choose (4,3).
The dashed arcs show the
2 3 possible new (permanent)
5
link added at this iteration.
1 4 6
Hence, link (4,3) is made
9 permanent.
1 C5
5 𝑪𝟓
7 3` 1
2 3 5
5 0 1 46
8 6 1 9
5 3 10

Alternate 7
links
4 3 5 6
8
4
3 34
Iteration 5
Example (cont.) 𝐶5 = 1,2,4,5,6 , 𝐶5 = 3
Tie between branch (1,3)
and (4,3) with 5km.
Resolve the tie arbitrarily.
Let us choose (4,3).
The dashed arcs show the
2 3 possible new (permanent)
5
link added at this iteration.
1 4 6
Link (4,3) is made
9 permanent.
1 5
7 3 1
5 0 2 3 5
8 6 1 46
1 9
5 3 10

4 3 7
5 6
8
4 35
3
Example (cont.)
• 𝐶6 = 1,2,3,4,5,6 , 𝐶6 = ∅.
Since 𝐶6 = ∅, process stopped.
• Summery of solution
iteration Minimum distance Add arc to tree? Cumulative tree
distance distance
connecting arc
1 (1,2) 1 yes 1
2 (2,5) 3 yes 4
3 (2,4) 4 yes 8
4 (4,6) 3 yes 11
5 (4,3) 5 yes 16

36
Example 2
• Apply minimal spanning tree

7 D 4
B
5 9 F
2 C

A 8 8 3
7 E

37
Solution

7 D 4
B
5 9 F
2 C
A 8 8 3
7 D 4
7 E B
5 9 F
2 C
A 8 8 3
7 E
38
Solution (cont.)

7 D 4
B
5 9 F
2 C
A 8 8 3
7 D 4
7 E B
5 9 F
2 C
A 8 8 3
7 E
39
Solution (cont.)

7 D 4
B
5 9 F
2 C
A 8 8 3
7 D 4
7 E B
5 9 F
2 C
A 8 8 3
7 E
40

You might also like