19 Flow II Notes
19 Flow II Notes
19 Flow II Notes
1 Previos Lecture
Theorem 1.1 (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
1
2 Accountability
2
3 Ford-Fulkerson Algorithm
Ford-Fulkerson(G,s,t)
Init flow f to zero
Lemma 3.1 If the capacities on the edges of G are integers, then Ford-Fulkerson runs in
O(m |f ∗ |) time, where |f ∗ | is the amount of flow in the maximum flow and m = |E(G)|.
Proof: Observe that the Ford-Fulkerson algorithm perform only substraction/addition and
min operations. Thus, if it finds an augmenting path, then cf (p) must be a positive integer
number. Namely, cf (p) ≥ 1. Thus, |f ∗ | must be an integer number (by induction), and each
interation of the while improves the flow by at least 1. It follows, that after |f ∗ | iterations of
the while the algorithm stops. However, each iteration of the while loop takes O(m) time,
as can be easily verified.
Observation 3.2 (Integrality theorem) If the capacity function c takes on only integral
values, then the maximum flow f produced by the Ford-Fulkerson method has the property
that |f | is integer-valued. Morover, for all vertices u and v, the value of f (u, v) is an itneger.
4 Edmonds-Karp algorithm
Edmonds-Karp algorithm works by modifying the Ford-Fulkerson algorithm so that it always
return the (edge) shortest augmenting path in Gf . This is implemented by finding p using
BFS.
Definition 4.1 For a flow f , let δf (v) be the length of the shortest path from the source s
to v in the residual graph Gf . Each edge is considered to be of length 1.
Lemma 4.2 If the Edmonds-Karp algorithm is run on a flow network G = (V, E) with
source s and sink t, then for all vertices v ∈ V − s, t, the shortest path distance δf (v) in the
residual network Gf increases monotonically with each flow augmentation.
We delay proving this technical lemma. Lets first prove that it is helping in our life.
Lemma 4.3 During the execution of EK algorithm, an edge uv might disappear (and thus
reappear) from Gfi at most n/2 times, where n = |V (G)|.
3
Proof: When − → disppaers that it must be that uv was on the augmenting path p. Further-
uv
more, cf (p) = cf (uv). We continue running EK till uv magically reappear. This means that
before uv reappeared, we handled an augmenting path π that contains the edge − → Let g
vu.
be the flow just after this. We have
Observation 4.4 Every time we add an augmenting path during the executation of EK
algorithm, at least one edge disappears from the residual graph G? . The “bottleneck” edge (the
edge that realizes the flow along the augmenting path) along the augmenting path disappears
after we apply the augmenting path.
Lemma 4.5 Edmonds-Karp algorithm handles at most O(nm) augmenting paths before it
stops. In particular, each augmenting path takes O(m) time, and the overall running time
of Edmonds-Karp algorithm is O(nm2 ) time, where n = |V (G)|and m = |E(G)|.
Proof: Every edge might disappear at most n/2 times during EK executation. Thus, there
are at most nm/2 edge disappearences during the executation of the EK algorithm. Each
time we augment a path, an edge disappears. Augmenting a path takes O(m) time, as we
have to perform BFS to find the augmenting path. It follows, that the overall running time
is as claimed.
We are done??
Lemma 4.6 If the Edmonds-Karp algorithm is run on a flow network G = (V, E) with
source s and sink t, then for all vertices v ∈ V − s, t, the shortest path distance δf (s, v) in
the residual network Gf increases monotonically with each flow augmentation.
Proof: Assume for the sake of contradiction that this is false, and let us stop immidately
after it fails. Let g be the flow after, and f the flow before.
Let v be the vertex s.t. δg (v) is minimal and δg (v) < δf (v).
Let p = s → · · · → u → v be the shortest path in Gg from s to v.
Clearly, uv ∈ E(Gg ).
Thus, δg (u) = δg (v) − 1.
By the choice of v, it must be that δg (u) ≥ δf (u). WHY?
If −
→ ∈ E(G ) then
uv f
4
Thus,
δf (u) = δf (v) + 1 > δg (v) = δg (u) + 1.
Thus, δf (u) > δg (u). A contradiction. WHY?
A bipartitle graph:
Theorem 5.2 One can compute maximum bipartite matching using network flows.
Proof: We create a new graph, with new source on the length and sink on the right.
Direct all edges from left to right, and set their capacity to 1. See:
1
s t
5
6 Multiple Sources and Sinks
Given several sources and sinks, how can we comptue maximum flow on such a network?
1
s1 t1
s2
t2
1
‘
Idea: Create a super source, that send all tis flow to the old sources, and similarly create
a super sink.
Resulting graph:
1
t1
∞
s ∞
∞
∞
1
t2
1