0% found this document useful (0 votes)
31 views3 pages

The Maximum Flow Problem

This document summarizes Dinic's algorithm for finding the maximum flow in a directed graph. It discusses key concepts like residual capacity, augmenting paths, and blocking flows. Dinic's algorithm works by repeatedly finding blocking flows in the level graph of the residual graph and pushing flow along augmenting paths. This can find a maximum flow in O(n^2m) time, where n is the number of vertices and m is the number of edges. The algorithm terminates in at most n-1 iterations because the level/distance of the sink vertex t from the source s increases with each iteration.

Uploaded by

islslsls
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
31 views3 pages

The Maximum Flow Problem

This document summarizes Dinic's algorithm for finding the maximum flow in a directed graph. It discusses key concepts like residual capacity, augmenting paths, and blocking flows. Dinic's algorithm works by repeatedly finding blocking flows in the level graph of the residual graph and pushing flow along augmenting paths. This can find a maximum flow in O(n^2m) time, where n is the number of vertices and m is the number of edges. The algorithm terminates in at most n-1 iterations because the level/distance of the sink vertex t from the source s increases with each iteration.

Uploaded by

islslsls
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

Meeting 18

November 3, 2005

Maximum Flow

cross the cut from X to Y ,


X
f (vw)
f (X, Y ) =

Computing flow in directed graphs is a natural but also


a fundamental problem to which other problems can be
reduced. It is an outgrowth of linear programming and
usually studied within the general field of optimization.
We consider it in this course because good data structures
are able to improve the running time of otherwise classic
flow algorithms. In this lecture, we describe Dinics algorithm for maximum flow and leave the implementation
using linking and cutting trees to the next lecture.

vX,wY

f (vw)

vX,wV

f (vw).

vX,wX

By skew symmetry, the second sum of the result vanishes.


By conservation of flow, the only non-zero contribution to
the first sum comes from v = s. Hence f (X, Y ) = |f |. In
words, for any flow f and any cut, the flow across the cut
is equal
Pto |f |. Specifically, we may choose Y = {t}, so
|f | = w f (wt).

The maximum flow problem. Let G = (V, E) be a directed graph with a distinguished source, s V , and a distinguished sink, t V . Each edge has a positive capacity,
which we describe by the function cap : V V R with
cap(vw) > 0 if vw E and cap(vw) = 0 if vw 6 E.
For example, we assume G has no loops, so cap(vv) = 0
for all v V . A flow is a function f : V V R that

Residual capacity. The capacity constraint in the definition of a flow implies f (X, Y ) cap(X, Y ), for every cut. This implies that the value of a max-flow is
no larger than the capacity of a min-cut. We will prove
shortly that the two are, in fact, equal. To this end, we
introduce the residual capacity, res : V V R, defined by res = cap f . The capacity constraint implies
res(vw) 0 for every ordered pair of vertices. The resid-

(i) is skew symmetric: f (vw) = f (wv);


(ii) satisfies the capacity constraint: f (vw) cap(vw);
P
(iii) conserves the flow: w f (vw) = 0 unless v = s, t.
If f (vw) > 0 we say there is flow from v to w. The flow
saturates an edge P
vw if f (vw) = cap(vw). The value of
the flow is |f | = w f (sw). A max-flow is a flow with
maximum value. Generally, such a flow is not unique. We
are interested in constructing a max-flow.

3, 3

4, 1

3
1 3

1, 1
2, 2

3,2

Similar to minimum spanning trees, a key concept in


max-flow construction is a cut, which is a partition of the
vertex set, V = X Y , such that s X and t Y . The
capacity of the cut is the sum of the capacities of the edges
that cross the cut from X to Y ,
X
cap(X, Y ) =
cap(vw).

3, 0

2
2

3, 2

4, 2

3
1

Figure 74: Left: directed graph with capacity (boldface) and


flow. Three of the edges are saturated and one has no flow. Right:
corresponding residual graph with residual capacity (boldface).

vX,wY

A min-cut is a cut with minimum capacity. Similarly, the


flow across the cut is the sum of flow along the edges that

ual graph, R, of f consists of all vertices and of all edges

60

with positive residual capacity. As can be seen in Figure 74, only the edges in G as well as their oppositely
directed versions can be in R. An augmenting path is
a path p from s to t in R, and its residual capacity is
res(p) = minvwp res(vw). For example, in Figure 74
there are two augmenting paths that visit each vertex at
most once, and both have residual capacity equal to one.
We can increase the flow by pushing up to res(p) additional units of flow along p.

Augmenting path method. The above considerations


suggest we construct a max-flow iteratively, by repeatedly
adding the flow along augmenting paths. Slightly more
formally, we start with f = 0 and repeat
Augmenting Step: find an augmenting path p and increase
the flow f by pushing res(p) units of flow along p.
If the capacities are integers, we get a max-flow in at most
|f | augmenting steps. It follows that for such a graph
there is an integer max-flow. The number of iterations depends on which augmenting paths we choose. If the capacities are irrational numbers, it is possible to get caught
in an infinite loop that converges toward a flow that is not
a max-flow. Nevertheless, we can prove there is always a
relatively short sequence of augmenting steps that leads to
a max-flow.

Max-flow min-cut. Suppose f is a flow on G and f is


