SlideShare una empresa de Scribd logo
1 de 78
Descargar para leer sin conexión
Network flow problems
Network flow problems
- Introduction of:
network, max-flow problem
capacity, flow
- Ford-Fulkerson method
pseudo code, residual networks, augmenting paths
cuts of networks
max-flow min-cut theorem
example of an execution
analysis, running time,
variations of the max-flow problem
Introduction – network
Practical examples of a network
- liquids flowing through pipes
- parts through assembly lines
- current through electrical network
- information through communication network
- goods transported on the road…
Introduction - network
Example: oil pipelineRepresentation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
S t
v1
v2
v3
v4source sink
Introduction – max-flow
problemRepresentation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
S t
v1
v2
v3
v4source sink
Informal definition of the max-flow problem:
What is the greatest rate at which material can be shipped
from the source to the sink without violating any capacity
contraints?
Example: oil pipeline
Introduction - capacity
S t
v1
v2
v3
v4
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
u v
12
u v
6
c(u,v)=12
c(u,v)=6
Big pipe
Small pipe
8
3
6
8
6
6
3
3
Example: oil pipeline
Introduction - capacity
S t
v1
v2
v3
v4
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
8
3
6
8
6
6
3
3
Example: oil pipeline
v4
v2
v3
v4
If (u,v)  E  c(u,v) = 0
0
0
0
6
Introduction – flow
S t
v1
v2
v3
v4
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
u v
6/12
u v
6/6
f(u,v)=6
f(u,v)=6
Flow below capacity
Maximum flow
8
3
6
8
6
6
3
3
Example: oil pipeline
Introduction – flow
S t
v1
v2
v3
v4
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
8
3
6
8
6
6
3
3
Example: oil pipeline
Introduction – flow
S t
v1
v2
v3
v4
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
8
3
6
6/8
6/6
6/6
3
3
Example: oil pipeline
Introduction – flow
S t
v1
v2 v4
v3
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
8
3
6
6/8
6/6
6/6
3
3
Example: oil pipeline
Introduction – flow
S t
v1
v2 v4
v3
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
3/8
3/3
3/6
6/8
6/6
6/6
3
3
Example: oil pipeline
Introduction – flow
S t
v1
v2 v4
v3
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
3/8
3/3
3/6
6/8
6/6
6/6
3
3
Example: oil pipeline
Introduction – flow
S t
v1
v2 v4
v3
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
5/8
3/3
3/6
8/8
6/6
6/6
2/3
3
Example: oil pipeline
Introduction – cancellation
S t
v1
v2 v4
v3
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
5/8
3/3
3/6
8/8
6/6
6/6
2/3
3
Example: oil pipeline
Introduction – cancellation
S t
v1
v2 v4
v3
Representation
Flow network: directed graph G=(V,E)
S t
v1
v2
v3
v4
6/8
3/3
4/6
8/8
5/6
6/6
3/3
1/3
u
v
10 4
u
v
8/10 4
u
v
8/10 3/4
u
v
5/10 4
Example: oil pipeline
Maximum Flow Problem: definitions
D
M
K
S
B
P
8
14
146
12
10
10
7
17
6
D
M
K
S
B
P
8
14
146
12
10
10
7
17
6
SOURCE:
Node with net outflow:
Production point
SINK:
Node with net inflow;
Consumption point
CAPACITY:
Maximum flow
on an edge
Efficient method to solve such problems: Ford-Fulkerson Method
Flow properties
Flow in G = (V,E): f: V x V R with 3 properties:
1) Capacity constraint: For all u,v  V : f(u,v) < c(u,v)
2) Skew symmetry: For all u,v  V : f(u,v) = - f(v,u)
3) Flow conservation: For all u  V  {s,t} :  f(u,v) = 0
v  V
Flow properties
Flow in G = (V,E): f: V x V R with 3 properties:
1) Capacity constraint: For all u,v  V : f(u,v) < c(u,v)
2) Skew symmetry: For all u,v  V : f(u,v) = - f(v,u)
3) Flow conservation: For all u  V  {s,t} :  f(u,v) = 0
v  V
S t
v1
v2
v3
v4
12/12
11/14
Flow network G = (V,E)
Note:
by skew
symmetry
f (v3,v1) = - 12
Net flow and value of a flow
Net Flow:
positive or negative value
of f(u,v)
Value of a Flow f:
Def:
|f| =  f(s,v)v  V
S t
v1
v2
v3
v4
6/8
3/3
4/6
8/8
5/6
6/6
3/3
1/3
u
v
8/10 3/4
u
v
5/10 4
f(u,v) = 5
f(v,u) = -5
The max-flow problem
Informal definition of the max-flow problem:
What is the greatest rate at which material can be shipped
from the source to the sink without violating any capacity
contraints?
Formal definition of the max-flow problem:
The max-flow problem is to find a valid flow for a given
weighted directed graph G, that has the maximum value over
all valid flows.
The Ford-Fulkerson method
a way how to find the max-flow
This method contains 3 important ideas:
1) residual networks
2) augmenting paths
3) cuts of flow networks
Ford-Fulkerson – pseudo code
1 initialize flow f to 0
2 while there exits an augmenting path p
3 do augment flow f along p
4 return f
Ford Fulkerson – residual
networks
S t
v1
v2
v3
v4
12/12
11/14
The residual network Gf of a given flow network G with a valid flow f
consists of the same vertices v  V as in G which are linked with
residual edges (u,v)  Ef that can admit more strictly positive net flow.
The residual capacity cf represents the weight of each edge Ef and is
the amount of additional net flow f(u,v) before exceeding the capacity
c(u,v)
Flow network G = (V,E)
cf(u,v) = c(u,v) – f(u,v)
S t
v1
v2
v3
v4
residual network Gf = (V,Ef)
Ford Fulkerson – residual
networks
S t
v1
v2
v3
v4
12/12
11/14
Flow network G = (V,E)
cf(u,v) = c(u,v) – f(u,v)
S t
v1
v2
v3
v4
residual network Gf = (V,Ef)
11
12
3
The residual network Gf of a given flow network G with a valid flow f
consists of the same vertices v  V as in G which are linked with
residual edges (u,v)  Ef that can admit more strictly positive net flow.
The residual capacity cf represents the weight of each edge Ef and is
the amount of additional net flow f(u,v) before exceeding the capacity
c(u,v)
Ford Fulkerson – augmenting
paths
S t
v1
v2
v3
v4
12/12
11/14
cf(p) = min{cf (u,v): (u,v) is on p}
Flow network G = (V,E) residual network Gf = (V,Ef)
Definition: An augmenting path p is a simple (free of any cycle) path
from s to t in the residual network Gf
Residual capacity of p
S t
v1
v2
v3
v4
12
3
11
Ford Fulkerson – augmenting
paths
S t
v1
v2
v3
v4
12/12
11/14
cf(p) = min{cf (u,v): (u,v) is on
p}
Flow network G = (V,E)
S t
v1
v2
v3
v4
12
3
residual network Gf = (V,Ef)
11
Definition: An augmenting path p is a simple (free of any cycle) path
from s to t in the residual network Gf
Residual capacity of p
Augmenting path
Ford Fulkerson – augmenting
paths
S t
v1
v2
v3
v4
12/12
11/14
Flow network G = (V,E)
S t
v1
v2
v3
v4
12
3
residual network Gf = (V,Ef)
11
We define a flow: fp: V x V  R such as:
cf(p) if (u,v) is on p
fp(u,v) = - cf(p) if (v,u) is on p
0 otherwise
Ford Fulkerson – augmenting
paths
S t
v1
v2
v3
v4
12/12
11/14
Flow network G = (V,E)
S t
v1
v2
v3
v4
12
3
residual network Gf = (V,Ef)
11
Our virtual flow fp along the
augmenting path p in Gf
cf(p) if (u,v) is on p
fp(u,v) = - cf(p) if (v,u) is on p
0 otherwise
We define a flow: fp: V x V  R such as:
Ford Fulkerson – augmenting the
flow
S t
v1
v2
v3
v4
12/12
11/14
Flow network G = (V,E)
S t
v1
v2
v3
v4
12
3
residual network Gf = (V,Ef)
11
Our virtual flow fp along the
augmenting path p in Gf
New flow: f´: V x V  R : f´=f + fp
cf(p) if (u,v) is on p
fp(u,v) = - cf(p) if (v,u) is on p
0 otherwise
We define a flow: fp: V x V  R such as:
Ford Fulkerson – new valid
flow
proof of capacity constraint
Proof:
fp (u ,v) < cf (u ,v) = c (u ,v) – f (u ,v)
 (f + fp) (u ,v) = f (u ,v) + fp (u ,v) < c (u ,v)
