SlideShare ist ein Scribd-Unternehmen logo
1 von 78
Downloaden Sie, um offline zu lesen
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:

Weitere ähnliche Inhalte

Was ist angesagt?

Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithm
faisal2204
 

Was ist angesagt? (20)

Max Flow Problem
Max Flow ProblemMax Flow Problem
Max Flow Problem
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
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
 
The Floyd–Warshall algorithm
The Floyd–Warshall algorithmThe Floyd–Warshall algorithm
The Floyd–Warshall algorithm
 
Trees and graphs
Trees and graphsTrees and graphs
Trees and graphs
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Ford fulkerson
Ford fulkersonFord fulkerson
Ford fulkerson
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Kruskal & Prim's Algorithm
Kruskal & Prim's AlgorithmKruskal & Prim's Algorithm
Kruskal & Prim's Algorithm
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithm
 
Network flows
Network flowsNetwork flows
Network flows
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
 

Andere mochten auch

Andere mochten auch (6)

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
 
機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話
 

Ähnlich wie Network flow problems

Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
Imane Haf
 
Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12
Traian Rebedea
 

Ähnlich wie 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
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flow
 
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
 
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
 
Lecture02_Part02.pptx
Lecture02_Part02.pptxLecture02_Part02.pptx
Lecture02_Part02.pptx
 
flows.ppt
flows.pptflows.ppt
flows.ppt
 
16_05.ppt
16_05.ppt16_05.ppt
16_05.ppt
 

Mehr von Dr 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 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
 

Mehr von 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
 

Kürzlich hochgeladen

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
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
negromaestrong
 

Kürzlich hochgeladen (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

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: