MAXIMUM FLOW
Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
What is Flow Network?
Flow network is a directed graph G = (V,E) such that
each edge has a non-negative capacity c(u,v) ≥ 0.
Two distinguished vertices exist in G namely:
Source (produces flow and denoted by s): In-degree
of this vertex is 0.
Sink (consumes flow and denoted by t): Out-degree
of this vertex is 0.
Flow in a network is an integer-valued function f
defined on the edges of G satisfying 0 ≤ f (u,v) ≤
c(u,v), for every edge (u,v) in E.
Contd…
Each edge (u,v) E has a non-negative capacity
c(u,v).
If (u,v) E assume c(u,v)=0.
Two special vertices, source s and sink t.
Every vertex v V is on some path from s to t.
Capacity
c(s,v1) = 16
c(v1,s) = 0
c(v2,s) = 0
c(v4,t) = 4 …
Conditions for Flow Network
For each edge (u,v) in E, the flow f (u,v) in G is a real valued
function f : V × V → R that satisfies the following properties:
Capacity constraints – The flow along an edge can not exceed
its capacity.
Skew symmetry – The net flow from u to v must be the
opposite of the net flow from v to u.
Flow conservation – Unless u is s or t, the net flow to a node is
zero.
The Value of a Flow
The value of a flow is given by:
| f | f ( s, v) f (v, t )
vV vV
The flow into the sink node (t) is same as flow
going out from the source node (s) and thus the
flow is conserved.
Total amount of flow from source s is equal to
total amount of flow into the sink t.
Example
A flow f in G with value | f | = 19.
Each edge (u, v) is labeled by
f (u,v)/c(u,v). Slash notation Edge Capacity Flow Comment
separates the flow and capacity; it (s,v1) 16 11 11 ≤ 16 Valid
does not indicate division. (s,v2) 13 8 8 ≤ 13 Valid
| f | f ( s, v) f (v, t ) 19
vV vV (v2,v1) 4 1 1 ≤ 4 Valid
The flow across nodes v1, v2 , v3,
(v1,v3) 12 12 12 ≤ 12 Valid
and v4 are also conserved as flow
(v3,v2) 9 4 4 ≤ 9 Valid
into them = flow out of them.
(v2,v4) 14 11 11 ≤ 14 Valid
v1: 11 + 1 = 12
v2 : 8 + 4 = 1 + 11 (v4,v3) 7 7 7 ≤ 7 Valid
v3: 12 + 7 = 4 + 15, and (v3,t) 20 15 15 ≤ 20 Valid
v4: 11 = 7 + 4. (v4,t) 4 4 4 ≤ 4 Valid
The Maximum Flow Problem
Given: In simple terms maximize
Graph G(V,E), the s to t flow, while ensuring
that the flow is feasible.
f (u,v) = flow on edge (u,v),
c(u,v) = capacity of edge (u,v),
s = source node, t = sink node.
Maximize: | f |
Subject to: f (u, v) f (v, u) 0, u s, t
vV vV
f (s, v) f (v, t )
vV vV
f
0 f (u, v) c(u, v), (u, v) E
Cuts of Flow Networks
A Cut in a network is a partition of V into S and T
(T = V – S) such that s (source) is in S and t (target)
is in T. 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
4 30 7
Capacity = 30
Min Cut
Min s-t cut (also called as a Min Cut) is a
cut of minimum capacity
2 9 5
Min s-t Cut
10 15 15 10
4
s 5 3 8 6 10 t
4 6 15 10
15
4 30 7 Capacity = 28
Flow of Min Cut
Let f be the flow and let (S,T) be a cut. Then | f | ≤
capacity(S,T). Capacity = c(v1,v3) + c(v2,v4)
= 12 + 14 = 26.
Flow = f(v1,v3) + f(v2,v4) - f(v3,v2)
= 12 + 11 – 4 = 19.
Ford-Fulkerson Method
FORD-FULKERSON-METHOD(G,s,t)
1. initialize flow f to 0
2. while there exists an augmenting path p in the
residual network Gf
3. augment flow f along p
4. return f
Residual Network
Given a flow network G = (V,E) and a flow f, the
residual network of G induced by f is Gf = (V,Ef),
where
Ef = {(u,v) V × V : cf (u,v) > 0} with residual
capacity cf
Contd…
Augmenting Path
An augmenting path p is a simple path from s to t
on a residual network Gf.
The maximum capacity by which we can increase
the flow on each edge in an augmenting path p is
known as the residual capacity of p, given by
c f ( p) min{c f (u, v) : (u, v) is on p}
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.
Note:
If | f | = c(S,T), then c(S,T) is the required min-cut.
Basic Ford-Fulkerson Algorithm
Line 7. Add residual capacity to the flow over an existing
edge (u,v) in E.
Line 8. Subtract residual capacity from the flow over an
existing edge (v,u) in E.
Example
Flow = 4
Initial flow = 0. Thus original network and initial
residual network is same.
Path: s → v1 → v3 → v2 → v4 → t.
Residual capacity: min(16, 12, 9, 14, 4) = 4.
All edges in path exists in E, so add 4 to the initial
flow for all the edges in the path (0 + 4 = 4).
Contd…
Update residual network using,
Contd…
Path: s → v2 → v1 → v3 → t.
Residual capacity: min(13, 4, 8, 20) = 4.
All edges in path exists in E, so add 4 to the flow for
all the edges in the path.
Flow = 4 + 4
Contd…
Update residual network.
Path: s → v1 → v2 → v3 → t.
Flow = 4 + 4 + 4
Residual capacity: min(12, 4, 4, 16) = 4.
Edges (v1,v2) and (v2,v3) in path doesn't exist in E, so
subtract residual capacity (4) from the previous flow for the
edges (v2,v1) and (v3,v2). For both the edges updated flow is
4 – 4 = 0.
Contd…
Update residual network.
Path: s → v2 → v4 → v3 → t.
Residual capacity: min(9, 10, 7, 12) = 7.
All edges in path exists in E, so add 7 to the flow for all
the edges in the path.
Flow = 4 + 4 + 4 + 7
Contd…
Update residual network.
Path: s → v1 → v3 → t.
Residual capacity: min(8, 4, 5) = 4.
All edges in path exists in E, so add 4 to the flow for all
the edges in the path.
Flow = 4 + 4 + 4 + 7 + 4
Contd…
Update residual network.
No path exists in the residual network from s to t.
Loop terminates and the final flow is
Flow = 4 + 4 + 4 + 7 + 4 = 23
| f | = 23.
c({s, v1,v2,v4},{v3,t}) = 23.
4
Example 2 2
1
5
3 1 1
2 4 2
4 s t
2 5 3 2
1 1
3 1 1
2 3
2 4
s t
3 2 4
1 2 5
1
3 3 1 1
2/2 4 2/2
s t
3 2
Flow = 2 1
3
4
Contd… 2
1
5
3 1 1
2/2 4 2/2
4 s t
2 5 3 1 2
1
3 1 1
2 2
3
4
s t
3 2 4
1 2 5
1
3 3 1 1
2/2 4 2/2
s t
2/3 1 2/2
Flow = 2 + 2
3
4
Contd… 2
1
5
3 1 1
2/2 4 2/2
4 s t
2 5 2/3 1 2/2
1
3 1 1
2
3
4
s t
1 1/4
1 2 2 5
2 1
1/3 1 1/1
3
2/2 4 2/2
s t
2/3 1 2/2
Flow = 2 + 2 + 1
3
1/4
Contd… 2
1
5
1/3 1 1/1
3 2/2 4 2/2
s t
2 1 5 2/3 1 2/2
2 1 1
1 1
2 3
4
s t
1 2
1
2 | f | = 5.
3
c({s,2,3,4,5},{t}) = 5.
Flow = 2 + 2 + 1 = 5
Analysis
If f * is the maximum flow, then algorithm executes
while loop of lines 3–8 at most | f *| times, assuming
flow increases by at least one unit in each iteration.
The time to find a path in a residual network is O(E).
The time to update capacity and flow values is O(1).
Each iteration of while loop thus takes O(E) time, as
does the initialization in lines 1–2.
Thus, the total running time of the FORD-
FULKERSON algorithm is O(E | f *|).
Edmonds-Karp algorithm
It’s similar to a Ford-Fulkerson method.
It chooses the augmenting path as a shortest
path from s to t in the residual network.
Edmonds-Karp algorithm runs in O(VE2) time.
Applications
Application area of max flow min cut is very
vast.
Interested students may refer the document
available at
http://www.cs.princeton.edu/~wayne/cs423/lec
tures/max-flow-applications