Lemma:
f : V x V  R : f = f + fp in
G
Capacity constraint:
For all u,v  V, we require f(u,v) < c(u,v)
cf(p) if (u,v) is on p
fp(u,v) = - cf(p) if (v,u) is on p
0 otherwise
cf(p) = min{cf (u,v): (u,v) is on
p}
cf(u,v) = c(u,v) – f(u,v)
Ford Fulkerson – new valid
flow
proof of Skew symmetry
Proof:
(f + fp)(u ,v) = f (u ,v) + fp (u ,v) = - f (v ,u) – fp (v
,u)
= - (f (v ,u) + fp (v ,u)) = - (f + fp) (v ,u)
Skew symmetry:
For all u,v  V, we require f(u,v) = - f(v,u)
Lemma:
f : V x V  R : f = f + fp in
G
Ford Fulkerson – new valid
flow
proof of flow conservation
Proof:
u  V – {s ,t}   (f + fp) (u ,v) =  (f(u ,v) + fp (u ,v))
=  f (u ,v) +  fp (u ,v) = 0 + 0 = 0
Flow conservation:
For all u  V  {s,t} :  f(u,v) = 0
v  V
v  Vv  V
v  Vv  V
Lemma:
f : V x V  R : f = f + fp in
G
Ford Fulkerson – new valid
flow
Proof:
| (f + fp) | =  (f + fp) (s ,v) =  (f (s ,v) + fp (s ,v))
=  f (s ,v) +  fp (s ,v) = | f | + | fp |
Lemma:
| (f + fp) | = | f | + | fp |
v  Vv  V
v  Vv  V
Value of a Flow f:
Def:
|f| = 
f(s,v)
v  V
Ford Fulkerson – new valid
flow
Lemma:
| (f + fp) | = | f | + | fp | > | f |
f : V x V  R : f = f + fp in G
Lemma shows:
if an augmenting path can be found then the above
flow augmentation will result in a flow improvement.
Question: If we cannot find any more an augmenting
path is our flow then maximum?
Idea: The flow in G is maximum  the residual Gf
contains no augmenting path.
Ford Fulkerson – cuts of flow
networks
New notion: cut (S,T) of a flow network
A cut (S,T) of a flow network G=(V,E) is a partiton of V into S
and T = V  S such that s  S and t  T.
Implicit summation notation: f (S, T) =   f (u, v)
S t
v1
v2
v3
v4
12/1
2
11/1
4 TS
In the example:
S = {s,v1,v2) , T = {v3,v4,t}
Net flow f(S ,T) = f(v1,v3) + f(v2,v4) + f(v2,v3)
= 12 + 11 + (-0) = 23
Capacity c(S,T) = c(v1,v3) + c(v2,v4)
= 12 + 14 = 26
Practical example
u  S v  T
Ford Fulkerson – cuts of flow
networks
Lemma:
the value of a flow in a network is the net flow across any cut
of the network
f (S ,T) = | f
|
S t
v1
v2
v3
v4
12/1
2
11/1
4
proof
Ford Fulkerson – cuts of flow
networks
Assumption:
The value of any flow f in a flow network G is bounded from
above by the capacity of any cut of G
Lemma:
| f | < c (S, T)
| f | = f (S, T)
=   f (u, v)
<   c (u, v)
= c (S, T)
v Tu S
v Tu S S t
v1
v2
v3
v4
12/1
2
11/1
4
F. Fulkerson: Max-flow min-cut theorem
If f is a flow in a flow network G = (V,E) with source s and
sink t, then the following conditions are equivalent:
1. f is a maximum flow in G.
2. The residual network Gf contains no augmenting paths.
3. | f | = c (S, T) for some cut (S, T) of G.
proof:
(1)  (2):
We assume for the sake of contradiction that f is a maximum flow in G
but that there still exists an augmenting path p in Gf.
Then as we know from above, we can augment the flow in G according
to the formula: f = f + fp. That would create a flow f that is strictly
greater than the former flow f which is in contradiction to our
assumption that f is a maximum flow.
F. Fulkerson: Max-flow min-cut
theorem
If f is a flow in a flow network G = (V,E) with source s and
sink t, then the following conditions are equivalent:
1. f is a maximum flow in G.
2. The residual network Gf contains no augmenting paths.
3. | f | = c (S, T) for some cut (S, T) of G.
proof:
(2)  (3):
S t
v1
v2
v3
v4
6/8
3/3
4/6
8/8
5/6
6/6
3/3
1/3
S t
v1
v2
v3
v4
2
3
2
8
1
6
3
2
5
6 1
4
residual network Gforiginal flow network
G
F. Fulkerson: Max-flow min-cut
theorem
If f is a flow in a flow network G = (V,E) with source s and
sink t, then the following conditions are equivalent:
1. f is a maximum flow in G.
2. The residual network Gf contains no augmenting paths.
3. | f | = c (S, T) for some cut (S, T) of G.
proof:
(2)  (3): Define
S = {v V |  path p from s to v in Gf }
T = V  S (note t  S according to (2))
S t
v1
v2
v3
v4
2
3
2
8
1
6
3
2
5
6 1
4
residual network Gf
F. Fulkerson: Max-flow min-cut
theorem
If f is a flow in a flow network G = (V,E) with source s and
sink t, then the following conditions are equivalent:
1. f is a maximum flow in G.
2. The residual network Gf contains no augmenting paths.
3. | f | = c (S, T) for some cut (S, T) of G.
proof:
(2)  (3): Define
S = {v V |  path p from s to v in Gf }
T = V  S (note t  S according to (2))
 for  u  S, v  T: f (u, v) = c (u, v)
