Professional Documents
Culture Documents
Ford Fulkerson Algorithm
Ford Fulkerson Algorithm
c(s,v1)=16
c(v1,s)=0
c(v2,s)=0 …
Conditions for Network Flow
For each edge (u,v) in E, the flow f(u,v) is a real valued function
that must satisfy following 3 conditions :
| f | f ( s, v ) f (v, t )
vV vV
The flow into the node is same as flow going out from the node and
thus the flow is conserved. Also the total amount of flow from source
s = total amount of flow into the sink t.
Example of a flow Capacity
Flow
1 8,8
10, 9
1,1
s t
6, 6 10,7
2
Table illustrating Flows and Capacity across different edges of graph above:
fs,1 = 9 , cs,1 = 10 (Valid flow since 10 > 9)
fs,2 = 6 , cs,2 = 6 (Valid flow since 6 ≥ 6)
f1,2 = 1 , c1,2 = 1 (Valid flow since 1 ≥ 1)
f1,t = 8 , c1,t = 8 (Valid flow since 8 ≥ 8)
f2,t = 7 , c2,t = 10 (Valid flow since 10 > 7)
The flow across nodes 1 and 2 are also conserved as flow into them = flow out.
The Maximum Flow Problem
Maximize v
Σjxsj = v
2 9 5
Cut
10 15 15 10
4
s 5 3 8 6 10 t
4 6 15 10
15
4 30 7
Capacity of Cut (S,T)
c( S , T ) c(u , v)
uS , vT
2 9 5
Cut
10 15 15 10
4
s 5 3 8 6 10 t
4 6 15 10
15
Capacity = 30
4 30 7
Min Cut
Min s-t cut (Also called as a Min Cut) is a cut of minimum capacity
2 9 5
s 5 3 8 6 10 t
4 6 15 10
15
Capacity = 28
4 30 7
Flow of Min Cut (Weak Duality)
Proof :
0 S T
8
t
s
7
Methods
c f (u , v ) c (u , v ) f (u , v )
1 8,8 1 0
10, 9 1
1,1 9 1 0 8
s t s t
6 7
6, 6 10,7 0
2 2 3
Original Network Residual Network
The Ford-Fulkerson Method
Begin
x := 0; // x is the flow.
create the residual network G(x);
while there is some directed path from s to t in G(x) do
begin
let P be a path from s to t in G(x);
Δ:= δ(P);
send Δunits of flow along P;
update the r's;
end
end {the flow x is now maximum}.
c f ( p ) min{c f (u , v ) : (u , v ) is on p}
The Ford-Fulkerson’s Algorithm
FORDFULKERSON(G,E,s,t) AUGMENT(f,P)
FOREACH e E b bottleneck(P)
f(e) 0 FOREACH e P
Gf residual graph IF (e E)
Proof:
2 2
s 4 t
3 2
1
3
This is the original network,
and the original residual
network.
Ford-Fulkerson Max Flow
4
2 5
3 1 1 1
2 2
s 4 t
3 2
1
3
Find any s-t path in G(x)
Ford-Fulkerson Max Flow
4
2 5
3 1 1 1
2 1
2
s 4 1
t
2
3 2
1
1
3
Determine the capacity of the path.
2 1
2
s 4 1
t
2
3 2
1
1
3
Find any s-t path
Ford-Fulkerson Max Flow
4
2 5
3 1 1 1
2
1 11
s 1
4 1
t
2
3 2
1
1
1
3 1
2
1 11
s 1
4 1
t
2
3 2
1
1
1
3 1
1 11
s 1
2
4 1
2
t
2
3 1
1
1
3 1
1
2 11
s 1
2
4 1
2
t
2
3 1
1
1
3 1
1
2 11
s 1
2
4 1
2
t
1
2 1
1
2
1
3 2
1
1
2 11
s 1
2
4 1
2
t
1
2
1
2
1
3 2
1
2 2
s 4 t
2 2
3
Here is the optimal flow