Advanced Algorithms Lecture 03,1
Advanced Algorithms Lecture 03,1
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
18.415/6.854 Advanced Algorithms September 10, 2008
Lecture 3
Lecturer: Michel X. Goemans
1 Introduction
Today we continue our discussion of maximum flows by introducing the fattest path augmenting
algorithm, an improvement over the Ford-Fulkerson algorithm, to solve the max flow problem. We
also discuss the minimum cost circulation problem.
2 Maximum Flow
In a maximum flow problem, the goal is to find the greatest rate (flow) at which material can be
sent from a source s to a sink t. Several problems can be modeled as a max-flow problem, including
bipartite matching, which will be discussed today. We will also discuss flow decomposition and the
fattest augmenting path algorithm.
Figure 1: The figure on the left represents a matching in a bipartite graph. The figure on the right
shows how the bipartite graph can be converted into a max-flow network by imposing a capacity of
1 on arcs out of s and into t.
3-1
The network is constructed as follows: We orient each edge in G from A to B and assign them a
capacity of 1 (any capacity greater than 1 works too). We also add two new vertices, s and t, and
arcs from s to every vertex in A, and from every vertex in B to t. All the new arcs are given unit
capacity.
Theorem 1 Let G = (V, E) be a bipartite graph with vertex partition V = A ∪ B, and let G� =
(V � , E � ) be the capacitated network constructed as above. If M is a matching in G, then there is an
integer-valued flow f in G� with value |f | = |M |. Conversely, if f is an integer-valued flow in G� ,
then there is a matching M in G with cardinality |M | = |f |.
Proof: Given M , define a flow f in G� as follows: if (u, v) ∈ M , then set f (s, u) = f (u, v) =
f (v, t) = 1 and f (u, s) = f (v, u) = f (t, v) = −1. For all other edges (u, v) ∈ E � , let f (u, v) = 0.
Each edge (u, v) ∈ M corresponds to 1 unit of flow in G� that traverses the path s → u → v → t.
The paths in M have distinct vertices, aside from s and t. The net flow across the cut (A ∪ s : B ∪ t)
is equal to |M |. We know that the net flow across any cut is the same, and equals the value of the
flow. Thus, we can conclude that |M | = |f |. To prove the converse, let f be an integer-valued flow
in G� . By flow conservation and the choice of capacities, the net flow in each arc must be -1, 0 or
1. Let M be the set of edges (u, v), with u ∈ A, v ∈ B for which f (u, v) = 1. It is easy to see, by
flow conservation again, that M is indeed a matching and, using the same argument as before, that
|M | = |f |. �
Since all the capacities of this maximum flow problem are integer valued, we know that there
always exists an integer-valued maximum flow, and therefore the theorem shows that this maximum
flow formulation correctly models the maximum cardinality bipartite matching.
Theorem 2 Any (raw) s-t flow r can be decomposed into at most m flows along either paths from s
to t or cycles, where m is the number of edges in the network. More precisely, it can be decomposed
into at most |{e : r(e) > 0}| ≤ m paths and cycles.
Proof: By tracing back the flow on an edge e and tracing forward the flow on e, we either get an
s-t path T , or a cycle T with r(e) > 0 for all e ∈ T . Denote the min flow on T by Δ(T ):
We want to decrease the flow on T such that at least one edge goes to 0 (by subtracting out Δ(T )),
and keep doing that until there are no more edges with non-zero flows. More precisely, the following
algorithm extracts at most m paths and cycles.
3-2
(a) Decrease the flow on this path by Δ(P ).
(b) Add this path as an element of the flow decomposition.
Each time we decrease the flow on a path or a cycle T , we zero out the flow on some edge.
When we do this, the new raw flow is rnew (e) = r(e) − Δ(T ) if e ∈ T , or r(e) otherwise. Since
there are |{e : r(e) > 0}| ≤ m edges with positive flow in the graph, there will be at most that
number of decreases in the flow, and consequently, at most that number of paths or cycles in the
flow decomposition. �
where the uf are the residual capacities. The minimum residual capacity ε(P ) (the bottleneck) is
the maximum flow that can be pushed along the path P . We wish to find the fattest augmenting
path P such that ε(P ) is maximized. The fattest augmenting path P can be efficiently found with
Dijkstra’s algorithm in O(m + n log n) time 1 .
Theorem 3 Assuming that capacities are integral and bounded by U , the optimal flow for a network
can be found in O(m log(mU )) = O(m log(nU )) iterations of augmenting along the fattest path.
Proof: Start with a zero flow, f = 0. Consider a maximum flow f ∗ . Its value is at most the value
of any cut, which is bounded by mU :
|f ∗ | ≤ mU.
Consider the flow f ∗ − f (this is, f ∗ (e) − f (e) for all edges e) in the residual graph Gf with residual
capacities uf = u − f .
We can decompose f ∗ − f into ≤ m flows using flow decomposition. As a result, at least one of
these paths carry a flow of value at least m 1
(|f ∗ | − |f |). Suppose now that we push ε(P ) units of
flow along the fattest path in the residual graph Gf and obtain a new flow f new of value:
|f new | = |f | + ε(P ).
Since the fattest path provides the greatest increase in flow value, we must have that ε(P ) ≥
1 ∗
m (|f | − |f |). Thus we have the following inequality
1
|f new | ≥ |f | + (|f ∗ | − |f |),
m
1 Actually,it can be found in O(m) time under the condition that we have the capacities sorted beforehand, see
the forthcoming problem set.
3-3
which implies
|f ∗ | − |f new | = |f ∗ | − |f | + |f | − |f new |
� �
1
≤ 1− (|f ∗ | − |f |) .
m
Eventually |f ∗ | − |fˆ| < 1 which implies f ∗ = fˆ since, for integral capacities, all intermediate flows
1 m
will be integral. Since (1 − m ) ≤ 1e for all m ≥ 2, the number of iterations required for the
difference to go below 1 is
k = m log(mU ).
�
Combining the results mentioned above we have the following corollary.
Corollary 4 We can find a maximum flow in an integer-capacitated network with maximum capacity
U in O((m + n log n)m log(nU )) time 2 .
Definition 2 A cost function c : E �→ R assigns a cost per unit flow to each edge. We assume the
cost function satisfies skew symmetry: c(v, w) = −c(w, v). For a set of edges C (e.g. a cycle), we
denote the total cost of C by : �
c(C) = c(v, w).
(v,w)∈C
Definition 3 The goal of the Minimum Cost Circulation Problem (MCCP) is to find a circulation
f of minimum cost c(f ) where �
c(f ) = c(v, w)f (v, w).
(v,w)
The MCCP is a special case of a Linear Programming (LP) problem (an optimization problem
with linear constraints and a linear objective function). But while no strongly polynomial time
algorithms are known for linear programming, we will be able to find one for MCCP.
2 Using the previous footnote, we can do this in O(m2 log(nU )) time.
3-4
3.1 Vertex Potentials
Before we can solve MCCP, it is necessary to introduce the concept of vertex potentials, or simply
potentials.
Definition 4 A vertex potential is a function p : V �→ R that assigns each vertex a potential. The
vertex potential defines a reduced cost function cp such that
(ii) Cycle Equivalence: for a cycle C, c(C) = cp (C); i.e., the reduced cost function agrees with
the cost function.
(iii) Circulation Equivalence: for all circulations, the reduced cost function agrees with the cost
function, c(f ) = cp (f ).
Proof: The first property is trivial. The second property follows since all the potential terms
cancel out. And we’ll prove the third property. By definition
�
cp (f ) = (c(v, w) + p(v) − p(w))(f (v, w))
(v,w)
� � � �
= c(f ) + p(v) f (v, w) − p(w) f (v, w).
v w:(v,w)∈E w v:(w,v)∈E
Now by flow conservation, the inner sums are all zero. Hence cp (f ) = c(f ). (The third property also
follows easily from flow decomposition, as the decomposition of a circulation only contains cycles
and thus the cost and the reduced cost of a circulation are the same because of (ii).) �
Of course, this doesn’t lead to a straight-forward implementation, since we haven’t specified which
negative-cost cycle to select or how to find them. We should also consider whether the algorithm is
efficient and whether it will terminate. We’ll answer these questions in the next lecture. However,
we will show now that if it terminates, then the circulation output is of minimum cost.
3-5
(iii) There exists a potential function p such that for all (v, w) ∈ Ef , cp (v, w) ≥ 0.
Proof: To show that (i) implies (ii), we’ll prove the contrapositive. Suppose there exists a negative
cost cycle C in the residual graph Gf where f is the optimal circulation. Denote by C � the reverse
cycle (i.e. following the arcs in the reverse order). We define a new circulation f � for any edge e as
follows. If e ∈ C, f � (e) = f (e) + ε. And if e ∈ C � , then f � (e) = f (e) − ε. Otherwise, let f � (e) = f (e).
Then we compute the cost of this new flow as
where the last step follows since C is a negative cost cycle. Thus we’ve shown that f is indeed not
optimal. Hence (i) implies (ii).
Now we show that (ii) implies (iii). Add zero-cost (or of arbitrary cost) arcs from a new vertex
s to every vertex in Gf (this is to make sure that s can reach every vertex in V ). Define a potential
p such that p(v) is the length of the shortest simple path from s to v. Then, since there are no
negative cost cycle, we have the optimality conditions for the shortest-path lengths:
c(f ∗ − f ) = cp (f ∗ − f )
�
= cp (v, w)[f ∗ (v, w) − f (v, w)]
(v,w)∈E
�
= 2 cp (v, w)[f ∗ (v, w) − f (v, w)]
(v,w):f ∗ −f >0
≥ 0
by (iii). Note that in the second to last step, we utilized the skew-symmetry of the cost of reverse
arcs (with flows of opposite parity). But since f ∗ is supposed to be strictly better than f , we have
a contradiction. �
References
[EK72] Jack Edmonds, and Richard M. Karp, Theoretical improvements in algorithmic efficiency
for network flow problems, Journal of the ACM 19 (2): 248–264, 1972.
[Klein67] Klein, M. A primal method for minimum cost flows with application to the assignment and
transportation problem. Management Science 14: 205-220, 1967.
3-6