You are on page 1of 25

Lecture 7

NETWORK MODEL

 Minimum spanning tree problems

 Shortest path problems

 Maximum flow problems

 CPM-PERT project scheduling models

1
Situations using Network Model
 Design offshore natural-gas pipeline

 Shortest route between 2 cities

 Determination of maximum capacity


of a coal slurry pipeline network

 Time schedule (start and completion


dates) for activities of a construction
project
2
Basic Definitions
A graph or network is defined by two sets of symbols:
• Nodes: A set of points or vertices (call it V) are
called nodes of a graph or network.
Nodes

1 2

• Arcs: An
arc consists of an ordered pair of vertices
and represents a possible direction of motion that
may occur between vertices. Arc

1 2
3
Basic Definitions
1 3 5
• Connected Network
• Directed Network 2
4

• Cycle / loop
• Path 1 3 5

• Simple path
4
• Simple cycle 2

• Tree
1 3
• Spanning Tree

4
Basic Definitions
For example in the figure below:
(1,2)-(2,3)-(4,3) is not a path;
(1,2)-(2,3)-(3,4) is a path, which represents a way
to travel from node 1 to node 4.

1 4

2 3
5
Minimal Spanning Tree
Step 1: Get connected &
unconnected array

Step 2: Select any node


from unconnected array

Step 3: Choose shortest


arc from selected
unconnected array

Step 4: Link permanently to connected array and


deleted from unconnected array
6
Minimal Spanning Tree

7
Shortest Path Problems
 Assume that each arc in the network has a
length associated with it.

 Suppose we start with a particular node. The


problem of finding the shortest path from node 1
to any other node in the network is called a
shortest path problem.

 Two algorithms: Dijkstra’s algorithm


Floyd’s algorithm

8
Car (or machine) replacement example:
Let’s assume that we have just purchased a new car
(or machine) for $12,000 at time 0. The cost of
maintaining the car during a year depends on the
age of the car at the beginning of the year, as given
in the table below.

Age of Car Annual Age of Car Trade-in Price


(Years) Maintenance cost (Years)
0 $2,000 1 $7,000
1 $4,000 2 $6,000
2 $5,000 3 $2,000
3 $9,000 4 $1,000
4 $12,000 5 $0

9
Car (or machine) replacement example:
 In order to avoid the high maintenance cost associated
with an older car, we may trade in the car and purchase a
new car.The trade-in prices are also given in the table.

 To simplify the computations we assume that at any time


it costs $12,000 to purchase a new car. Our goal is to
minimize the net cost incurred during the next five years.

 Let’s formulate this problem as a shortest path problem.


Our network will have six nodes.
1. Node i is the beginning of year i and for i<j, an arc (i,j)
corresponds to purchasing a new car at the beginning
of year i and keeping it until the beginning of year j.
2. The length of arc (i,j) (call it cij) is the total net cost
incurred from year i to j.
10
Car (or machine) replacement example:
cij = maintenance cost incurred for years i,i+1,…,j-1
+ cost of purchasing a car at the beginning of year i
- trade-in value received at the beginning of year j.
Applying this formula to the information we will
obtain the following:
c12=2+12-7=7 c13=(2+4)+12-6=12
c14=(2+4+5)+12-2=21 c15=(2+4+5+9)+12-1=31
c16=(2+4+5+9+12)+12-0=44
c23=2+12-7=7 c24=(2+4)+12-6=12
c25=(2+4+5)+12-2=21 c26=(2+4+5+9)+12-1=31
c34=2+12-7=7 c35=(2+4)+12-6=12
c36=(2+4+5)+12-2=21
c45=2+12-7=7 c46=(2+4)+12-6=12
c56=2+12-7=7 11
Network for minimizing car costs

From the figure below we can see that


both path 1-3-5-6 and 1-2-4-6
give the shortest path with a value of 31.
44

31 31

21 21

12
12

1 7
2 7
3 7
4 7
5 7
6

12 12

21

12
Shortest Path Problem
Dijkstra’s Algorithm: source node to every other nodes.
Node Label : [ Distance , from node i ]
Temporary labels (shortest) Permanent labels

[4, C]

[0, -]

[1, B]
13
Shortest Path Problem
Node Label Status Change Node Label Status Change
In Status In Status
Iteration 3 Iteration 4
B [0,–] P B [0,–] P
C [1,B] P C [1,B] P
A [4,C] P A [4,C] P
E [4+1,C] T F [4,C] P
F [1+3,C] T ← P E [5,C] T ← P
D [4+8,A] T D [12,A] T
G [11,F] T
Iteration 5 Iteration 6
B [0,–] P B [0,–] P
C [1,B] P C [1,B] P
A [4,C] P A [4,C] P
F [4,C] P F [4,C] P
E [5,C] P E [5,C] P
D [12,A] T G [7,E] P
G [7,E] T ← P

BC EG Minimum distance is 7


14
Shortest Path Problem
Floyd’s Algorithm: any two nodes in the network.
Use square matrix with n rows and n columns

Distance, d Sequence, S

dik + dkj < dij

