Lecture slides by Kevin Wayne Copyright © 2005 PearsonAddison Wesley Copyright © 2013 Kevin Wayne
http://www.cs.princeton.edu/~wayne/kleinbergtardos
7. NETWORK FLOW I
_{‣} maxflow and mincut problems
_{‣} FordFulkerson algorithm
_{‣} maxflow mincut theorem
_{‣} capacityscaling algorithm
_{‣} shortest augmenting paths
_{‣} blockingflow algorithm
_{‣} unitcapacity simple networks
Last updated on Sep 8, 2013 6:40 AM
SECTION 7.1
7. NETWORK FLOW I
_{‣} maxflow and mincut problems
_{‣} FordFulkerson algorithm
_{‣} maxflow mincut theorem
_{‣} capacityscaling algorithm
_{‣} shortest augmenting paths
_{‣} blockingflow algorithm
_{‣} unitcapacity simple networks
Flow network
_{・} Abstraction for material flowing through the edges. _{・} Digraph G = (V, E) with source s ∈ V and sink t ∈ V. _{・} Nonnegative integer capacity c(e) for each e ∈ E.
no parallel edges no edge enters s no edge leaves t
3
Minimum cut problem
Def. A stcut (cut) is a partition (A, B) of the vertices with s ∈ A and t ∈ B.
Def. Its capacity is the sum of the capacities of the edges from A to B.
cap( A, B) =
∑ c(e)
e out of A
4
Minimum cut problem
Def. A stcut (cut) is a partition (A, B) of the vertices with s ∈ A and t ∈ B.
Def. Its capacity is the sum of the capacities of the edges from A to B.
cap( A, B) =
∑ c(e)
e out of A
don't count edges from B to A
5
Minimum cut problem
Def. A stcut (cut) is a partition (A, B) of the vertices with s ∈ A and t ∈ B.
Def. Its capacity is the sum of the capacities of the edges from A to B.
cap( A, B) =
∑ c(e)
e out of A
Mincut problem. Find a cut of minimum capacity.
6
Maximum ﬂow problem
Def. An stflow (flow) f is a function that satisfies:
_{・} For each e ∈ E :
_{・} For each v ∈ V – {s, t} :
0 ≤
∑ f (e)
f ( e ) ≤
=
c ( e )
∑ f (e)
e in to v
e out of v
[capacity]
[flow conservation]
_{f}_{l}_{o}_{w}
capacity
= 
5 + 5 + 0 
= 10 
= 
10 + 0 
= 10 
7
Maximum ﬂow problem
Def. An stflow (flow) f is a function that satisfies:
_{・} For each e ∈ E :
_{・} For each v ∈ V – {s, t} :
0 ≤ f ( e ) ≤ c ( e )
∑ f (e)
∑ f (e)
=
e in to v
e out of v
Def. The value of a flow f is: val( f ) =
∑ f (e)
e out of s
.
[capacity]
[flow conservation]
value
=
8
Maximum ﬂow problem
Def. An stflow (flow) f is a function that satisfies:
_{・} For each e ∈ E :
_{・} For each v ∈ V – {s, t} :
0 ≤ f ( e ) ≤ c ( e )
∑ f (e)
∑ f (e)
=
e in to v
e out of v
Def. The value of a flow f is: val( f ) =
∑ f (e)
e out of s
.
[capacity]
[flow conservation]
9
SECTION 7.1
7. NETWORK FLOW I
_{‣} maxflow and mincut problems _{‣} FordFulkerson algorithm
_{‣} maxflow mincut theorem
_{‣} capacityscaling algorithm
_{‣} shortest augmenting paths
_{‣} blockingflow algorithm
_{‣} unitcapacity simple networks
Towards a maxﬂow algorithm
Greedy algorithm. _{・} Start with f (e) = 0 for all edge e ∈ E. _{・} Find an s↝t path P where each edge has f (e) < c(e). _{・} Augment flow along path P. _{・} Repeat until you get stuck.
11
Towards a maxﬂow algorithm
Greedy algorithm. _{・} Start with f (e) = 0 for all edge e ∈ E. _{・} Find an s↝t path P where each edge has f (e) < c(e). _{・} Augment flow along path P. _{・} Repeat until you get stuck.
0 + 8 = 8
12
Towards a maxﬂow algorithm
Greedy algorithm. _{・} Start with f (e) = 0 for all edge e ∈ E. _{・} Find an s↝t path P where each edge has f (e) < c(e). _{・} Augment flow along path P. _{・} Repeat until you get stuck.
8 + 2 = 10
13
Towards a maxﬂow algorithm
Greedy algorithm. _{・} Start with f (e) = 0 for all edge e ∈ E. _{・} Find an s↝t path P where each edge has f (e) < c(e). _{・} Augment flow along path P. _{・} Repeat until you get stuck.
10 + 6 = 16
14
Towards a maxﬂow algorithm
Greedy algorithm. _{・} Start with f (e) = 0 for all edge e ∈ E. _{・} Find an s↝t path P where each edge has f (e) < c(e). _{・} Augment flow along path P. _{・} Repeat until you get stuck.
ending ﬂow value = 16
16
15
Towards a maxﬂow algorithm
Greedy algorithm. _{・} Start with f (e) = 0 for all edge e ∈ E. _{・} Find an s↝t path P where each edge has f (e) < c(e). _{・} Augment flow along path P. _{・} Repeat until you get stuck.
but maxﬂow value = 19
19
16
Residual graph
Original edge: e = (u, v) ∈ E. _{・} Flow f (e). _{・} Capacity c(e).
Residual edge. _{・} "Undo" flow sent. _{・} e = (u, v) and e ^{R} = (v, u). _{・} Residual capacity:
c _{f} ( e )
⎧ c ( e ) − f ( e )
= ⎨ ⎩ f ( e )
if 
e ∈ E 
if 
e ^{R} ∈ E 
original graph G
6 / 17
flow
capacity
Residual graph: G _{f} = (V, E _{f} ). _{・} Residual edges with positive residual capacity.
where flow on a reverse edge negates flow on a forward edge
_{・} E _{f} = {e : f (e) < c(e)} ∪ {e ^{R} : f (e) > 0}. _{・} Key property: f ' is a flow in G _{f} iff f + f ' is a flow in G.
17
Augmenting path
Def. An augmenting path is a simple s↝t path P in the residual graph G _{f} .
Def. The bottleneck capacity of an augmenting P is the minimum residual capacity of any edge in P.
Key property. Let f be a flow and let P be an augmenting path in G _{f} . Then f ' is a flow and val( f ' ) = val( f ) + bottleneck(G _{f} , P).
AUGMENT (f, c, P)
b ← bottleneck capacity of path P. FOREACH edge e ∈ P
IF (e ∈ E ) f (e) ← f (e)
+
b.
ELSE
RETURN f.
f (e ^{R} ) ← f (e ^{R} ) – b.
18
FordFulkerson algorithm
FordFulkerson augmenting path algorithm. _{・} Start with f (e) = 0 for all edge e ∈ E. _{・} Find an augmenting path P in the residual graph G _{f} . _{・} Augment flow along path P. _{・} Repeat until you get stuck.
FORDFULKERSON (G, s, t, c)
FOREACH edge e ∈ E : f (e) ← 0.
G _{f} ← residual graph. WHILE (there exists an augmenting path P in G _{f} ) f ← AUGMENT (f, c, P). Update G _{f} .
RETURN f.
}
19
FordFulkerson algorithm demo
20
FordFulkerson algorithm demo
network G
0 + 8 = 8
21
FordFulkerson algorithm demo
network G
8 + 2 = 10
22
FordFulkerson algorithm demo
network G
10 + 6 = 16
23
FordFulkerson algorithm demo
network G
16 + 2 = 18
24
FordFulkerson algorithm demo
network G
18 + 1 = 19
25
FordFulkerson algorithm demo
network G
26
SECTION 7.2
7. NETWORK FLOW I
_{‣} maxflow and mincut problems
_{‣} FordFulkerson algorithm _{‣} maxflow mincut theorem
_{‣} capacityscaling algorithm
_{‣} shortest augmenting paths
_{‣} blockingflow algorithm
_{‣} unitcapacity simple networks
Relationship between ﬂows and cuts
Flow value lemma. Let f be any flow and let (A, B) be any cut. Then, the net flow across (A, B) equals the value of f.
∑ f ( e ) −
e out of A
∑ f ( e ) = v( f )
e in to A
value of ﬂow = 25
28
Relationship between ﬂows and cuts
Flow value lemma. Let f be any flow and let (A, B) be any cut. Then, the net flow across (A, B) equals the value of f.
∑ f ( e )
e out of A
−
∑ f ( e )
e in to A
= v( f )
value of ﬂow = 25
29
Relationship between ﬂows and cuts
Flow value lemma. Let f be any flow and let (A, B) be any cut. Then, the net flow across (A, B) equals the value of f.
∑ f ( e ) −
e out of A
∑ f ( e )
e in to A
=
v( f )
30
Relationship between ﬂows and cuts
Weak duality. Let f be any flow and (A, B) be any cut. Then, v( f ) ≤ cap(A, B).
Pf.
lemma
∑ f ( e ) −
e out of A
∑ f ( e )
e out of A
∑ f ( e )
e in to A
≤ 
∑ 
c ( e ) 