a max-flow on G. Furthermore, let f 0 be a max-flow on R.
This is well defined because R and res can be substituted
for G and cap and define their own flow problem. The
back-edges of R express the fact that we can, and sometimes want to reduce the flow along edges of G. We note
that f + f 0 is skew symmetric, satisfies the capacity constraint for G, and conserves the flow. It therefore is a flow
on G and we have

L EMMA . m augmenting steps suffice to increase f = 0


to a max-flow.

|f + f 0 | = |f | + |f 0 | |f |.

P ROOF. We argue backwards, starting with a max-flow f .


Let G be the subgraph of G induced by positive flow
edges.

Similarly, f f is a flow on R, so we have


|f f | = |f | |f | |f 0 |.

Backward Step: find a path p from s to t in G , let be


the smallest flow along an edge in p, and decrease f
by along p.

In words, the value of the max-flow on R is the difference


between the values of the flow and the max-flow on G,
|f 0 | = |f ||f |. We are now ready to prove that the value
of the max-flow is equal to the capacity of the min-cut.

In each backward step, the flow vanishes along at least


one additional edge. This edge then gets removed from
G , which implies that s and t become disconnected in at
most m backward steps.

M AX - FLOW M IN - CUT T HEOREM . The following conditions are equivalent:

The proof is non-constructive and it is not clear how we


can find the at most m augmenting paths going forward.
A natural strategy is to always augment along a maximum
residual capacity path. Such a path can be constructed using the bottleneck version of Dijkstras algorithm. It is
also possible to show that the number of such augmenting steps is bounded by O(m log(C + 1)), where C is the
maximum capacity of any edge, assuming the capacities
are integers.

(i) f is a max-flow;
(ii) there is no augmenting path;
(iii) |f | = cap(X, Y ) for some cut V = X Y .
P ROOF. (i) (ii) (iii) (i). The first implication
is obvious and so is the last. To prove (ii) (iii), let
X be the set of vertices reachable from s in R and set
Y = V X. By construction, each edge from X to Y is
saturated. Therefore,
X
f (vw)
|f | =

Dinics algorithm. A different strategy suggests we


push flow along shortest augmenting paths. Indeed, Dinic
suggests we push flow along all such paths simultaneously.
Here length is measured by counting edges. The key concept is a blocking flow in which every path from s to t contains a saturated edge. Such a flow cannot be improved by
pushing additional flow along a path in the graph, but it

vX,wY

cap(vw),

vX,wY

which is the capacity of the cut, cap(X, Y ).

61

is not the same as a max-flow. Consider, for example, the


blocking flow of the level graph with residual capacities
shown in the top row of Figure 75. It can be improved by
pushing another unit of flow along the top two edges of the
right path, then along the diagonal but opposing its direction, and finally along the last two edges of the left path.
Let R be the residual graph of f and call the distance of a
vertex v from s its level. The level graph is the subgraph L
of R containing all vertices reachable from s along level
increasing edges. In other words, L is the union of all
shortest paths with source s. Using breadth-first search,
we can compute L in time O(m).

p reaching all the way to t, we push res(p) units of flow


along p, and iterate. Each time we push flow, we saturate
at least one edge, thus shrinking L by at least one edge.
If we also delete the incoming edge uv whenever v is a
dead-end in the search, we get a blocking flow in time
O(mn). More details on this method and an improved
implementation will be given in the next lecture.
Number of augmentations. We prove that Dinics algorithm halts after at most n1 steps. We do this by showing
that in each step, the level of t increases. Consider Ri , Li
and Ri+1 , Li+1 , the residual and the level graphs after i
and i + 1 Dinic steps. Let vw be an edge in Ri+1 . If vw is
also in Ri then leveli (w) leveli (v) + 1 by definition of
level in Ri . Otherwise, we must have pushed flow in the
opposite direction, from w to v, so wv Li and we again
have leveli (w) leveli (v) + 1. If we now take a path
from s to t in Li+1 , we get leveli+1 (w) = leveli+1 (v) + 1
for each of its edges and therefore leveli+1 (t) leveli (t).
Assuming equality, we get a contradiction by considering
a shortest path p from s to t in Ri . Every edge vw p is
in Li , but at least one edge of p is not in Ri+1 . Hence
Ri+1 contains none of the shortest paths of Ri and it
contains no new paths of the same length. This implies
leveli+1 (t) > leveli (t). The level of t starts out as 1 or
larger and it cannot exceed n 1. Hence it becomes undefined after at most n 1 Dinic steps.

Dinic Step: find a blocking flow f 0 of the level graph of f


and set f = f + f 0 .
We illustrate this method for the graph in Figure 74. A
0

1
2

3
3
0

1
3

0
2

1
1

1 3
2

1
1

2
2

1 2
2

1
2

To summarize, we have an algorithm that constructs a


max-flow of G in fewer than n iterations, each taking time
O(mn). We thus have an algorithm that constructs a maxflow in time O(n2 m).

2
4

1
3

Figure 75: Left column: graphs with flows. Middle column:


residual graphs with residual capacities. Right column: level
graphs with levels and blocking flows.

simple way for finding a blocking flow in L uses depthfirst search. Starting from s, we stop when we have a path

62

You might also like