15
Floyd’s Algorithm
Step 0: Define the starting distance matrix D0 and node
sequence matrix S0. The diagonal elements are marked (-) to
indicate that they are blocked.

Step 1 … n: Set k = n

Define row k and column k as pivot row and pivot column.


Apply the triple operation to each element dij in Dk-1 , for all
i and j .
If the condition dik + dkj < dij , ( i  k , j  k , and i  j ) is
satisfied, make the following changes:

(i) Create Dk by replacing dij in Dk-1 with dik + dkj .

(ii) Create Sk by replacing sij in Sk-1 with k.

Set k = k+1, and repeat step k.

16
Floyd’s Algorithm Example

1 2 3
1 - 4 5
D0 =
2 2 - 
1 5
3  -3 -
4 2 3
1 2 3
-3 1 - 2 3
2
S= 2 1 - 3
3 1 2 -

17
Floyd’s Algorithm Example
1 1 2 3
k=1 5 D0 =1 - 4 5
Vertex 1 can be 4 2 3
2 2 - 
intermediate -3
2 3  -3 -
node
1 2 3
1 - 4 5 D1[2,3] = min( D0[2,3], D0[2,1]+D0[1,3] )
D1 =
2 2 - 7 = min (, 7)
3  -3 - =7

1 2 3
1 - 2 3 D1[3,2] = min( D0[3,2], D0[3,1]+D0[1,2] )
= min (-3,)
S= 2 1 - 1
= -3
3 1 2 -
No changes 18
Floyd’s Algorithm Example
1 5 1 2 3
k=2 D1 =1 - 4 5
Vertices 1, 2 can 4 2 3
2 2 - 7
be intermediate -3
2 3  -3 -
1 2 3
1 - 4 5 D2[1,3] = min( D1[1,3], D1[1,2]+D1[2,3] )
D2 = 2 2 - 7 = min (5, 4+7)
=5
3 -1 -3 -

1 2 3
1 - 2 3 D2[3,1] = min( D1[3,1], D1[3,2]+D1[2,1] )
S= = min (, -3+2)
2 1 - 1
= -1
3 2 2 -
No changes
19
Floyd’s Algorithm Example
k=3 1 1 2 3
5 D2 =
Vertices 1, 2, 3 1 - 4 5
can be 4 2 3
2 2 - 7
intermediate -3
2 3 -1 -3 -
1 2 3
1 - 2 5 D3[1,2] = min(D2[1,2], D2[1,3]+D2[3,2] )
D3 =
2 2 - 7 = min (4, 5+(-3))
3 -1 -3 - =2

1 2 3
1 - 3 3 D3[2,1] = min(D2[2,1], D2[2,3]+D2[3,1] )
S= 2 1 - 1 = min (2, 7+ (-1))
3 2 2 - =2
No changes
20
Maximum Flow Problems
 Many situations can be modeled by a network
in which the arcs may be thought of as having a
capacity that limits the quantity of a product that
may be shipped through the arc.
 In these situations, it is often desired to
transport the maximum amount of flow from a
starting point (called the source) to a terminal
point (called the sink).
 Such problems are called maximum flow
problems.

21
Example for maximum flow problem
Sunco Oil wants to ship the maximum possible
amount of oil (per hour) via pipeline from node so
to node si as shown in the figure below.
Arc Capacity
(0)3
(so,1) 2
so (2)2
1 (2)3
2 (2)2
si (so,2) 3
(1,2) 3
(0)4 3 (0)1

(xij) uij (1,3) 4


flow capacity (3,si) 1
(2,si) 2

The various arcs represent pipelines of different diameters. The


maximum number of barrels of oil that can be pumped through
each arc is shown in the table above (also called arc capacity).
22
Maximal Flow Model
Find breakthrough paths with net positive flow between source and sink nodes.

Step 1. Let a1 =  and label the source node 1 with [, - ] . Set i =1
Step 2. Determine S = unlabeled nodes j from node i (Cij > 0 ).
Step 3. Determine k Si such that Cik = max {Cij}, for j  Si.
Step 4. (Backtracking). If i = 1, no further breakthroughs are possible;
go to step 6.
Step 5. (Determination of residue network). the maximum flow along
the path is computed as fp = min { a1 , ak1 , ak2 , …, an }.
The residual capacity of is decreased by fp in the direction of the flow
and increase by fp in the reverse direction.
Step 6. (Solution).
Given that m breakthrough paths have been determined, the maximal
flow in the network is F = f1 + f 2+ ……… + fm
23
Maximal Flow Model
Iteration 1
Step 1: i = 1, [ ∞, - ], a1= ∞
Step 2: S1={2, 3, 4}
Step 3: k = 3, a3= 30
C13 = max {C12, C13, C14}
= max{20, 30, 10}=30
Step 2: S3={4, 5}
Step 3: k = 5, a5= 20
C35 = max {C34, C45}
= max{10, 20}=20 Residual capacities
Breakthrough (C13, C31)=(30-20, 0+20)
Step 5: Max flow along path =(10,20)
f1 = min(a1 , a3, a5) = 20 (C35, C53)=(20-20, 0+20)
=(0,20)
24
Maximal Flow Model

F= 60 units
25

You might also like