Académique Documents
Professionnel Documents
Culture Documents
Network Models
Mjdah Al Shehri
Mute ur call
Network Models
There is a many of operation research situation is
modeled and solved as network ( nodes can
connected by branches)
There are five network models algorithms
1- Minimal spanning tree
2- shortest-route algorithms
3- maximum-flow algorithms
4- minimum cost capacitated network algorithms
5- Critical path( CPM) algorithms
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
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
A set of arc
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
1
2
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.
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
Example:
1
2
10
1
2
1
Tree
3
2
3
2
5
4
Spannin
g Tree
11
12
13
Example (cont.)
Midwest TV cable company is in the process of providing
cable service to five new housing development service
areas.
3
2
4 6
1
9
1
5
3
1
0
6
8
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
14
Example (cont.)
The algorithms start at node 1
2
4 6
1
9
1
5
3
1
0
6
8
4
15
Example (cont.)
Iteration 1
C1
`
4 6
1
C
1
9
1
5
3
1
0
6
8
4
16
Example (cont.)
C1
`
4 6
1
C
1
9
1
5
3
1
0
6
8
4
17
Example (cont.)
2
C
1
2
3
5
4 6
9
5
3
1
0
6
8
4
18
Example (cont.)
2
C
1
2
C2
`
3
4 6
9
1
5
3
1
0
6
8
4
2 3
1 46
9
1 5
7
3
5
4
1
0
8
3
19
Example (cont.)
iteration2
C
2
C2
`
3
4 6
9
1
5
3
1
0
6
8
4
20
Example (cont.)
C
2
C2
`
3
4 6
9
1
5
3
1
0
6
8
4
21
Example (cont.)
C
3
4 6
1
9
1
5
3
1
0
6
8
C3
`
2 3
1 46
9
1 5
7
3
5
4
1
0
8
3
22
Example (cont.)
iteration3
C
3
4 6
1
9
1
5
3
1
0
6
8
C3
`
23
Example (cont.)
C
3
4 6
1
9
1
5
3
1
0
6
8
C3
`
24
Example (cont.)
C
4
3
5
4 6
1
9
1
5
3
1
0
C4
`
6
8
4
2 3
1 46
9
1 5
7
3
5
4
1
0
8
3
25
Example (cont.)
iteration4
C
4
3
5
4 6
1
9
1
5
3
1
0
C4
`
6
8
4
26
Example (cont.)
C
4
3
5
4 6
1
9
1
5
3
1
0
C4
`
6
8
4
27
Example (cont.)
C
5
3
5
4 6
1
9
1
C5
`
3 1
0
5
5
7
8
4
2 3
1 46
9
1 5
7
3
5
4
1
0
8
3
28
Example (cont.)
iteration5
C
5
3
5
4 6
1
9
7
C5
`
3 1
0
5
Alternat
e links
6
3
29
Example (cont.)
C
5
3
5
4 6
1
9
7
C5
`
3 1
0
5
Alternat
e links
6
3
30
Example (cont.)
2
3
5
4 6
1
9
1
5
3
1
0
6
8
4
31
Example (cont.)
Summery of solution
iteration
Minimum
distance
connecting arc
distance
Cumulative tree
distance
(1,2)
yes
(2,5)
yes
(2,4)
yes
(4,6)
yes
11
(4,3)
yes
16
32
Example 2
Apply minimal spanning tree
D
B
5
C
A
8
7
3
E
33
Solution
D
8
7
3
B
7
5
2
A
4
F
C
8
8
7
3
E
34
Solution (cont.)
D
2
A
4
F
C
8
8
7
3
E
2
A
4
F
C
8
8
7
3
E
35
Solution (cont.)
D
2
A
4
F
C
8
8
7
3
E
2
A
4
F
C
8
8
7
3
E
36
Example 3
4
F
9
B
6
5
9
7
9
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
37
Solution
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
38
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
39
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
40
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
41
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
42
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
43
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
44
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
45
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
46
Solution (cont.)
4
F
9
B
6
5
9
7
8
2
A
10
9
9
18
D
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
47
48
Dijkstraa algorithm
Step0: label the source node(node1) with the permanent
label [0,--]. Set i=1
Stepi= (a) compute the temporary labels[ui+dij,i] for each
node j that can be reached through node i. provided j is
not permanently label. If node j is already label with [uj,k]
through another node k and if ui+dij< uj, replace [uj,k] with
[ ui+ dij, i]
(b) if all node have premanent label stop. Otherwise
select the label [Ur,s] having the shortest distance (=ui)
among all temporary label. Set i=r and repeat step i
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
49
Example
The figure give the route and their length in
miles between city 1 and four other cities.
Determine the shortest route between city 1 and
each of the remaining four cities.
15
100
20
1
30
50
10
60
50
100
Example(cont.)
15
20
1
30
50
10
60
label
status
[0,--]
permanent
[0+100, 1]
temporary
[0+30,1]
temporary
51
100
Example(cont.)
15
20
1
30
50
10
60
Iteration2: node 4, and 5 can be reached from node 3 and the list labeled
node becomes:
Node
label
status
[0,--]
permanent
[100, 1]
temporary
[30,1]
Permanent
[30+10,3]=[40,3]
temporary
[30+60,3]=[90,3]
temporary
node 4 is smallest distance so from the temporaries list. so, status of node
4 is changed to permanent
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
52
100
Example(cont.)
15
20
1
30
50
10
60
Iteration 3: node 2 and 5 can be reached from node4. the list of labeled
is updated as
Node
label
status
[0,--]
permanent
[40+12,4]=[55,4]
temporary
[30,1]
Permanent
[40,3]
Permanent
[90,3] or [40+50,4]
temporary
Node 2 is permanent
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
53
Example(cont.)
Iteration 4: only node 3 can be reached from node 2, the node 3 is
permanent , so the new list remain the same
Node
label
status
[0,--]
permanent
[55,4]
permanent
[30,1]
Permanent
[40,3]
Permanent
[90,3] or [40+50,4]
temporary
54
Example(cont.)
The process ends
Node
label
status
[0,--]
permanent
[55,4]
permanent
[30,1]
Permanent
[40,3]
Permanent
[90,3] or [40+50,4]
Permanent
55
Floyds algorithm
Step0: define starting distance matrix D0 and node sequence
matrix S0. the diagonal elements are marked with(-). Set k=1
General step k: define row k and column as pivot row and pivot
column. Apply the triple operation to each element dij in Dk-1.
if the condition:
Dik+dkj<dij
Is satisfied, make the following changes:
(a) creat Dk by replacing dij in Dk-1 with dik+dkj
(b) create Sk by repacing sij in sk-1 with k. set k=k+1 and
repeat step k.
56
57
Example
2
4
4
6
15
10
D0
s0
58
Example (cont.)
K=1
We highlight the first column and first row of the Distance matrix and
compare all other items with the sum of the items highlighted in the
same row and column.
If the sum is less than the item then it should be replaced with the sum.
59
Example (cont.)
D0
S0
60
Example (cont.)
D0
S0
61
Example (cont.)
D0
S0
62
Example (cont.)
D0
S0
63
Example (cont.)
D0
S0
64
Example (cont.)
D0
S0
65
Example (cont.)
D0
S0
66
Example (cont.)
D0
S0
67
Example (cont.)
D0
S0
68
Example (cont.)
D0
S0
69
Example (cont.)
D0
S0
70
Example (cont.)
D0
S0
71
Example (cont.)
D0
S0
72
Example (cont.)
D0
S0
73
Example (cont.)
D0
S0
74
Example (cont.)
D0
S0
75
Example (cont.)
D0
S0
76
Example (cont.)
77
Example (cont.)
We have now completed one iteration. We
rename the new matrices:
D1
S1
78
Example (cont.)
Set k=2
We highlight the second column and second
row of the Distance matrix and compare all
other items with the sum of the items highlighted
in the same row and column.
If the sum is less than the item then it should be
replaced with the sum.
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
79
Example (cont.)
D1
S1
80
Example (cont.)
D1
S1
81
Example (cont.)
D1
S1
82
Example (cont.)
D1
S1
83
Example (cont.)
D1
S1
84
Example (cont.)
D1
S1
85
Example (cont.)
D1
S1
86
Example (cont.)
D1
S1
87
Example (cont.)
D1
S1
88
Example (cont.)
D1
S1
89
Example (cont.)
D1
S1
90
Example (cont.)
D1
S1
91
Example (cont.)
D1
S1
92
Example (cont.)
D1
S1
93
Example (cont.)
D1
S1
94
Example (cont.)
D1
S1
95
Example (cont.)
D1
S1
96
Example (cont.)
D1
S1
97
Example (cont.)
D1
S1
98
Example (cont.)
We have now completed two iteration. We
rename the new matrices:
D2
S2
99
Example (cont.)
Set k=3
We highlight the third column and third row of
the Distance matrix and compare all other items
with the sum of the items highlighted in the same
row and column.
If the sum is less than the item then it should be
replaced with the sum.
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
100
Example (cont.)
D2
S2
101
Example (cont.)
D2
S2
102
Example (cont.)
D2
S2
103
Example (cont.)
We have now completed third iteration. We
S3
renameD3the new matrices:
104
Example (cont.)
Set k=4
We highlight the fourth column and fourthrow of
the Distance matrix and compare all other items
with the sum of the items highlighted in the same
row and column.
If the sum is less than the item then it should be
replaced with the sum.
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
105
Example (cont.)
D3
S3
106
Example (cont.)
D3
S3
107
Example (cont.)
We have now completed fourth iteration. We
S4
renameD4the new matrices:
108
Example (cont.)
Set k=5
We highlight the fifth column and fifth row of the
Distance matrix and compare all other items
with the sum of the items highlighted in the same
row and column.
If the sum is less than the item then it should be
replaced with the sum.
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
109
Example (cont.)
D4
S4
110
Example (cont.)
D4
S4
111
Example (cont.)
112
113
113
How it works
In maximum flow algorithm, we determine if there
is any path from source to sink that can carry flow.
If there is , the flow is augmented as much as
possible along this path; and residual capacities of
the arc used on the path are reduced accordingly.
114
114
GO TO STEP 1
Hamdy A. Taha, Operations Research: An introduction, Prentice Hall
115
115
Example
Determine the maximum flow in the network.
0
20
5
10
0
0
30
20
30
0
0
40
10
20
116
116
Example (cont.)
Iteration1:
Select Path: 145
Residual capacities
1-4
10
2-5
20
0
Augment flow by 10
Reduce forward capacities by 10
Increase backward capacities by 10
20
5
10
30
0
30
0
40
10
20
10
10
20
10
10
10
20
30
0
30
0
40
10
20
117
117
Example (cont.)
Iteration 2:
No additional possible flow along arc(1,4); thus find new path; Select
path 1345
Residual capacities
1-3
30
3-4
10
4-5
10
10
10
10
Augment flow by 10
Reduce forward capacities by 10
Increase backward capacities by 10
10
10
10
30
20
0 10
30
0
40
0
20
20
20
0
0
15
10
20
10
10
10
10
30
10 0
40
0
20
118
118
Example (cont.)
Iteration 3:
No additional possible flow along arc(3,4) and (4,5); thus find new path;
Select path 135
Residual capacities
1-3
20
3-5
20
10
10
20
10
40
0
0
10 0
30
0
10
20
20
0
15
20
20
10
10
0
20
0
20
30 0
30
0
20
10
20
20
10
0
15
Augment flow by 20
Reduce forward capacities by 20
Increase backward capacities by 20
40
20
119
119
Example (cont.)
Iteration 4:
No additional possible flow along arc(1,3) and (3,5); thus find new path;
Select path 125
Residual capacities
1-2
20
2-5
30
10
10
20
0
10
20
0
20
30 0
30
40
10
20
0
0
15
20
20
20 5
20
30
20
0
20
10
30
20
10
0
15
Augment flow by 20
Reduce forward capacities by 20
Increase backward capacities by 20
10
20
40
30 0
0
20
120
120
Example (cont.)
Iteration 4:
No more flow is possible flow because there is no residual capacity left
on the cut consisting (1,2),(1,3), and (1,4); so maximum flow is
10
20
4 0
20+30+10=60.
10
From
To
Flow
20
30
10
20
10
20
20
30
20
0
20
10
15
10
20
Hamdy A. Taha,
An introduction, Prentice Hall
5 Operations Research:
20
40
20
20
30 0
0
20
121
121