e out of A 

= 
cap( A , B ) 
_{▪} 
≤
32
Maxﬂow mincut theorem
Augmenting path theorem. A flow f is a maxflow iff no augmenting paths. Maxflow mincut theorem. Value of the maxflow = capacity of mincut.
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 ).
ii. f is a maxflow.
iii. There is no augmenting path with respect to f.
[
i ii ]
_{・} Suppose that (A, B) is a cut such that cap(A, B) = val(f ).
_{・} Then, for any flow f ', val(f ')
_{・} Thus,
≤ cap(A, B)
= val(f ).
f is a maxflow. ▪
_{w}_{e}_{a}_{k} _{d}_{u}_{a}_{l}_{i}_{t}_{y}
by assumption
33
Maxﬂow mincut theorem
Augmenting path theorem. A flow f is a maxflow iff no augmenting paths. Maxflow mincut theorem. Value of the maxflow = capacity of mincut.
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 ).
ii. f is a maxflow.
iii. There is no augmenting path with respect to f.
[ ii iii ]
We prove contrapositive: ~ iii ~ ii.
_{・} Suppose that there is an augmenting path with respect to f. _{・} Can improve flow f by sending flow along this path.
_{・} Thus, f is not a maxflow.
▪
34
Maxﬂow mincut theorem
[ iii i ] _{・} Let f be a flow with no augmenting paths. _{・} Let A be set of nodes reachable from s in residual graph G _{f} . _{・} By definition of cut A, s ∈ A. _{・} By definition of flow f, t ∉ A.
edge e = (v, w) with v ∈ B, w ∈ A must have f(e) = 0
v( f )
flowvalue
lemma
=
=
∑ f ( e ) −
e out of A
∑ c( e )
e out of A
= cap( A, B )
∑ f ( e )
e in to A
edge e = (v, w) with v ∈ A, w ∈ B must have f(e) = c(e)
35
SECTION 7.3
7. NETWORK FLOW I
_{‣} maxflow and mincut problems
_{‣} FordFulkerson algorithm
_{‣} maxflow mincut theorem _{‣} capacityscaling algorithm
_{‣} shortest augmenting paths
_{‣} blockingflow algorithm
_{‣} unitcapacity simple networks
Running time
Assumption. Capacities are integers between 1 and C.
Integrality invariant. Throughout the algorithm, the flow values f (e) and the residual capacities c _{f} (e) are integers.
Theorem. The algorithm terminates in at most val (f *) ≤ n C iterations.
Pf. Each augmentation increases the value by at least 1.
▪
Corollary. The running time of FordFulkerson is O(m n C). Corollary. If C = 1, the running time of FordFulkerson is O(m n).
Integrality theorem. Then exists a maxflow f * for which every flow value f * (e) is an integer. Pf. Since algorithm terminates, theorem follows from invariant.
▪
37
Bad case for FordFulkerson
Q. Is generic FordFulkerson algorithm polytime in input size?
m, n, and log C
A. No. If max capacity is C, then algorithm can take ≥ C iterations.
_{・} s →v→w→t
_{・} s →w→v→t
_{・} s →v→w→t
_{・} s →w→v→t
・ …
_{・} s →v→w→t
_{・} s →w→v→t
each augmenting path sends only 1 unit of flow (# augmenting paths = 2C)
38
Choosing good augmenting paths
Use care when selecting augmenting paths. _{・} Some choices lead to exponential algorithms. _{・} Clever choices lead to polynomial algorithms. _{・} If capacities are irrational, algorithm not guaranteed to terminate!
Goal. Choose augmenting paths so that:
_{・} Can find augmenting paths efficiently. _{・} Few iterations.
39
Choosing good augmenting paths
Choose augmenting paths with:
_{・} Max bottleneck capacity. _{・} Sufficiently large bottleneck capacity. _{・} Fewest number of edges.
EdmondsKarp 1972 (USA)
Dinic 1970 (Soviet Union)
40
Capacityscaling algorithm
Intuition. Choose augmenting path with highest bottleneck capacity:
it increases flow by max possible amount in given iteration. _{・} Don't worry about finding exact highest bottleneck path. _{・} Maintain scaling parameter Δ . _{・} Let G _{f} ( Δ ) be the subgraph of the residual graph consisting only of arcs with capacity ≥ Δ .
G f
41
Capacityscaling algorithm
CAPACITYSCALING(G, s, t, c)
FOREACH edge e ∈ E : f (e) ← 0.
Δ ← largest power of 2 ≤ C.
WHILE ( Δ ≥ 1) G _{f} ( Δ ) ← Δ residual graph. WHILE (there exists an augmenting path P in G _{f} ( Δ )) f ← AUGMENT (f, c, P). Update G _{f} ( Δ ). Δ ← Δ / 2.
RETURN f.
42
Capacityscaling algorithm: proof of correctness
Assumption. All edge capacities are integers between 1 and C.
Integrality invariant. All flow and residual capacity values are integral.
Theorem. If capacityscaling algorithm terminates, then f is a maxflow. Pf. _{・} By integrality invariant, when Δ = 1 ⇒ G _{f} ( Δ ) = G _{f} . _{・} Upon termination of Δ = 1 phase, there are no augmenting paths. ▪
43
Capacityscaling algorithm: analysis of running time
Lemma 1. The outer while loop repeats 1 + ⎡log _{2} C⎤ times. Pf. Initially C / 2 < Δ ≤ C; Δ decreases by a factor of 2 in each iteration. ▪
Lemma 2. Let f be the flow at the end of a Δ scaling phase. Then,
the value of the maxflow ≤ val( f ) + m Δ .
proof on next slide
Lemma 3. There are at most 2m augmentations per scaling phase. Pf. _{・} Let f be the flow at the end of the previous scaling phase. _{・} LEMMA 2 ⇒ val( f *) ≤ val( f ) + 2 m Δ . _{・} Each augmentation in a Δ phase increases val( f ) by at least Δ . ▪
Theorem. The scaling maxflow algorithm finds a max flow in O(m log C) augmentations. It can be implemented to run in O(m 2 log C) time. Pf. Follows from LEMMA 1 and LEMMA 3. ▪
44
Capacityscaling algorithm: analysis of running time
Lemma 2. Let f be the flow at the end of a Δ scaling phase. Then, the value of the maxflow ≤ val( f ) + m Δ . Pf.
_{・} We show there exists a cut (A, B) such that cap(A, B) ≤ val( f ) + m Δ . _{・} Choose A to be the set of nodes reachable from s in G _{f} ( Δ ). _{・} By definition of cut A, s ∈ A.
_{・} By definition of flow f, t ∉ A.
edge e = (v, w) with v ∈ B, w ∈ A must have f(e) ≤ Δ
val( f ) 
_{=} 
∑ 
_{f} _{(} _{e} _{)} 
− 
∑ f ( e ) 

e out of A 
e in to A 

≥ 
∑ 
( c( e ) − Δ ) − 
∑ 
Δ 

e out of A 
e in to A 

= 
∑ 
c ( e ) − 
∑ Δ 
− 
∑ 
Δ 

e out of A 
e out of A 
e in to A 

≥ 
cap(A, B)  m Δ 
edge e = (v, w) with v ∈ A, w ∈ B must have f(e) ≥ c(e) – Δ
45
SECTION 17.2
7. NETWORK FLOW I
_{‣} maxflow and mincut problems
_{‣} FordFulkerson algorithm
_{‣} maxflow mincut theorem
_{‣} capacityscaling algorithm _{‣} shortest augmenting paths
_{‣} blockingflow algorithm
_{‣} unitcapacity simple networks
Shortest augmenting path
Q. Which augmenting path?
A. The one with the fewest number of edges.
can find via BFS
SHORTESTAUGMENTINGPATH(G, s, t, c)
FOREACH e ∈ E : f (e) ← 0.
G _{f} ← residual graph. WHILE (there exists an augmenting path in G _{f} ) P ← BREADTHFIRSTSEARCH (G _{f} , s, t). f ← AUGMENT (f, c, P). Update G _{f} .
RETURN f.
47
Shortest augmenting path: overview of analysis
L1. Throughout the algorithm, length of the shortest path never decreases.
L2.
augmenting path strictly increases.
After at most m shortest path augmentations, the length of the shortest
Theorem. The shortest augmenting path algorithm runs in O(m ^{2} n) time. Pf. _{・} O(m + n) time to find shortest augmenting path via BFS. _{・} O(m) augmentations for paths of length k. _{・} If there is an augmenting path, there is a simple one.
⇒ 
1 
≤ k 
< 
n 
⇒ 
O(m n) augmentations. ▪ 
48
Shortest augmenting path: analysis
Def. Given a digraph G = (V, E) with source s, its level graph is defined by:
_{・} ℓ(v) = number of edges in shortest path from s to v. _{・} L _{G} = (V, E _{G} ) is the subgraph of G that contains only those edges (v,w) ∈ E with ℓ(w) = ℓ(v) + 1.
49
Shortest augmenting path: analysis
Def. Given a digraph G = (V, E) with source s, its level graph is defined by:
_{・} ℓ(v) = number of edges in shortest path from s to v. _{・} L _{G} = (V, E _{G} ) is the subgraph of G that contains only those edges (v,w) ∈ E with ℓ(w) = ℓ(v) + 1.
Property. Can compute level graph in O(m + n) time. Pf. Run BFS; delete back and side edges.
Key property. P is a shortest s↝v path in G iff P is an s↝v path L _{G} .
50
Shortest augmenting path: analysis
L1. Throughout the algorithm, length of the shortest path never decreases. _{・} Let f and f ' be flow before and after a shortest path augmentation. _{・} Let L and L ' be level graphs of G _{f} and G _{f} _{'} . _{・} Only back edges added to G _{f} _{'} (any path with a back edge is longer than previous length) ▪
51
Shortest augmenting path: analysis
L2.
augmenting path strictly increases. _{・} The bottleneck edge(s) is deleted from L after each augmentation. _{・} No new edge added to L until length of shortest path strictly increases. ▪
After at most m shortest path augmentations, the length of the shortest
52
Shortest augmenting path: review of analysis
L1. Throughout the algorithm, length of the shortest path never decreases.
L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases.
Theorem. The shortest augmenting path algorithm runs in O(m ^{2} n) time. Pf. _{・} O(m + n) time to find shortest augmenting path via BFS. _{・} O(m) augmentations for paths of exactly k edges. _{・} O(m n) augmentations. ▪
53
Shortest augmenting path: improving the running time
Note. Θ (m n) augmentations necessary on some networks. _{・} Try to decrease time per augmentation instead. _{・} Simple idea ⇒ O(m n 2 ) [Dinic 1970] _{・} Dynamic trees ⇒ O(m n log n) [SleatorTarjan 1983]
54
SECTION 18.1
7. NETWORK FLOW I
_{‣} maxflow and mincut problems
_{‣} FordFulkerson algorithm
_{‣} maxflow mincut theorem
_{‣} capacityscaling algorithm
_{‣} shortest augmenting paths _{‣} blockingflow algorithm
_{‣} unitcapacity simple networks
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
level graph L _{G}
56
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
advance
level graph L _{G}
57
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
augment
level graph L _{G}
58
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
advance
level graph L _{G}
59
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
retreat
level graph L _{G}
60
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
advance
level graph L _{G}
61
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
augment
level graph L _{G}
62
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
advance
level graph L _{G}
63
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
retreat
level graph L _{G}
64
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
retreat
level graph L _{G}
65
Blockingﬂow algorithm
Two types of augmentations. _{・} Normal: length of shortest path does not change. _{・} Special: length of shortest path strictly increases.
Phase of normal augmentations. _{・} Explicitly maintain level graph L _{G} . _{・} Start at s, advance along an edge in L _{G} until reach t or get stuck. _{・} If reach t, augment and and update L _{G} . _{・} If get stuck, delete node from L _{G} and go to previous node.
end of phase
level graph L _{G}
66
Blockingﬂow algorithm
INITIALIZE(G, s, t, f, c)
L _{G} ← levelgraph of G _{f} .
P ← ∅ .
GOTO ADVANCE(s).
RETREAT(v)
IF
(v = s) STOP.
ELSE
Delete v (and all incident edges) from L _{G} . Remove last edge (u, v) from P.
GOTO ADVANCE(u).
ADVANCE(v)
IF
(v = t)
AUGMENT(P).
Remove saturated edges from L _{G} .
P ← ∅ .
GOTO ADVANCE(s).
IF (there exists edge (v, w) ∈ L _{G} )
Add edge (v, w) to P.
GOTO ADVANCE(w).
ELSE GOTO RETREAT(v).
67
Blockingﬂow algorithm: analysis
Lemma. A phase can be implemented in O(m n) time. Pf.
_{・} Initialization happens once per phase. _{・} At most m augmentations per phase.
O(m) using BFS
O(mn) per phase
(because an augmentation deletes at least one edge from L _{G} )
_{・} At most n retreats per phase. (because a retreat deletes one node from L _{G} ) _{・} At most m n advances per phase.
O(m + n) per phase
O(mn) per phase
(because at most n advances before retreat or augmentation) ▪
Theorem. [Dinic 1970] The blockingflow algorithm runs in O(mn 2 ) time. Pf. _{・} By lemma, O(mn) time per phase. _{・} At most n phases (as in shortest augment path analysis).
▪
68
Choosing good augmenting paths: summary
Assumption. Integer capacities between 1 and C.
method 
# augmentations 
running time 

augmenting path 
n C 
O(m n C) 

fattest augmenting path 
m log (mC) 
O(m 2 log n log (mC)) 

capacity scaling 
m 
log C 
O(m 2 log C) 

improved capacity scaling 
m 
log C 
O(m n log C) 

shortest augmenting path 

Bien plus que des documents.
Découvrez tout ce que Scribd a à offrir, dont les livres et les livres audio des principaux éditeurs.
Annulez à tout moment.