



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Algorithms; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Spring 1999;
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




A process cannot be understood by stopping it. Understanding must move with the flow of the process, must join it and flow with it. — The First Law of Mentat, in Frank Herbert’s Dune (1965)
There’s a difference between knowing the path and walking the path. — Morpheus [Laurence Fishburne], The Matrix (1999)
capacity function c : E → IR≥ 0. For any flow function f : E → IR≥ 0 , the residual capacity is defined as
0 otherwise
The residual graph Gf = ( V , Ef ), where Ef is the set of edges whose non-zero residual capacity is positive.
s t
10/
0/
10/
0/
10/
5/
5/
5/
0/ s t 10
10
5
10
15 5 5
10 5
15
5
10 10
A flow f in a weighted graph G and its residual graph Gf.
In the last lecture, we proved the Max-flow Min-cut Theorem: In any weighted directed graph network, the value of the maximum ( s , t ) -flow is equal to the cost of the minimum ( s , t ) -cut. The proof of the theorem is constructive. If the residual graph contains a path from s to t , then we can increase the flow by the minimum capacity of the edges on this path, so we must not have the maximum flow. Otherwise, we can define a cut ( S , T ) whose cost is the same as the flow f , such that every edge from S to T is saturated and every edge from T to S is empty, which implies that f is a maximum flow and ( S , T ) is a minimum cut.
s t 10
10
5
10
15 5 5
10 5
15
5
10 10 s t
10/
5/
5/
5/
10/
5/
0/
10/
0/
An augmenting path in Gf and the resulting (maximum) flow f ′.
It’s not hard to realize that this proof translates almost immediately to an algorithm, first developed by Ford and Fulkerson in the 1950s: Starting with the zero flow, repeatedly augment the flow along any path s † t in the residual graph, until there is no such path. If every edge capacity is an integer, then every augmentation step increases the value of the flow by a positive integer. Thus, the algorithm halts after | f ∗| iterations, where f ∗^ is the actual maximum flow. Each iteration requires O ( E ) time, to create the residual graph Gf and perform a whatever-first-search
to find an augmenting path. Thus, in the words case, the Ford-Fulkerson algorithm runs in O ( E | f ∗|)
time. If we multiply all the capacities by the same (positive) constant, the maximum flow increases everywhere by the same constant factor. It follows that if all the edge capacities are rational , then the Ford-Fulkerson algorithm eventually halts. However, if we allow irrational capacities, the algorithm can loop forever, always finding smaller and smaller augmenting paths. Worse yet, this infinite sequence of augmentations may not even converge to the maximum flow! Perhaps the simplest example of this effect was discovered by Uri Zwick. Consider the graph shown below, with six vertices and nine edges. Six of the edges have some large integer capacity X , two have capacity 1, and one has capacity φ = (
p 5 − 1 ) / 2 ≈ 0 .618034, chosen so that 1 − φ = φ^2. To prove that the Ford-Fulkerson algorithm can get stuck, we can watch the residual capacities of the three horizontal edges as the algorithm progresses. (The residual capacities of the other six edges will always be at least X − 3.)
t
s X (^) X X
X X X
1 1 ϕ
A B C Uri Zwick’s non-terminating flow example, and three augmenting paths.
The Ford-Fulkerson algorithm starts by choosing the central augmenting path, shown in the large figure above. The three horizontal edges„ in order from left to right, now have residual capacities 1, 0, φ. Suppose inductively that the horizontal residual capacities are φk −^1 , 0, φk^ for some non-negative integer k.
The second Edmonds-Karp heuristic was actually proposed by Ford and Fulkerson in their original max-flow paper, and first analyzed by the Russian mathematician Dinits (sometimes transliterated Dinic) in 1970. Edmonds and Karp published their independent and slightly weaker analysis in 1972. So naturally, almost everyone refers to this algorithm as ‘Edmonds-Karp’.^2
Choose the augmenting path with fewest edges.
The correct path can be found in O ( E ) time by running breadth-first search in the residual graph. More surprisingly, the algorithm halts after a polynomial number of iterations, independent of the actual edge capacities! The proof of this upper bound relies on two observations about the evolution of the residual graph. Let fi be the current flow after i augmentation steps, let Gi be the corresponding residual graph. In particular, f 0 is zero everywhere and G 0 = G. For each vertex v , let leveli ( v ) denote the unweighted shortest path distance from s to v in Gi , or equivalently, the level of v in a breadth-first search tree of Gi rooted at s. Our first observation is that these levels can only increase over time.
Lemma 1. leveli + 1 ( v ) ≥ leveli ( v ) for all vertices v and integers i.
Proof: The claim is trivial for v = s , since leveli ( s ) = 0 for all i. Choose an arbitrary vertex v 6 = s , and
and we’re done.) Because this is a shortest path, we have leveli + 1 ( v ) = leveli + 1 ( u ) + 1, and the inductive hypothesis implies that leveli + 1 ( u ) ≥ leveli ( u ).
the levels are defined by breadth-first traversal.
leveli ( u ) + 1. In both cases, we have leveli + 1 ( v ) = leveli + 1 ( u ) + 1 ≥ leveli ( u ) + 1 ≥ leveli ( v ). É
Whenever we augment the flow, the bottleneck edge in the augmenting path disappears from the residual graph, and some other edge in the reversal of the augmenting path may (re-)appear. Our second observation is that an edge cannot appear or disappear too many times.
the residual graph Gf at most V / 2 times.
lemma, we have levelj ( u ) = levelj ( v ) + 1 ≥ leveli ( v ) + 1 = leveli ( u ) + 2. (^2) To be fair, Edmonds and Karp discovered their algorithm a few years before publication—getting ideas into print takes time, especially in the early 1970s—which is why some authors believe they deserve priority. I don’t buy it; Dinits also presumably discovered his algorithm a few years before its publication. (In Soviet Union, result publish you.) On the gripping hand, Dinits’s paper also described an improvement to the algorithm presented here that runs in O ( V^2 E ) time instead of O ( V E^2 ), so maybe that ought to be called Dinits’s algorithm.
In other words, the distance from s to u increased by at least 2 between the disappearance and
at most V / 2. É
Now we can derive an upper bound on the number of iterations. Since each edge can disappear at most V / 2 times, there are at most EV / 2 edge disappearances overall. But at least one edge disappears on each iteration, so the algorithm must halt after at most EV / 2 iterations. Finally, since each iteration
requires O ( E ) time, Dinits’ algorithm runs in O ( V E^2 ) time overall.