07NetworkFlowI 2x2
07NetworkFlowI 2x2
N ETWORK F LOW I
A flow network is a tuple G = (V, E, s, t, c). Def. An st-cut (cut) is a partition (A, B) of the nodes with s ∈ A and t ∈ B.
・Digraph (V, E) with source s ∈ V and sink t ∈ V.
・Capacity c(e) ≥ 0 for each e ∈ E. assume all nodes are reachable from s
Def. Its capacity is the sum of the capacities of the edges from A to B.
capacity
9
4 15 15 10
10 10
s 5 8 10 t s 5 t
15 15
4 6 15 10
16
capacity = 10 + 5 + 15 = 30
3 4
Minimum-cut problem Minimum-cut problem
Def. An st-cut (cut) is a partition (A, B) of the nodes with s ∈ A and t ∈ B. Def. An st-cut (cut) is a partition (A, B) of the nodes with s ∈ A and t ∈ B.
Def. Its capacity is the sum of the capacities of the edges from A to B. Def. Its capacity is the sum of the capacities of the edges from A to B.
10 10
s 8 t s 8 t
16
capacity = 10 + 8 + 16 = 34 capacity = 10 + 8 + 10 = 28
5 6
Which is the capacity of the given st-cut? Def. An st-flow (flow) f is a function that satisfies:
C. 45 (20 + 25)
D. 79 (20 + 25 + 8 + 11 + 9 + 6)
flow capacity
inflow at v = 5 + 5 + 0 = 10
5/9 outflow at v = 10 + 0 = 10
capacity
5 5
s 20 8 10 10 0/4 /1 0 / 15 /
10
/ 5
10
s 5/5 5/8 v 10 / 10 t
6 12 8 11 9 8
6
10
/ 0 0 / 15 10
15 0/4 /6 /
10
1 16 25 t
10 / 16
7 8
Maximum-flow problem Maximum-flow problem
Def. An st-flow (flow) f is a function that satisfies: Def. An st-flow (flow) f is a function that satisfies:
・For each e ∈ E : 0 f (e) c(e) [capacity] ・For each e ∈ E : 0 f (e) c(e) [capacity]
・For each v ∈ V – {s, t} : e v
f (e) =
e v
f (e) [flow conservation] ・For each v ∈ V – {s, t} : e v
f (e) =
e v
f (e) [flow conservation]
Def. The value of a flow f is: val(f ) = f (e) f (e) Def. The value of a flow f is: val(f ) = f (e) f (e)
e s e s e s e s
5/9 8/9
5 5 2 8
10 0/4 /1 0 / 15 /
10 10 0/4 /1 0 / 15 /
10
/ 5 / 5
10 10
10 13
/ 0 0 / 15 10 / 3 0 / 15 10
15 0/4 /6 / 15 0/4 /6 /
10 10
value = 5 + 10 + 10 = 25 value = 10 + 5 + 13 = 28
10 / 16 13 / 16
9 10
Greedy algorithm.
7. N ETWORK F LOW I ・Start with f (e) = 0 for each edge e ∈ E.
・Find an s↝t path P where each edge has f (e) < c(e).
‣ max-flow and min-cut problems ・Augment flow along path P.
‣ Ford–Fulkerson algorithm ・Repeat until you get stuck.
‣ max-flow min-cut theorem
‣ capacity-scaling algorithm
‣ shortest augmenting paths flow capacity
flow network G and flow f
‣ Dinitz’ algorithm
0/4
‣ simple unit-capacity networks
SECTION 7.1
0
0 /
10 0/2 /8 0/6 10
/
0 value of flow
s 0 / 10 0/9 0 / 10 t 0
12
Toward a max-flow algorithm Toward a max-flow algorithm
0/4 0/4
8
0 — 0
0 / 0 /
10 0/2 /8 0/6 10 8 10 0/2 /8 0/6 10
/ /
0 0
—
8
s 0 / 10 0/9 0 / 10 t 0 s 0 / 10 0/9 —
0 / 10 t 0 +8=8
13 14
0/4 0/4
6
0 —
0
10 2 —
0/2 8 0/6 / 10 2/2 8 6 —
0/6 /
10 /
/8 10 / /8 10
8
— 10
2 10 6 8
s 0 / 10 —
0/9 —8 / 10 t 8 + 2 = 10 s —
0 / 10 —
2/9 10 / 10 t 10 + 6 = 16
15 16
Toward a max-flow algorithm Toward a max-flow algorithm
0/4 3/4
6 9
10 2/2 8
/8 6/6 / 10 0/2 7
/8 6/6 /
/ 10 / 10
10 10
s 6 / 10 8/9 10 / 10 t 16 s 9 / 10 9/9 10 / 10 t 19
17 18
Q. Why does the greedy algorithm fail? Original edge. e = (u, v) ∈ E. original flow network G
A. Once greedy algorithm increases flow on an edge, it never decreases it. ・Flow f (e). 6 / 17
・Capacity c(e).
u v
・The unique max flow f * has f *(v, w) = 0. Reverse edge. e reverse = (v, u).
・Greedy algorithm could choose s→v→w→t as first path. ・“Undo” flow sent.
residual network Gf residual
flow network G
Residual capacity. capacity
v 2 t (
<latexit sha1_base64="YJfOSbURwSXvCUYEAycBJsfVqD0=">AAACrnicbVBdi9NAFJ3ErzV+bHd9Ul8Gi7I+WBJZdF+EBRF8XMF2F5oYJrc37bCTSZi5kZaQN/+kf8Ff4STNg229MHA459w5MyerlLQUhr89/87de/cfHD0MHj1+8vR4dHI6s2VtAKdQqtLcZMKikhqnJEnhTWVQFJnC6+z2c6df/0RjZam/06bCpBBLLXMJghyVjn5Bmp/hW/4piDNcSt2Au8y2AXTkO95rb3hMuKZG5rzlyGOp+Zc4Dpz2o9kqBrsMbNt984Fhu83deox6MaSlo3E4CfvhhyAawJgNc5WeeKfxooS6QE2ghLXzKKwoaYQhCQrbIK4tVgJuxRLnDmpRoE2avq6Wv3bMguelcUcT79l/NxpRWLspMucsBK3svtaR/9PmNeUXSSN1VRNq2AblteJU8q57vpAGgdTGAQFGurdyWAkjgFw5Oyn93RXCzk+ada0llAvcYxWtyYiuxWi/s0Mwez+JPkzOv52PLy+GPo/YS/aKnbGIfWSX7Cu7YlMG7I838p57L/zQn/mJn26tvjfsPGM746/+Aodl0mY=</latexit>
u 11 v
c(e) f (e) e2E
cf (e) = 6
f (e ) e 2E
reverse edge
2 1 2
edges with positive
residual capacity
Def. An augmenting path is a simple s↝t path in the residual network G f . Which is the augmenting path of highest bottleneck capacity?
A. A→F→G→H
Def. The bottleneck capacity of an augmenting path P is the minimum
residual capacity of any edge in P. B. A→B→C→D →H
C. A→F→B→G→H
Key property. Let f be a flow and let P be an augmenting path in G f .
D. A→F→B→G→ C→D→H
Then, after calling f ʹ ← AUGMENT( f, c, P), the resulting f ʹ is a flow and
val( f ʹ) = val( f ) + bottleneck(G f, P).
21 5 target 22
Ford–Fulkerson algorithm
RETURN f.
23
Relationship between flows and cuts Relationship between flows and cuts
Flow value lemma. Let f be any flow and let (A, B) be any cut. Then, Flow value lemma. Let f be any flow and let (A, B) be any cut. Then,
the value of the flow f equals the net flow across the cut (A, B). the value of the flow f equals the net flow across the cut (A, B).
5/9 5/9
5 5 5 5
10 0/4 /1 0 / 15 /
10 10 0/4 /1 0 / 15 /
10
/ 5 / 5
10 10
10 10
/ 0 0 / 15 10 / 0 0 / 15 10
15 0/4 /6 / 15 0/4 /6 /
10 10
10 / 16 10 / 16
25 26
Flow value lemma. Let f be any flow and let (A, B) be any cut. Then, Which is the net flow across the given cut?
the value of the flow f equals the net flow across the cut (A, B).
A. 11 (20 + 25 − 8 − 11 − 9 − 6)
D. 45 (20 + 25)
net flow across cut = (10 + 10 + 5 + 10 + 0 + 0) – (5 + 5 + 0 + 0) = 25
5/9
1/1 14 / 16 22 / 25 t
10 / 16
27 28
Relationship between flows and cuts Relationship between flows and cuts
Flow value lemma. Let f be any flow and let (A, B) be any cut. Then, Weak duality. Let f be any flow and (A, B) be any cut. Then, val( f ) ≤ cap(A, B).
the value of the flow f equals the net flow across the cut (A, B). Pf.
val(f ) = f (e) f (e)
e A e A
val(f ) = f (e) f (e)
e A e A f (e)
flow value
lemma e A
c(e)
Pf. val(f ) = f (e) f (e) e A
e s e s
= cap(A, B) ▪
by flow conservation, all terms
except for v = s are 0
= f (e) f (e)
8/9
v A e v e v
2 8
/1 /
10 0/4 5 0 / 15 10
/ 10
val(f ) = f (e) f (e) 10
▪
e A e A
s 5/5 7/8 9 / 10 t s 5 t
12
2
/
15 0/4 /6 0 / 15 10 15
/
10
12 / 16
Corollary. Let f be a flow and let (A, B) be any cut. Max-flow min-cut theorem. Value of a max flow = capacity of a min cut.
If val( f ) = cap(A, B), then f is a max flow and (A, B) is a min cut. strong duality
weak duality
Pf.
・For any flow f ʹ: val( f ʹ) ≤ cap(A, B) = val( f ).
・For any cut (Aʹ, Bʹ): cap(Aʹ, Bʹ) ≥ val( f ) = cap(A, B). ▪
weak duality
8/9
2
/1
8 1956 IRE TRANXACTIONX ON INFORiMATION THEORY 117
/
10 0/4 5 0 / 15 10
/ 10
10
A Note on the Maximum Flow Through a Network*
P. ELIASt, A. FEINSTEINI, AND C. E. SHANNON!
s 5/5 8/8 10 / 10 t s 8 t
Max-flow min-cut theorem. Value of a max flow = capacity of a min cut. Max-flow min-cut theorem. Value of a max flow = capacity of a min cut.
Augmenting path theorem. A flow f is a max flow iff no augmenting paths. Augmenting path theorem. A flow f is a max flow iff no augmenting paths.
Pf. The following three conditions are equivalent for any flow f : Pf. The following three conditions are equivalent for any flow f :
i. There exists a cut (A, B) such that cap(A, B) = val( f ). i. There exists a cut (A, B) such that cap(A, B) = val( f ).
ii. f is a max flow. ii. f is a max flow.
if Ford–Fulkerson terminates,
iii. There is no augmenting path with respect to f. then f is max flow
iii. There is no augmenting path with respect to f.
33 34
[ iii ⇒ i ] Theorem. Given any max flow f , can compute a min cut (A, B) in O(m) time.
・Let f be a flow with no augmenting paths. Pf. Let A = set of nodes reachable from s in residual network G f . ▪
・Let A = set of nodes reachable from s in residual network G f. argument from previous slide implies that
・By definition of A: s ∈ A. capacity of (A, B) = value of flow f
A s 5 8 10 t
= cap(A, B) s
15
2 3 1 6
10
13
35 36
Analysis of Ford–Fulkerson algorithm (when capacities are integral)
Q. Is generic Ford–Fulkerson algorithm poly-time in input size? The Ford–Fulkerson algorithm is guaranteed to terminate if the edge
m, n, and log C capacities are …
A. No. If max capacity is C, then algorithm can take ≥ C iterations.
・s→v→w→t A. Rational numbers.
・s→w→v→t
Let D denote the product (or lcm) of the denominators.
each augmenting path
Then, every edge flow f (e) and every residual capacity cf (e)
sends only 1 unit of flow
・s→v→w→t (# augmenting paths = 2C)
s
B. Real numbers. is a multiple of 1 / D.
・s→w→v→t
v 1 w
C
t
39 40
Choosing good augmenting paths Choosing good augmenting paths
Use care when selecting augmenting paths. Choose augmenting paths with:
・Some choices lead to exponential algorithms. ・Max bottleneck capacity (“fattest”). how to find?
・Clever choices lead to polynomial algorithms. ・Sufficiently large bottleneck capacity. next
JACK EDMONDS
・Few iterations. ABSTRACT. This paper presents new algorithms for t h e m a x i m u m flow problem, the Hitchcock
t r a n s p o r t a t i o n problem, and t h e general m i n i m u m - c o s t flow problem. U p p e r bounds on the
numbers of steps in these algorithms are derived, and are shown to compale favorably with
upper bounds on t h e numbers of steps required by earlier algorithms.
First, the paper states the m a x i m u m flow problem, gives the F o r d - F u l k e r s o n labeling method
for its solution, and points out t h a t an improper choice of flow a u g m e n t i n g p a t h s can lead to
Edmonds-Karp 1972 (USA)
severe c o m p u t a t i o n a l difficulties. T h e n rules of choice t h a t avoid these difficulties are given.
We show t h a t , if each flow a u g m e n t a t i o n is made along an a u g m e n t i n g p a t h h a v i n g a minimum Dinitz 1970 (Soviet Union)
n u m b e r of arcs, t h e n a m a x i m u m flow in an n-node network will be o b t a i n e d a f t e r no more t h a n
~(n a - n) a u g m e n t a t i o n s ; and t h e n we show t h a t if each flow change is chosen to produce a
m a x i m u m increase in the flow value then, provided the capacities are integral, a m a x i m u m flow
will be d e t e r m i n e d within at most 1 + logM/(M--1) if(t, S) a u g m e n t a t i o n s , wheref*(t, s) is the
value of the maximum flow and M is the m a x i m u m n u m b e r of arcs across a cut.
Next a new algorithm is given for the m i n i m u m - c o s t flow problem, in which all s h o r t e s t - p a t h
c o m p u t a t i o n s are performed on networks with all weights nonnegative. In particular, this
a l g o r i t h m solves the n X n assigmnent problem in O(n3) steps. Following t h a t we explore a invented in response to a class
" s c a l i n g " technique for solving a minimum-cost flow problem by t r e a t i n g a sequence of derived
problems w i t h "scaled d o w n " capacities. It is shown t h a t , using this technique, the solution of exercises by Adel’son-Vel’skiĭ
a I i i t c h c o c k t r a n s p o r t a t i o n problem w i t h m sources and n sinks, m ~ n, and m a x i m u m flow B,
requires at most (n + 2) log2 (B/n) flow a u g m e n t a t i o n s . Similar results are also given for the
41 general minimum-cost flow problem. 42
An a b s t r a c t s t a t i n g the main results of the present paper was presented at the Calgary
I n t e r n a t i o n a l Conference on C o m b i n a t o r i a l Structures and T h e i r Applications, J u n e 1969.
In a paper b y l)inic (1970) a result closely related to the main result of Section 1.2 is obtained.
Dinic shows t h a t , in a network with n nodes and p arcs, a m a x i m u m flow can be computed in
0 (n2p) primitive operations b y an algorithm which a u g m e n t s along s h o r t e s t augmenting paths.
KEY WOl¢l)S AND PHP~ASES: network flows, t r a n s p o r t a t i o n problem, analysis of algorithms
CR CATEGOI{.IES: 5.3, 5.4, 8.3
Overview. Choosing augmenting paths with “large” bottleneck capacity. Research Center, U n i v e r s i t y of California, Berkeley, CA 94720; the l a t t e r a u t h o r ' s research has
been partially s u p p o r t e d by the N a t i o n a l Science F o u n d a t i o n raider G r a n t GP-15473 with the
f
FOREACH edge e ∈ E : f (e) ← 0.
only those edges with capacity ≥ Δ.
・Any augmenting path in G f (Δ) has bottleneck capacity ≥ Δ.
Δ ← largest power of 2 ≤ C.
WHILE (Δ ≥ 1)
s s G f (Δ) ← Δ-residual network of G with respect to flow f .
WHILE (there exists an s↝t path P in G f (Δ))
f ← AUGMENT( f, c, P).
0
0
10
10
11
11
2
2
RETURN f.
12
12
17
17
2
2
__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
t t
Gf Gf (Δ), Δ = 100 43 44
Capacity-scaling algorithm: proof of correctness Capacity-scaling algorithm: analysis of running time
Assumption. All edge capacities are integers between 1 and C. Lemma 1. There are 1 + ⎣log2 C⎦ scaling phases.
Pf. Initially C / 2 < Δ ≤ C; Δ decreases by a factor of 2 in each iteration. ▪
Invariant. The scaling parameter Δ is a power of 2.
Pf. Initially a power of 2; each phase divides Δ by exactly 2. ▪ Lemma 2. Let f be the flow at the end of a Δ-scaling phase.
Then, the max-flow value ≤ val( f ) + m Δ.
Integrality invariant. Throughout the algorithm, every edge flow f (e) and Pf. Next slide.
residual capacity cf (e) is an integer.
Pf. Same as for generic Ford–Fulkerson. ▪ Lemma 3. There are ≤ 2m augmentations per scaling phase.
or equivalently,
Pf. at the end
Theorem. If capacity-scaling algorithm terminates, then f is a max flow. ・Let f be the flow at the beginning of a Δ-scaling phase. of a 2Δ-scaling phase
cap(A, B) m
edge e = (v, w) with v ∈ A, w ∈ B
must have f(e) > c(e) – Δ
47
Shortest augmenting path Shortest augmenting path: overview of analysis
Q. How to choose next augmenting path in Ford–Fulkerson? Lemma 1. The length of a shortest augmenting path never decreases.
A. Pick one that uses the fewest edges. Pf. Ahead.
number of edges
49 50
Def. Given a digraph G = (V, E) with source s, its level graph is defined by: Which edges are in the level graph of the following digraph?
・ℓ(v) = number of edges in shortest s↝v path.
・LG = (V, EG) is the subgraph of G that contains only those edges (v, w) ∈ E A. D→F.
with ℓ(w) = ℓ(v) + 1.
B. E→F.
C. Both A and B.
graph G
D. Neither A nor B.
1 3
s t
B D
level graph LG
s t source A C E F sink
ℓ= 0 ℓ= 1 ℓ= 2 ℓ= 3 51
0 1 2 3
52
Shortest augmenting path: analysis Shortest augmenting path: analysis
Def. Given a digraph G = (V, E) with source s, its level graph is defined by: Lemma 1. The length of a shortest augmenting path never decreases.
・ℓ(v) = number of edges in shortest s↝v path. ・Let f and f ʹ be flow before and after a shortest-path augmentation.
・LG = (V, EG) is the subgraph of G that contains only those edges (v, w) ∈ E ・Let LG and LG ʹ be level graphs of G f and G f ʹ .
with ℓ(w) = ℓ(v) + 1. ・Only back edges added to G f ′
(any s↝t path that uses a back edge is longer than previous length) ▪
Key property. P is a shortest s↝v path in G iff P is an s↝v path in LG. level graph LG
s t
ℓ= 0 ℓ= 1 ℓ= 2 ℓ= 3
level graph LG
level graph LG′
s t
ℓ= 0 ℓ= 1 ℓ= 2 ℓ= 3 53
s t
54
Lemma 2. After at most m shortest-path augmentations, the length of a Lemma 1. Throughout the algorithm, the length of a shortest augmenting
shortest augmenting path strictly increases. path never decreases.
・At least one (bottleneck) edge is deleted from LG per augmentation.
・No new edge added to LG until shortest path length strictly increases. ▪ Lemma 2. After at most m shortest-path augmentations, the length of a
shortest augmenting path strictly increases.
s t
ℓ= 0 ℓ= 1 ℓ= 2 ℓ= 3
s t
55 56
Shortest augmenting path: improving the running time
・Dynamic trees ⇒ O(m n log n) [Sleator–Tarjan 1983] ‣ max-flow and min-cut problems
JOURNAL OF COMPUTER AND SYSTEM SCIENCES 26, 362-391 (1983)
‣ Ford–Fulkerson algorithm
‣ max-flow min-cut theorem
A Data Structure for Dynamic Trees
1. INTR~DIJCTI~N 57
s t s t
level graph LG level graph LG
59 60
Dinitz’ algorithm Dinitz’ algorithm
augment advance
remove from level graph
edges with bottleneck capacity
s t s t
level graph LG level graph LG
61 62
retreat advance
s t s t
level graph LG level graph LG
63 64
Dinitz’ algorithm Dinitz’ algorithm
augment advance
s t s t
level graph LG level graph LG
65 66
retreat retreat
s t s t
level graph LG level graph LG
67 68
Dinitz’ algorithm Dinitz’ algorithm (as refined by Even and Itai)
LG ← level-graph of G f. IF (v = t)
P ← ∅. AUGMENT(P).
Phase of normal augmentations.
・Construct level graph LG. GOTO ADVANCE(s). Remove saturated edges from LG.
P ← ∅.
・If reach t, augment flow; update LG; and restart from s. GOTO ADVANCE(s).
・If get stuck, delete node from LG and retreat to previous node.
RETREAT(v)
_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
s t _______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
level graph LG
69 70
How to compute the level graph LG efficiently? Lemma. A phase can be implemented to run in O(m n) time.
Pf.
A. Depth-first search. ・Initialization happens once per phase. O(m) using BFS
source A C E F sink
0 1 2 3
71 72
Augmenting-path algorithms: summary Maximum-flow algorithms: theory highlights
1972 fattest path m log (mC) O(m2 log n log (mC)) 1974 blocking flows O(n3) Karzanov
1972 capacity scaling m log C O(m2 log C) fat paths 1983 dynamic trees O(m n log n) Sleator–Tarjan
1970 level graph mn O(m n2 ) shortest paths 2013 compact networks O(m n) Orlin
1983 dynamic trees mn O(m n log n ) 2014 interior-point methods Õ(m n1/2 log C) Lee–Sidford
20xx
73 max-flow algorithms with m edges, n nodes, and integer capacities between 1 and C 74
Push–relabel algorithm (SECTION 7.4). [Goldberg–Tarjan 1988] Caveat. Worst-case running time is generally not useful for predicting or
Increases flow one edge at a time instead of one augmenting path at a time. comparing max-flow algorithm performance in practice.
ANDREW V. GOLDBERG
Massachusetts Institute of Technology, Cambridge, Massachusetts
AND
On I m p l e m e n t i n g P u s h - R e l a b e l M e t h o d
ROBERT E. TARJAN for the M a x i m u m Flow P r o b l e m EUROPEAN
JOURNAL
OF OPERATIONAL
Princeton University, Princeton, New Jersey, and AT&T Bell Laboratories, Murray Hill, New Jersey Boris V. Cherkassky 1 and Andrew V. Goldberg 2 RESEARCH
ELSEVIER European Journal of Operational Research 97 (1997) 509-542
1 Central Institute for Economics and Mathematics,
Krasikova St. 32, 117418, Moscow, Russia
Abstract. All previously known efftcient maximum-flow algorithms work by finding augmenting paths, [email protected]
either one path at a time (as in the original Ford and Fulkerson algorithm) or all shortest-length 2 Computer Science Department, Stanford University Theory and Methodology
augmenting paths at once (using the layered network approach of Dinic). An alternative method based Stanford, CA 94305, USA
on the preflow concept of Karzanov is introduced. A preflow is like a flow, except that the total amount
goldberg~cs. stanford, edu Computational investigations of maximum flow algorithms
flowing into a vertex is allowed to exceed the total amount flowing out. The method maintains a preflow
Ravindra K . A h u j a a, M u r a l i K o d i a l a m b, A j a y K . M i s h r a c, J a m e s B . O r l i n d,.
in the original network and pushes local flow excess toward the sink along what are estimated to be A b s t r a c t . We study efficient implementations of the push-relabel method
shortest paths. The algorithm and its analysis are simple and intuitive, yet the algorithm runs as fast as for the maximum flow problem. The resulting codes are faster than the a Department t~'lndustrial and Management Engineering. Indian Institute of Technology. Kanpur, 208 016, India
b AT& T Bell Laboratories, Holmdel, NJ 07733, USA
any other known method on dense.graphs, achieving an O(n)) time bound on an n-vertex graph. By previous codes, and much faster on some problem families. The speedup c KA'F-ZGraduate School of Business, University of Pittsburgh, Pittsburgh, PA 15260, USA
is due to the combination of heuristics used in our implementations. We
incorporating the dynamic tree data structure of Sleator and Tarjan, we obtain a version of the algorithm also exhibit a family of problems for which the running time of all known
d Sloun School of Management, Massachusetts Institute of Technology. Cambridge. MA 02139. USA
running in O(nm log(n’/m)) time on an n-vertex, m-edge graph. This is as fast as any known method methods seem to have a roughly quadratic growth rate. Received 30 August 1995; accepted 27 June 1996
for any graph density and faster on graphs of moderate density. The algorithm also admits efticient
distributed and parallel implementations. A parallel implementation running in O(n’log n) time using 1 Introduction Abstract
n processors and O(m) space is obtained. This time bound matches that of the Shiloach-Vishkin
algorithm, which also uses n processors but requires O(n’) space. The rnaximum flow problem is a classical combinatorial problem that comes up The maximum flow algorithm is distinguished by the long line of successive contributions researchers have made in
obtaining algorithms with incrementally better worst-case complexity. Some, but not all, of these theoretical improvements
in a wide variety of applications. In this paper we study implementations of the
have produced improvements in practice. The purpose of this paper is to test some of the major algorithmic ideas developed
Categories and Subject Descriptors: F.2.2 [Analysis of Algorithms and Problem Complexity]: Non- push-rdabel [13, 17] method for the problem. in the recent years and to assess their utility on the empirical front. However, our study differs from previous studies in
75 The basic methods for the maximum flow problem include the network sim- 76
numerical Algorithms and Problems; G.2.2 [Discrete Mathematics]: Graph Theory-graph algorithms; plex method of Dantzig [6, 7], the augmenting path method of Ford and F~lker-
several ways. Whereas previous studies focus primarily on CPU time analysis, our analysis goes further and provides
detailed insight into algorithmic behavior. It not only observes how algorithms behave but also tries to explain why
network problems son [12], the blocking flow method of Dinitz [10], and the push-relabel method algorithms behave that way. We have limited our study to the best previous maximum flow algorithms and some of the
General Terms: Algorithms, Design, Theory, Verification of Goldberg and Tarjan [14, 17]. (An earlier algorithm of Cherkassky [5] has recent algorithms that are likely to be efficient in practice. Our study encompasses ten maximum flow algorithms and five
classes of networks. The augmenting path algorithms tested by us include Dinic's algorithm, the shortest augmenting path
many features of the push-relabel method.) The best theoretical time bounds
Additional Key Words and Phrases: Dynamic trees, maximum-flow problem for the maximum flow problem, based on the latter method, are as follows. An algorithm, and the capacity-scaling algorithm. The preflow-push algorithms tested by us include Karzanov's algorithm, three
implementations of Goldberg-Tarjan's algorithm, and three versions of Ahuja-Orlin-Tarjan's excess-scaling algorithms.
algorithm of Goldberg and Tarjan [17] runs in O(nm log(n2/m)) time, an algo-
Maximum-flow algorithms: practice Maximum-flow algorithms: Matlab
In IEEE Transactions on PAMI, Vol. 26, No. 9, pp. 1124-1137, Sept. 2004 p.1
After [15, 31, 19, 8, 25, 5] minimum cut/maximum flow algorithms on graphs emerged as Tanmay Verma IIIT-Delhi
an increasingly useful tool for exact or approximate energy minimization in low-level vision. [email protected] Delhi, India
The combinatorial optimization literature provides many min-cut/max-flow algorithms with
Dhruv Batra TTI-Chicago
[email protected] Chicago, USA
different polynomial time complexity. Their practical efficiency, however, has to date been
studied mainly outside the scope of computer vision. The goal of this paper is to provide an
new algorithm that we have recently developed. The algorithms we study include both Algorithms for finding the maximum amount of flow possible in a network (or max-
Goldberg-Tarjan style “push-relabel” methods and algorithms based on Ford-Fulkerson flow) play a central role in computer vision problems. We present an empirical compari-
son of different max-flow algorithms on modern problems. Our problem instances arise
style “augmenting paths”. We benchmark these algorithms on a number of typical graphs
from energy minimization problems in Object Category Segmentation, Image Deconvo-
in the contexts of image restoration, stereo, and segmentation. In many cases our new lution, Super Resolution, Texture Restoration, Character Completion and 3D Segmen-
algorithm works several times faster than any of the other methods making near real-time tation. We compare 14 different implementations and find that the most popularly used
implementation of Kolmogorov [5] is no longer the fastest algorithm available, especially
performance possible. An implementation of our max-flow/min-cut algorithm is available
for dense graphs.
upon request for research purposes.
1. Augmenting-Path (AP) variants: algorithms [5, 13, 14, 17, 21] that maintain a valid
flow during the algorithm, i.e. always satisfying the capacity and flow-conservation
constraints.
7. N ETWORK F LOW I
© 2012. The copyright of this document resides with its authors.
It may be distributed unchanged freely in print or electronic forms.
79
Network flow: quiz 7 Simple unit-capacity networks
Which max-flow algorithm to use for bipartite matching? Def. A flow network is a simple unit-capacity network if:
・Every edge has capacity 1.
A. Ford–Fulkerson: O(m n C).
・Every node (other than s or t) has exactly one entering edge, node capacity = 1
C. Shortest augmenting path: O(m2 n). Property. Let G be a simple unit-capacity network and let f be a 0–1 flow.
Then, residual network G f is also a simple unit-capacity network.
D. Dinitz’ algorithm: O(m n2).
1 1
NETWORK FLOW AND TESTING GRAPH CONNECTIVITY*
SHIMON EVEN" AND R. ENDRE TARJAN:I:
Abstract. An algorithm of Dinic for finding the maximum flow in a network is described. It is
then shown that if the vertex capacities are all equal to one, the algorithm requires at most O(IV[ 1/2 IEI)
time, and if the edge capacities are all equal to one, the algorithm requires at most O(I VI 2/3. IEI) time.
Also, these bounds are tight for Dinic’s algorithm.
These results are used to test the vertex connectivity of a graph in O(IVI 1/z. IEI 2) time and the
edge connectivity in O(I V[ 5/3. IEI) time.
Key words. Dinic’s algorithm, maximum flow, connectivity, vertex connectivity, edge connec-
tivity 82
81
1. Network flow. Let G(V, E) be a finite directed graph, where V is the set of
vertices and E is the set of edges. Each edge e is assigned.a capacity c(e) O. >=
One of the vertices, s, is called the source, and another, t, is called the sink. We seek
a flow function f(e) on the edges such that for every e, c(e) f(e) >=
0 and such >=
that the total flow which enters a vertex, other than s or t, will equal the total
Simple unit-capacity networks
flow which leaves the vertex. Of all such flows, we want one for which the net total Simple unit-capacity networks
flow which emanates from s is maximum.
This well-known network flow problem [1] was recently reexamined. A
solution in O(n 5) steps, where n is the number of vertices, was produced by Edmonds within a phase, length of shortest
Shortest-augmenting-path
and Karp [2] in 1969.algorithm.
A solution in O(I VI 2" IE]) steps was published in Russian by Phase of normal augmentations. augmenting path does not change
・ Lemma 3.reachable
Afterfrom ≤ ns1/2viaadditional
a single usable edge, where the usable direction
augmentations, flow is from
is optimal.
s to ▪
Received by the editors June 27, 1974, and in revised form November 15, 1974.
-Computer Science Department, Technion-Israel Institute of Technology, Haifa, Israel. On
leave of absence from the Department of Applied Mathematics, Weizmann Institute of Science, Rehovot,
Israel. Parts1/2
s t
Lemma 3. After ≤ n additional augmentations, flow is optimal.
of this work were completed during the summers of 1972 and 1973 while he visited the
Department of Computer Science, Cornell University, Ithaca, New York.
Pf. Each augmentation increases flow value by at least 1. ▪
Computer Science Division, University of California at Berkeley, Berkeley, California 94720.
The work of this author was supported in part by the National Science Foundation under Grant
NSF-GJ-35604X, and by a Miller Research Fellowship.
507
Lemma 1 and Lemma 2. Ahead.
level graph LG
83 84
Simple unit-capacity networks Simple unit-capacity networks
s t s t
85 86
advance retreat
s t s t
87 88
Simple unit-capacity networks Simple unit-capacity networks
advance augment
s t s t
89 90
level graph LG
91 92
Network flow: quiz 8 Simple unit-capacity networks: analysis
Consider running advance–retreat algorithm in a unit-capacity network Lemma 2. After n1/2 phases, val( f ) ≥ val( f *) – n1/2.
(but not necessarily a simple one). What is running time? ・After n1/2 phases, length of shortest augmenting path is > n1/2.
both indegree and outdegree ・Thus, level graph has ≥ n1/2 levels (not including levels for s or t).
・Let 1 ≤ h ≤ n1/2 be a level with min number of nodes ⇒ ⎢Vh ⎢ ≤ n1/2.
of a node can be larger than 1
B. O(m3/2).
C. O(m n).
level graph LG for flow f
D. May not terminate.
s t
V1 Vh Vn1/2
94
93
Lemma 2. After n1/2 phases, val( f ) ≥ val( f *) – n1/2. Theorem. [Even–Tarjan 1975] In simple unit-capacity networks,
・After n1/2 phases, length of shortest augmenting path is > n1/2. Dinitz’ algorithm computes a maximum flow in O(m n1/2) time.
・Thus, level graph has ≥ n1/2 levels (not including levels for s or t). Pf.
・Let 1 ≤ h ≤ n1/2 be a level with min number of nodes ⇒ ⎢Vh ⎢ ≤ n1/2. ・Lemma 1. Each phase takes O(m) time.
・Let A = {v : ℓ(v) < h} ∪ {v : ℓ(v) = h and v has ≤ 1 outgoing residual edge}. ・Lemma 2. After n1/2 phases, val( f ) ≥ val( f *) – n1/2.
・capf (A, B) ≤ ⎢Vh ⎢ ≤ n1/2 ⇒ val( f ) ≥ val( f *) – n1/2. ▪ ・Lemma 3. After ≤ n1/2 additional augmentations, flow is optimal. ▪
unit-capacity
simple network
residual network Gf Corollary. Dinitz’ algorithm computes max-cardinality bipartite matching
residual edges
in O(m n1/2) time.
A
s t
V1 Vh Vn1/2
95 96