(otherwise (u, v)  Ef and v  S)
 | f | = f (S, T) = c (S, T)
1
S t
v1
v2
v3
v4
6/8
3/3
4/6
8/8
5/6
6/6
3/3
1/3
original network G
F. Fulkerson: Max-flow min-cut
theorem
If f is a fow in a flow network G = (V,E) with source s and
sink t, then the following conditions are equivalent:
1. f is a maximum flow in G.
2. The residual network Gf contains no augmenting paths.
3. | f | = c (S, T) for some cut (S, T) of G.
proof:
(3)  (1): as proofed before | f | = f (S, T) < c (S, T)
the statement of (3) : | f | = c (S, T) implies that f is a maximum flow
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t in the
residual network Gf
5 do cf (p) = min {cf (u, v) | (u, v) is in p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf (p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
(residual) network Gf
The basic Ford Fulkerson algorithm
example of an execution
S t
v1
v2
v3
v4
0/12
0/14
(residual) network Gf
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
(residual) network Gf
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
(residual) network Gf
temporary variable:
cf (p) = 12
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
(residual) network Gf
temporary variable:
cf (p) = 12
S t
v1
v2
v3
v4
12/1
2
14
new flow network
G
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
(residual) network
Gf
S t
v1
v2
v3
v4
12/1
2
14
new flow network G
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
(residual) network Gf
S t
v1
v2
v3
v4
12/1
2
14
new flow network
G
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
(residual) network Gf
S t
v1
v2
v3
v4
12/1
2
14
new flow network
G
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
(residual) network
Gf
S t
v1
v2
v3
v4
12/1
2
14
new flow network
G
temporary variable:
cf (p) = 4
S t
v1
v2
v3
v4
12
14
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
14
(residual) network
Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
temporary variable:
cf (p) = 4
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
10
(residual) network Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
4
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
10
(residual) network Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
4
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
10
(residual) network
Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
4
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
10
(residual) network
Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
4
temporary variable:
cf (p) = 7
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
S t
v1
v2
v3
v4
12
10
(residual) network
Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
4
temporary variable:
cf (p) = 7
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
The basic Ford Fulkerson
algorithm
example of an execution
(residual) network
Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
S t
v1
v2
v3
v4
12
3
11
1 for eachedge(u,v)  E[G]
2 do f[u,v]=0
3 f [v, u] = 0
4 while thereexistsapathpfromstot
intheresidualnetworkG f
5 do cf(p)=min{c f(u,v)|(u,v)  p}
6 for eachedge(u,v)inp
7 do f[u,v]=f[u,v]+c f(p)
8 f [v, u] = - f[u,v]
The basic Ford Fulkerson
algorithm
example of an execution
(residual) network Gf
S t
v1
v2
v3
v4
12/1
2
new flow network
G
S t
v1
v2
v3
v4
12
3
11
Finally we have:
| f | = f (s, V) = 23
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
Analysis of the Ford Fulkerson
algorithm
Running time
The running time depends on how the augmenting path p in line 4 is
determined.
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
Analysis of the Ford Fulkerson
algorithm
Running time (arbitrary choice of p)
O(|E|)
O(|E|
)
O(|E|
|fmax|)
running time: O ( |E| |fmax|
)
with fmax as maximum
flow
(1) The augmenting path is chosen arbitrarily and all capacities are
integers
1 for each edge (u, v)  E [G]
2 do f [u, v] = 0
3 f [v, u] = 0
4 while there exists a path p from s to t
in the residual network Gf
5 do cf(p) = min{cf(u, v) | (u, v)  p}
6 for each edge (u, v) in p
7 do f [u, v] = f [u, v] + cf(p)
8 f [v, u] = - f [u, v]
O(|E|
)
Analysis of the Ford Fulkerson
algorithm
Running time (arbitrary choice of p)
(1) The augmenting path is chosen arbitrarily and all capacities are
integers
Consequencies of an arbitrarily
choice:
Example if |f*| is large:
t
v2
v1
s
1
running time: O ( |E| |fmax|
)
with fmax as maximum
flow
Analysis of the Ford Fulkerson
algorithm
Running time (arbitrary choice of p)
(1) The augmenting path is chosen arbitrarily and all capacities are
integers
Consequencies of an arbitrarily
choice:
Example if |f*| is large:
t
v2
v1
s
1/1
t
v2
v1
s
1
residual network Gf
running time: O ( |E| |fmax|
)
with fmax as maximum
flow
Analysis of the Ford Fulkerson
algorithm
Running time (arbitrary choice of p)
(1) The augmenting path is chosen arbitrarily and all capacities are
integers
Consequencies of an arbitrarily
choice:
Example if |f*| is large:
t
v2
v1
s
1
t
v2
v1
s
1
residual network
Gf
running time: O ( |E| |fmax|
)
with fmax as maximum
flow
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
running time: O ( |V| |E|²
)
S t
u1
u2
v3
v4
4
4
Informal idea of the proof:
(1) for all vertices v  V{s,t}:
the shortest path distance
f(s,v) in Gf increases
monotonically with each flow
augmentation
f (s,v) < f (s,v)
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
S t
u1
u2
v3
v4
4
4
Informal idea of the proof:
(1) for all vertices v  V{s,t}:
the shortest path distance
f(s,v) in Gf increases
monotonically with each flow
augmentation
. f(s,v) < f (s,v)
f(s,u2) = 1
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
t
u1
u2
v3
v4
4
4
f(s,u2) = 3
Two flow augmentations later
S
Informal idea of the proof:
(1) for all vertices v  V{s,t}:
the shortest path distance
f(s,v) in Gf increases
monotonically with each flow
augmentation
. f(s,v) < f (s,v)
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
S t
u1
u2
v3
v4
4
4
The total number of flow
augmentations performed by
the algorithm is at most O(|V|
|E|)
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
S t
u1
u2
v3
v4
4
4
Critical edges on the path p
Def: critical edge (u,v)
if cf(p) = cf(u,v)
At least one edge on p must be
critical.
How many times can (u,v) be
critical during an execution of
Edmonds-Karp algorithm?
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
S t
u1
u2
v3
v4
4
4
our example: edge (u2,v4)
Idea:
(u,v) can become critical at most
O(V) times
(After beeing critical it
dissappears in Gf and can only
reappear after net flow is
decreased)
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
our example: edge (u2,v4) has
disappeared
Idea:
(u,v) can become critical at most
O(V) times
(After beeing critical it
dissappears in Gf and can only
reappear after net flow is
decreased)
t
u1
u2
v3
v4
4
4
Two flow augmentations later
S
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
our example: edge (u2,v4)
reappeared but is now unreachable
from s
Idea:
(u,v) can become critical at most
O(V) times
(After beeing critical it
disappears in Gf and can only
reappear after net flow is
decreased)
t
u1
u2
v3
v4
4
2
After the third flow augmentation
S
2
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Analysis of the Ford Fulkerson
algorithm
Running time with Edmonds-Karp algorithm
running time: O ( |V| |E|²
)
Idea:
(u,v) can become critical at most
O(|V|) times
O(|E|) pairs of vertices exist in
Gf
All critical edges in O(|V| |E|)
O(|E|) for breath first search for
p
total running time O(|V| |E|²)
(2) Edmonds-Karp algorithm
augmenting path is found by breath-first search and has to be a shortest path from
p to t
Different variants of the max-flow
problem
- The algorithm of Dinic (different implementations reaps
better running times than Edmonds-Karp): e.g. simultanous
saturation of augmenting paths of the same length O(|V|² |E|)
- A second capacity function lim for a lower limit of the flow
function f with lim(u,v) < f(u,v) < c(u,v)
- A cost function cost where each edge (u,v) has got a second
weight cost(u,v) and the min-cost max-flow problem
- Networks with multiple sources and sinks
Networks with multiple
sources and sinks
s1
s3
s2
t2
t1
s4
S´ T´supersource supersink
Ford Fulkerson – cuts of flow
networks
Assumption:
the value of a flow in a network is the net flow across any cut
of the network
Lemma:
f (S ,T) = | f
|
f (S, T) = f (S, VS)
= f (S, V) – f (S, S)
= f (S, V) = f (s  [Ss], V)
= f (s, V) + f (Ss, V)
= f (s, V) = | f |
Working with flows:
X,Y,Z  V and X  Y = 
f (X, Y) =   f (x, y)
f (X, X) = 0
f (X, Y) = - f (Y, X)
f (u, V) = 0 for all u  V  {s, t}
f (X  Y, Z) = f (X, Z) + f (Y, Z)
f (Z, X  Y) = f (Z, X) + f (Z, Y)
x  X y  Y
Proof:

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

EULER AND FERMAT THEOREM
EULER AND FERMAT THEOREMEULER AND FERMAT THEOREM
EULER AND FERMAT THEOREM
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programing
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Time space trade off
Time space trade offTime space trade off
Time space trade off
 
Dijkstra algorithm a dynammic programming approach
Dijkstra algorithm   a dynammic programming approachDijkstra algorithm   a dynammic programming approach
Dijkstra algorithm a dynammic programming approach
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123
 
5.5 graph mining
5.5 graph mining5.5 graph mining
5.5 graph mining
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 
Gradient descent method
Gradient descent methodGradient descent method
Gradient descent method
 

Destacado

A Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkA Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkShethwala Ridhvesh
 
Deep Networks with Neuromorphic VLSI devices
Deep Networks with Neuromorphic VLSI devicesDeep Networks with Neuromorphic VLSI devices
Deep Networks with Neuromorphic VLSI devicesGiacomo Indiveri
 
Embedding Watermarks into Deep Neural Networks
Embedding Watermarks into Deep Neural NetworksEmbedding Watermarks into Deep Neural Networks
Embedding Watermarks into Deep Neural NetworksYusuke Uchida
 
「人工知能で作る楽しい未来」
「人工知能で作る楽しい未来」「人工知能で作る楽しい未来」
「人工知能で作る楽しい未来」Romotive Japan
 
Low power vlsi design ppt
Low power vlsi design pptLow power vlsi design ppt
Low power vlsi design pptAnil Yadav
 
機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話Ryota Kamoshida
 

Destacado (7)

A Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkA Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing Network
 
Deep Networks with Neuromorphic VLSI devices
Deep Networks with Neuromorphic VLSI devicesDeep Networks with Neuromorphic VLSI devices
Deep Networks with Neuromorphic VLSI devices
 
Embedding Watermarks into Deep Neural Networks
Embedding Watermarks into Deep Neural NetworksEmbedding Watermarks into Deep Neural Networks
Embedding Watermarks into Deep Neural Networks
 
「人工知能で作る楽しい未来」
「人工知能で作る楽しい未来」「人工知能で作る楽しい未来」
「人工知能で作る楽しい未来」
 
t-SNE
t-SNEt-SNE
t-SNE
 
Low power vlsi design ppt
Low power vlsi design pptLow power vlsi design ppt
Low power vlsi design ppt
 
機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話
 

Similar a Network flow problems

22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdf22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdfabeedmaleek
 
aads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdfaads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdfNanaKoori
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network TalkImane Haf
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flowSaruarChowdhury
 
Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Traian Rebedea
 
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...AIRCC Publishing Corporation
 
bellman-ford Theorem.ppt
bellman-ford Theorem.pptbellman-ford Theorem.ppt
bellman-ford Theorem.pptSaimaShaheen14
 
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...AIRCC Publishing Corporation
 
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...ijcsit
 
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...AIRCC Publishing Corporation
 
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUBPresentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUBWorld University of Bangladesh
 
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...csandit
 
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...cscpconf
 
CS253: Network Flow (2019)
CS253: Network Flow (2019)CS253: Network Flow (2019)
CS253: Network Flow (2019)Jinho Choi
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithmA. S. M. Shafi
 

Similar a Network flow problems (20)

22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdf22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdf
 
aads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdfaads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdf
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
 
MaximumFlow.ppt
MaximumFlow.pptMaximumFlow.ppt
MaximumFlow.ppt
 
Maxflow
MaxflowMaxflow
Maxflow
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flow
 
Network flows
Network flowsNetwork flows
Network flows
 
Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12
 
maxflow.ppt
maxflow.pptmaxflow.ppt
maxflow.ppt
 
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
 
bellman-ford Theorem.ppt
bellman-ford Theorem.pptbellman-ford Theorem.ppt
bellman-ford Theorem.ppt
 
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
 
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
 
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
ON THE IMPLEMENTATION OF GOLDBERG'S MAXIMUM FLOW ALGORITHM IN EXTENDED MIXED ...
 
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUBPresentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
 
Max Flow Problem
Max Flow ProblemMax Flow Problem
Max Flow Problem
 
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
 
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
 
CS253: Network Flow (2019)
CS253: Network Flow (2019)CS253: Network Flow (2019)
CS253: Network Flow (2019)
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 

Más de Dr Sandeep Kumar Poonia

An improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithmAn improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithmDr Sandeep Kumar Poonia
 
Modified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithmModified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithmDr Sandeep Kumar Poonia
 
Enhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithmEnhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithmDr Sandeep Kumar Poonia
 
Memetic search in differential evolution algorithm
Memetic search in differential evolution algorithmMemetic search in differential evolution algorithm
Memetic search in differential evolution algorithmDr Sandeep Kumar Poonia
 
Improved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithmImproved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithmDr Sandeep Kumar Poonia
 
Comparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithmComparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithmDr Sandeep Kumar Poonia
 
A novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithmA novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithmDr Sandeep Kumar Poonia
 
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked listsMultiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked listsDr Sandeep Kumar Poonia
 
Sunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmSunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmDr Sandeep Kumar Poonia
 
New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm Dr Sandeep Kumar Poonia
 
Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...Dr Sandeep Kumar Poonia
 
Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...Dr Sandeep Kumar Poonia
 

Más de Dr Sandeep Kumar Poonia (20)

Soft computing
Soft computingSoft computing
Soft computing
 
An improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithmAn improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithm
 
Modified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithmModified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithm
 
Enhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithmEnhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithm
 
RMABC
RMABCRMABC
RMABC
 
Memetic search in differential evolution algorithm
Memetic search in differential evolution algorithmMemetic search in differential evolution algorithm
Memetic search in differential evolution algorithm
 
Improved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithmImproved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithm
 
Comparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithmComparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithm
 
A novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithmA novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithm
 
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked listsMultiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
 
Sunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmSunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithm
 
New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm
 
A new approach of program slicing
A new approach of program slicingA new approach of program slicing
A new approach of program slicing
 
Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...
 
Enhanced abc algo for tsp
Enhanced abc algo for tspEnhanced abc algo for tsp
Enhanced abc algo for tsp
 
Database aggregation using metadata
Database aggregation using metadataDatabase aggregation using metadata
Database aggregation using metadata
 
Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...
 
Lecture28 tsp
Lecture28 tspLecture28 tsp
Lecture28 tsp
 
Lecture27 linear programming
Lecture27 linear programmingLecture27 linear programming
Lecture27 linear programming
 
Lecture26
Lecture26Lecture26
Lecture26
 

Último

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 

Último (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 

Network flow problems

  • 2. Network flow problems - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting paths cuts of networks max-flow min-cut theorem example of an execution analysis, running time, variations of the max-flow problem
  • 3. Introduction – network Practical examples of a network - liquids flowing through pipes - parts through assembly lines - current through electrical network - information through communication network - goods transported on the road…
  • 4. Introduction - network Example: oil pipelineRepresentation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 S t v1 v2 v3 v4source sink
  • 5. Introduction – max-flow problemRepresentation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 S t v1 v2 v3 v4source sink Informal definition of the max-flow problem: What is the greatest rate at which material can be shipped from the source to the sink without violating any capacity contraints? Example: oil pipeline
  • 6. Introduction - capacity S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 u v 12 u v 6 c(u,v)=12 c(u,v)=6 Big pipe Small pipe 8 3 6 8 6 6 3 3 Example: oil pipeline
  • 7. Introduction - capacity S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 8 6 6 3 3 Example: oil pipeline v4 v2 v3 v4 If (u,v)  E  c(u,v) = 0 0 0 0 6
  • 8. Introduction – flow S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 u v 6/12 u v 6/6 f(u,v)=6 f(u,v)=6 Flow below capacity Maximum flow 8 3 6 8 6 6 3 3 Example: oil pipeline
  • 9. Introduction – flow S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 8 6 6 3 3 Example: oil pipeline
  • 10. Introduction – flow S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 6/8 6/6 6/6 3 3 Example: oil pipeline
  • 11. Introduction – flow S t v1 v2 v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 6/8 6/6 6/6 3 3 Example: oil pipeline
  • 12. Introduction – flow S t v1 v2 v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 3/8 3/3 3/6 6/8 6/6 6/6 3 3 Example: oil pipeline
  • 13. Introduction – flow S t v1 v2 v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 3/8 3/3 3/6 6/8 6/6 6/6 3 3 Example: oil pipeline
  • 14. Introduction – flow S t v1 v2 v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 5/8 3/3 3/6 8/8 6/6 6/6 2/3 3 Example: oil pipeline
  • 15. Introduction – cancellation S t v1 v2 v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 5/8 3/3 3/6 8/8 6/6 6/6 2/3 3 Example: oil pipeline
  • 16. Introduction – cancellation S t v1 v2 v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 u v 10 4 u v 8/10 4 u v 8/10 3/4 u v 5/10 4 Example: oil pipeline
  • 17. Maximum Flow Problem: definitions D M K S B P 8 14 146 12 10 10 7 17 6 D M K S B P 8 14 146 12 10 10 7 17 6 SOURCE: Node with net outflow: Production point SINK: Node with net inflow; Consumption point CAPACITY: Maximum flow on an edge Efficient method to solve such problems: Ford-Fulkerson Method
  • 18. Flow properties Flow in G = (V,E): f: V x V R with 3 properties: 1) Capacity constraint: For all u,v  V : f(u,v) < c(u,v) 2) Skew symmetry: For all u,v  V : f(u,v) = - f(v,u) 3) Flow conservation: For all u  V {s,t} :  f(u,v) = 0 v  V
  • 19. Flow properties Flow in G = (V,E): f: V x V R with 3 properties: 1) Capacity constraint: For all u,v  V : f(u,v) < c(u,v) 2) Skew symmetry: For all u,v  V : f(u,v) = - f(v,u) 3) Flow conservation: For all u  V {s,t} :  f(u,v) = 0 v  V S t v1 v2 v3 v4 12/12 11/14 Flow network G = (V,E) Note: by skew symmetry f (v3,v1) = - 12
  • 20. Net flow and value of a flow Net Flow: positive or negative value of f(u,v) Value of a Flow f: Def: |f| =  f(s,v)v  V S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 u v 8/10 3/4 u v 5/10 4 f(u,v) = 5 f(v,u) = -5
  • 21. The max-flow problem Informal definition of the max-flow problem: What is the greatest rate at which material can be shipped from the source to the sink without violating any capacity contraints? Formal definition of the max-flow problem: The max-flow problem is to find a valid flow for a given weighted directed graph G, that has the maximum value over all valid flows.
  • 22. The Ford-Fulkerson method a way how to find the max-flow This method contains 3 important ideas: 1) residual networks 2) augmenting paths 3) cuts of flow networks
  • 23. Ford-Fulkerson – pseudo code 1 initialize flow f to 0 2 while there exits an augmenting path p 3 do augment flow f along p 4 return f
  • 24. Ford Fulkerson – residual networks S t v1 v2 v3 v4 12/12 11/14 The residual network Gf of a given flow network G with a valid flow f consists of the same vertices v  V as in G which are linked with residual edges (u,v)  Ef that can admit more strictly positive net flow. The residual capacity cf represents the weight of each edge Ef and is the amount of additional net flow f(u,v) before exceeding the capacity c(u,v) Flow network G = (V,E) cf(u,v) = c(u,v) – f(u,v) S t v1 v2 v3 v4 residual network Gf = (V,Ef)
  • 25. Ford Fulkerson – residual networks S t v1 v2 v3 v4 12/12 11/14 Flow network G = (V,E) cf(u,v) = c(u,v) – f(u,v) S t v1 v2 v3 v4 residual network Gf = (V,Ef) 11 12 3 The residual network Gf of a given flow network G with a valid flow f consists of the same vertices v  V as in G which are linked with residual edges (u,v)  Ef that can admit more strictly positive net flow. The residual capacity cf represents the weight of each edge Ef and is the amount of additional net flow f(u,v) before exceeding the capacity c(u,v)
  • 26. Ford Fulkerson – augmenting paths S t v1 v2 v3 v4 12/12 11/14 cf(p) = min{cf (u,v): (u,v) is on p} Flow network G = (V,E) residual network Gf = (V,Ef) Definition: An augmenting path p is a simple (free of any cycle) path from s to t in the residual network Gf Residual capacity of p S t v1 v2 v3 v4 12 3 11
  • 27. Ford Fulkerson – augmenting paths S t v1 v2 v3 v4 12/12 11/14 cf(p) = min{cf (u,v): (u,v) is on p} Flow network G = (V,E) S t v1 v2 v3 v4 12 3 residual network Gf = (V,Ef) 11 Definition: An augmenting path p is a simple (free of any cycle) path from s to t in the residual network Gf Residual capacity of p Augmenting path
  • 28. Ford Fulkerson – augmenting paths S t v1 v2 v3 v4 12/12 11/14 Flow network G = (V,E) S t v1 v2 v3 v4 12 3 residual network Gf = (V,Ef) 11 We define a flow: fp: V x V  R such as: cf(p) if (u,v) is on p fp(u,v) = - cf(p) if (v,u) is on p 0 otherwise
  • 29. Ford Fulkerson – augmenting paths S t v1 v2 v3 v4 12/12 11/14 Flow network G = (V,E) S t v1 v2 v3 v4 12 3 residual network Gf = (V,Ef) 11 Our virtual flow fp along the augmenting path p in Gf cf(p) if (u,v) is on p fp(u,v) = - cf(p) if (v,u) is on p 0 otherwise We define a flow: fp: V x V  R such as:
  • 30. Ford Fulkerson – augmenting the flow S t v1 v2 v3 v4 12/12 11/14 Flow network G = (V,E) S t v1 v2 v3 v4 12 3 residual network Gf = (V,Ef) 11 Our virtual flow fp along the augmenting path p in Gf New flow: f´: V x V  R : f´=f + fp cf(p) if (u,v) is on p fp(u,v) = - cf(p) if (v,u) is on p 0 otherwise We define a flow: fp: V x V  R such as:
  • 31. Ford Fulkerson – new valid flow proof of capacity constraint Proof: fp (u ,v) < cf (u ,v) = c (u ,v) – f (u ,v)  (f + fp) (u ,v) = f (u ,v) + fp (u ,v) < c (u ,v) Lemma: f : V x V  R : f = f + fp in G Capacity constraint: For all u,v  V, we require f(u,v) < c(u,v) cf(p) if (u,v) is on p fp(u,v) = - cf(p) if (v,u) is on p 0 otherwise cf(p) = min{cf (u,v): (u,v) is on p} cf(u,v) = c(u,v) – f(u,v)
  • 32. Ford Fulkerson – new valid flow proof of Skew symmetry Proof: (f + fp)(u ,v) = f (u ,v) + fp (u ,v) = - f (v ,u) – fp (v ,u) = - (f (v ,u) + fp (v ,u)) = - (f + fp) (v ,u) Skew symmetry: For all u,v  V, we require f(u,v) = - f(v,u) Lemma: f : V x V  R : f = f + fp in G
  • 33. Ford Fulkerson – new valid flow proof of flow conservation Proof: u  V – {s ,t}   (f + fp) (u ,v) =  (f(u ,v) + fp (u ,v)) =  f (u ,v) +  fp (u ,v) = 0 + 0 = 0 Flow conservation: For all u  V {s,t} :  f(u,v) = 0 v  V v  Vv  V v  Vv  V Lemma: f : V x V  R : f = f + fp in G
  • 34. Ford Fulkerson – new valid flow Proof: | (f + fp) | =  (f + fp) (s ,v) =  (f (s ,v) + fp (s ,v)) =  f (s ,v) +  fp (s ,v) = | f | + | fp | Lemma: | (f + fp) | = | f | + | fp | v  Vv  V v  Vv  V Value of a Flow f: Def: |f| =  f(s,v) v  V
  • 35. Ford Fulkerson – new valid flow Lemma: | (f + fp) | = | f | + | fp | > | f | f : V x V  R : f = f + fp in G Lemma shows: if an augmenting path can be found then the above flow augmentation will result in a flow improvement. Question: If we cannot find any more an augmenting path is our flow then maximum? Idea: The flow in G is maximum  the residual Gf contains no augmenting path.
  • 36. Ford Fulkerson – cuts of flow networks New notion: cut (S,T) of a flow network A cut (S,T) of a flow network G=(V,E) is a partiton of V into S and T = V S such that s  S and t  T. Implicit summation notation: f (S, T) =   f (u, v) S t v1 v2 v3 v4 12/1 2 11/1 4 TS In the example: S = {s,v1,v2) , T = {v3,v4,t} Net flow f(S ,T) = f(v1,v3) + f(v2,v4) + f(v2,v3) = 12 + 11 + (-0) = 23 Capacity c(S,T) = c(v1,v3) + c(v2,v4) = 12 + 14 = 26 Practical example u  S v  T
  • 37. Ford Fulkerson – cuts of flow networks Lemma: the value of a flow in a network is the net flow across any cut of the network f (S ,T) = | f | S t v1 v2 v3 v4 12/1 2 11/1 4 proof
  • 38. Ford Fulkerson – cuts of flow networks Assumption: The value of any flow f in a flow network G is bounded from above by the capacity of any cut of G Lemma: | f | < c (S, T) | f | = f (S, T) =   f (u, v) <   c (u, v) = c (S, T) v Tu S v Tu S S t v1 v2 v3 v4 12/1 2 11/1 4
  • 39. F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1. f is a maximum flow in G. 2. The residual network Gf contains no augmenting paths. 3. | f | = c (S, T) for some cut (S, T) of G. proof: (1)  (2): We assume for the sake of contradiction that f is a maximum flow in G but that there still exists an augmenting path p in Gf. Then as we know from above, we can augment the flow in G according to the formula: f = f + fp. That would create a flow f that is strictly greater than the former flow f which is in contradiction to our assumption that f is a maximum flow.
  • 40. F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1. f is a maximum flow in G. 2. The residual network Gf contains no augmenting paths. 3. | f | = c (S, T) for some cut (S, T) of G. proof: (2)  (3): S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 S t v1 v2 v3 v4 2 3 2 8 1 6 3 2 5 6 1 4 residual network Gforiginal flow network G
  • 41. F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1. f is a maximum flow in G. 2. The residual network Gf contains no augmenting paths. 3. | f | = c (S, T) for some cut (S, T) of G. proof: (2)  (3): Define S = {v V |  path p from s to v in Gf } T = V S (note t  S according to (2)) S t v1 v2 v3 v4 2 3 2 8 1 6 3 2 5 6 1 4 residual network Gf
  • 42. F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1. f is a maximum flow in G. 2. The residual network Gf contains no augmenting paths. 3. | f | = c (S, T) for some cut (S, T) of G. proof: (2)  (3): Define S = {v V |  path p from s to v in Gf } T = V S (note t  S according to (2))  for  u  S, v  T: f (u, v) = c (u, v) (otherwise (u, v)  Ef and v  S)  | f | = f (S, T) = c (S, T) 1 S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 original network G
  • 43. F. Fulkerson: Max-flow min-cut theorem If f is a fow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1. f is a maximum flow in G. 2. The residual network Gf contains no augmenting paths. 3. | f | = c (S, T) for some cut (S, T) of G. proof: (3)  (1): as proofed before | f | = f (S, T) < c (S, T) the statement of (3) : | f | = c (S, T) implies that f is a maximum flow
  • 44. 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf (p) = min {cf (u, v) | (u, v) is in p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf (p) 8 f [v, u] = - f [u, v] The basic Ford Fulkerson algorithm
  • 45. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v] (residual) network Gf
  • 46. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 0/12 0/14 (residual) network Gf 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 47. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 (residual) network Gf 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 48. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 (residual) network Gf temporary variable: cf (p) = 12 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 49. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 (residual) network Gf temporary variable: cf (p) = 12 S t v1 v2 v3 v4 12/1 2 14 new flow network G 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 50. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 (residual) network Gf S t v1 v2 v3 v4 12/1 2 14 new flow network G 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 51. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 (residual) network Gf S t v1 v2 v3 v4 12/1 2 14 new flow network G 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 52. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 (residual) network Gf S t v1 v2 v3 v4 12/1 2 14 new flow network G 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 53. The basic Ford Fulkerson algorithm example of an execution (residual) network Gf S t v1 v2 v3 v4 12/1 2 14 new flow network G temporary variable: cf (p) = 4 S t v1 v2 v3 v4 12 14 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 54. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 14 (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G temporary variable: cf (p) = 4 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 55. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 10 (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G 4 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 56. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 10 (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G 4 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 57. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 10 (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G 4 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 58. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 10 (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G 4 temporary variable: cf (p) = 7 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 59. The basic Ford Fulkerson algorithm example of an execution S t v1 v2 v3 v4 12 10 (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G 4 temporary variable: cf (p) = 7 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 60. The basic Ford Fulkerson algorithm example of an execution (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G S t v1 v2 v3 v4 12 3 11 1 for eachedge(u,v)  E[G] 2 do f[u,v]=0 3 f [v, u] = 0 4 while thereexistsapathpfromstot intheresidualnetworkG f 5 do cf(p)=min{c f(u,v)|(u,v)  p} 6 for eachedge(u,v)inp 7 do f[u,v]=f[u,v]+c f(p) 8 f [v, u] = - f[u,v]
  • 61. The basic Ford Fulkerson algorithm example of an execution (residual) network Gf S t v1 v2 v3 v4 12/1 2 new flow network G S t v1 v2 v3 v4 12 3 11 Finally we have: | f | = f (s, V) = 23 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 62. Analysis of the Ford Fulkerson algorithm Running time The running time depends on how the augmenting path p in line 4 is determined. 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]
  • 63. Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) O(|E|) O(|E| ) O(|E| |fmax|) running time: O ( |E| |fmax| ) with fmax as maximum flow (1) The augmenting path is chosen arbitrarily and all capacities are integers 1 for each edge (u, v)  E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v)  p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v] O(|E| )
  • 64. Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1 running time: O ( |E| |fmax| ) with fmax as maximum flow
  • 65. Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1/1 t v2 v1 s 1 residual network Gf running time: O ( |E| |fmax| ) with fmax as maximum flow
  • 66. Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1 t v2 v1 s 1 residual network Gf running time: O ( |E| |fmax| ) with fmax as maximum flow
  • 67. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t running time: O ( |V| |E|² ) S t u1 u2 v3 v4 4 4 Informal idea of the proof: (1) for all vertices v  V{s,t}: the shortest path distance f(s,v) in Gf increases monotonically with each flow augmentation f (s,v) < f (s,v)
  • 68. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) S t u1 u2 v3 v4 4 4 Informal idea of the proof: (1) for all vertices v  V{s,t}: the shortest path distance f(s,v) in Gf increases monotonically with each flow augmentation . f(s,v) < f (s,v) f(s,u2) = 1 (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 69. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) t u1 u2 v3 v4 4 4 f(s,u2) = 3 Two flow augmentations later S Informal idea of the proof: (1) for all vertices v  V{s,t}: the shortest path distance f(s,v) in Gf increases monotonically with each flow augmentation . f(s,v) < f (s,v) (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 70. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) S t u1 u2 v3 v4 4 4 The total number of flow augmentations performed by the algorithm is at most O(|V| |E|) (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 71. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) S t u1 u2 v3 v4 4 4 Critical edges on the path p Def: critical edge (u,v) if cf(p) = cf(u,v) At least one edge on p must be critical. How many times can (u,v) be critical during an execution of Edmonds-Karp algorithm? (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 72. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) S t u1 u2 v3 v4 4 4 our example: edge (u2,v4) Idea: (u,v) can become critical at most O(V) times (After beeing critical it dissappears in Gf and can only reappear after net flow is decreased) (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 73. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) our example: edge (u2,v4) has disappeared Idea: (u,v) can become critical at most O(V) times (After beeing critical it dissappears in Gf and can only reappear after net flow is decreased) t u1 u2 v3 v4 4 4 Two flow augmentations later S (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 74. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) our example: edge (u2,v4) reappeared but is now unreachable from s Idea: (u,v) can become critical at most O(V) times (After beeing critical it disappears in Gf and can only reappear after net flow is decreased) t u1 u2 v3 v4 4 2 After the third flow augmentation S 2 (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 75. Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) Idea: (u,v) can become critical at most O(|V|) times O(|E|) pairs of vertices exist in Gf All critical edges in O(|V| |E|) O(|E|) for breath first search for p total running time O(|V| |E|²) (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t
  • 76. Different variants of the max-flow problem - The algorithm of Dinic (different implementations reaps better running times than Edmonds-Karp): e.g. simultanous saturation of augmenting paths of the same length O(|V|² |E|) - A second capacity function lim for a lower limit of the flow function f with lim(u,v) < f(u,v) < c(u,v) - A cost function cost where each edge (u,v) has got a second weight cost(u,v) and the min-cost max-flow problem - Networks with multiple sources and sinks
  • 77. Networks with multiple sources and sinks s1 s3 s2 t2 t1 s4 S´ T´supersource supersink
  • 78. Ford Fulkerson – cuts of flow networks Assumption: the value of a flow in a network is the net flow across any cut of the network Lemma: f (S ,T) = | f | f (S, T) = f (S, VS) = f (S, V) – f (S, S) = f (S, V) = f (s  [Ss], V) = f (s, V) + f (Ss, V) = f (s, V) = | f | Working with flows: X,Y,Z  V and X  Y =  f (X, Y) =   f (x, y) f (X, X) = 0 f (X, Y) = - f (Y, X) f (u, V) = 0 for all u  V {s, t} f (X  Y, Z) = f (X, Z) + f (Y, Z) f (Z, X  Y) = f (Z, X) + f (Z, Y) x  X y  Y Proof: