0% found this document useful (0 votes)
3 views44 pages

Maxflow

The document discusses the Maximum Flow Problem in directed graphs, detailing the input requirements, goal of computing maximal flow, and the constraints involved. It introduces key concepts such as cuts, the residual network, and the Max-Flow-Min-Cut Theorem, along with algorithms like Ford-Fulkerson and Dinic's Algorithm for solving the problem. Additionally, it covers the integrality of flows and applications in bipartite matching.

Uploaded by

Mëłły Lîlï
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views44 pages

Maxflow

The document discusses the Maximum Flow Problem in directed graphs, detailing the input requirements, goal of computing maximal flow, and the constraints involved. It introduces key concepts such as cuts, the residual network, and the Max-Flow-Min-Cut Theorem, along with algorithms like Ford-Fulkerson and Dinic's Algorithm for solving the problem. Additionally, it covers the integrality of flows and applications in bipartite matching.

Uploaded by

Mëłły Lîlï
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

PI Informatik

The Maximum Flow Problem Kurt Mehlhorn

nput: • a directed graph G = (V, E), source node s ∈ V , sink node t ∈ V


• edge capacities cap : E → IR≥0

1/0 1/1
s 1/1 t

2/2 2/1

Goal: • compute a flow of maximal value, i.e.,


• a function f : E → IR≥0 satisfying the capacity constraints and the
flow conservation constraints

(1) 0 ≤ f (e) ≤ cap(e) for every edge e ∈ E


P P
(2) f (e) = f (e) for every node v ∈ V \{s, t}
e;target(e)=v e;source(e)=v

• and maximizing the net flow


1
into t.
PI Informatik
Further Reading Kurt Mehlhorn

he main sources for the lectures are the books [8, 1, 9]. The original
ublications on the preflow-push algorithm are [6, 2]. [5] describes the currently
est flow algorithm for integral capacities. Papers by the instructors are [3, 7, 4].

R.K. Ahuja, T.L. Magnanti, and J.B. Orlin. Network Flows. Prentice Hall, 1993.
R.K. Ahuja and J.B. Orlin. A fast and simple algorithm for the maximum flow problem.
Operation Research, 37:748–759, 1989.
J. Cheriyan, T. Hagerup, and K. Mehlhorn. An o(n3 )-time maximum flow algorithm. SIAM
Journal of Computing, 25(6):1144–1170, 1996.
J. Cheriyan and K. Mehlhorn. An analysis of the highest-level selection rule in the
preflow-push max-flow algorithm. IPL, 69:239–242, 1999.
www.mpi-sb.mpg.de/~mehlhorn/ftp/maxflow.ps.
A.V. Goldberg and S. Rao. Beyond the flow decomposition barrier. JACM, 45(5), 1998.
A.V. Goldberg and R.E. Tarjan. A new approach to the maximum-flow problem. Journal of
the ACM, 35:921–940, 1988.
T. Hagerup, P. Sanders, and J. Träff. An implementation of the binary blocking flow
algorithm. In Proceedings of the 2nd Workshop on Algorithm Engineering (WAE’98), pages
143–154. Max-Planck-Institut für Informatik, 1998.
K. Mehlhorn. Data Structures and Algorithms. Springer, 1984.
K. Mehlhorn and S. Näher. The LEDA Platform for Combinatorial and Geometric
2
Computing. Cambridge University Press, 1999. 1018 pages.
PI Informatik
Some Notation and First Properties Kurt Mehlhorn

P P
• the excess of a node v: excess(v) = f (e) − f (e)
e;target(e)=v e;source(e)=v

• in a flow: all nodes except s and t have excess zero.


• the value of a flow = val (f ) = excess(t)

learly: the net flow into t is equal to the next flow out of s.
emma 1 excess(t) = −excess(s)
he proof is short and illustrates an important technique
X
excess(s) + excess(t) = excess(v) = 0
v∈V

• the first equality holds since excess(v) = 0 for v 6= s, t.


• the second equality holds since the flow across any edge e = (v, w) appears
twice in this sum
– positively in excess(w) and negatively in excess(v)
3
PI Informatik
Cuts Kurt Mehlhorn

• a subset S of the nodes is called a cut. Let T = V \ S


• S is called an (s, t)-cut if s ∈ S and t ∈ T .
• the capacity of a cut is the total capacity of the edges leaving the cut,
X
cap(S) = cap(e).
e∈E∩(S×T )

• a cut S is called saturated if f (e) = cap(e) for all e ∈ E ∩ (S × T ) and


f (e) = 0 for all e ∈ E ∩ (T × S).

1/1 1/1
1/0 1/1 s t
s 1/1 t 1/0

2/2 2/1 2/2 2/2

4
PI Informatik
Cuts and Flows Kurt Mehlhorn

emma 2 For any flow f and any (s, t)-cut


• val (f ) ≤ cap(S).
• if S is saturated, val (f ) = cap(S).
roof: We have
X
val (f ) = −excess(s) = − excess(u)
u∈S
X X X
= f (e) − f (e) ≤ cap(e)
e∈E∩(S×T ) e∈E∩(T ×S) e∈E∩(S×T )

= cap(S).

or a saturated cut, the inequality is an equality.

Remarks:
• A saturated cut proves the optimality of a flow.
• For every maximal flow there is a 5saturated cut proving its optimality (=⇒)
PI Informatik
The Residual Network Kurt Mehlhorn

• let f be a flow in G = (V, E)


• the residual network Gf captures possible changes to f
– same node set as G
– for every edge e = (v, w) up to two edges e0 and e00 in Gf
∗ if cap(e) < f (e), we have an edge e0 = (v, w) ∈ Gf
residual capacity r(e0 ) = cap(e) − f (e).
∗ if f (e) > 0, we have an edge e00 = (w, v) ∈ Gf
residual capacity r(e00 ) = f (e).
• two flows and the corresponding residual networks

1/1 1/1
1/0 1/1 s t
s 1/1 t 1/0

2/2 2/1 2/2 2/2

6
PI Informatik
Maximum Flows and the Residual Graph Kurt Mehlhorn

heorem 1 (Maximum Flows and the Residual Graph) Let f be an


s, t)-flow, let Gf be the residual network with respect to f , and let S be the set of
odes that are reachable from s in Gf .
) If t ∈ S then f is not maximum.
) If t ∈
/ S then S is a saturated cut and f is maximum.

2/1 2/2 2 2/2 2/2


1/1 1 1/0 t
s t s 1 t s
1
2/2 2/1 2 1 2/2 2/2

G Gf G
An illustration of part a)

7
Maximum Flows and the Residual Graph: PartKurta Mehlhorn
PI Informatik

t is reachable from s in Gf , f is not maximal


• Let p be any simple path from s to t in Gf
• Let δ be the minimum residual capacity of any edge of p. Then δ > 0.
• We construct a flow f 0 of value val (f ) + δ. Let (see Figure on preceding slide)


 f (e) + δ if e 0
is in p

f 0 (e) = f (e) − δ if e00 is in p



f (e) if neither e0 nor e00 belongs to p.

• f 0 is a flow and val (f 0 ) = val (f ) + δ.

a path in Gf : s −→ v1 −→ v2 −→ v3 −→ v4 −→ v5 −→ t

the corresponding path in G:

8
Maximum Flows and the Residual Graph: PartKurt
PI Informatik
b Mehlhorn
t cannot be reached from s in Gf , f is maximal.
• Let S be the set of nodes reachable from s and let T = V \ S.
• There is no edge (v, w) in Gf with v ∈ S and w ∈ T .
• Hence
– f (e) = cap(e) for any e with e ∈ E ∩ (S × T ) and
– f (e) = 0 for any e with e ∈ E ∩ (T × S)
• Thus S is saturated and f is maximal.

Gf G
9
PI Informatik
Max-Flow-Min-Cut Theorem Kurt Mehlhorn

heorem 2 (Max-Flow-Min-Cut Theorem)

max {val (f ) ; f is a flow} = min {cap(S) ; S is an (s, t)-cut}

roof:
• ≤ is the content of Lemma 2, part (a).
• let f be a maximum flow
– then there is no path from s to t in Gf and
– the set S of nodes reachable from s form a saturated cut
– hence val (f ) = cap(S) by Lemma 2, part (b).

theorem of the form above is called a duality theorem.


10
PI Informatik
The Ford-Fulkerson Algorithm Kurt Mehlhorn

• start with the zero flow, i.e., f (e) = 0 for all e.


• construct the residual network Gf
• check whether t is reachable from s.
– if not, stop
– if yes, increase flow along an augmenting path, and iterate

• each iteration takes time O(n + m)


• if capacities are arbitrary reals, the algorithm may run forever
• it does well in the case of integer capacities

11
PI Informatik
Integrality Theorem Kurt Mehlhorn

• assume integral capacities, say in [0 .. C]


• let v ∗ = value of the maximum flow ≤ deg(s) · C ≤ nC
• Claim: all flows constructed are integral (and hence final flow is integral)
Proof: We use induction on the number of iterations.
– the initial flow (= all-zero-flow) is integral.
– if current flow is integral, residual capacities are integral and hence next
flow is integral
• every augmentation increases flow value by at least one
• running time is O((n + m)v ∗ ); this is good if v ∗ is small

heorem 3 If edge capacities are integral, there exists an integral maximal flow.
Moreover, the algorithm of Ford and Fulkerson finds it in time O((n + m)v ∗ ),
here v ∗ is the value of the maximum flow.

12
PI Informatik
Bipartite Matching Kurt Mehlhorn

• given a bipartite graph G = (A ∪ B, E), find a maximal matching


• matching M , a subset of the edges, no two of which share an endpoint
• reduces easily to network flow
– add a source s, edges (s, a) for a ∈ A, capacity one
– add a sink t, edges (b, t) for b ∈ B, capacity one
– direct edges in G from A to B, capacity +∞
– integral flows correspond to matchings

– Ford-Fulkerson takes time O(nm) since v ∗ ≤ n, can be improved to O( nm)

0 4 0 4

1 5 1 5

2 6 2 6

3 7 3 7
13
PI Informatik
The Theorem of Hall Kurt Mehlhorn

heorem 4 A bipartite graph G = (A ∪ B, E) has an A-perfect matching (= a


matching of size |A|) iff for every subset A0 ⊂ A, |Γ(A0 )| ≥ |A0 |, where Γ(A0 ) is
he set of neighbors of the nodes in A0 .
ondition is clearly necessary; we need to show sufficiency
• assume that there is no A-perfect matching
• then flow in the graph defined on preceding slide is less than |A|
• and hence minimum cut has capacity less than |A|.
• consider a minimum (s, t)-cut (S, T ).
• let A0 = A ∩ S, A00 = A ∩ T , B 0 = B ∩ S, B 00 = B ∩ T

• no (!!!) edge from A0 to B 00 and hence Γ(A0 ) ⊆ B 0


• flow = |B 0 | + |A00 | < |A| = |A0 | + |A00 |
• thus |B 0 | < |A0 | 14
A Theoretical Improvement for Integral Capacities

• modify Ford-Fulkerson by always augmenting along a flow of maximal


residual capacity
• Theorem 5 running time becomes: T = O((m + m logdv ∗ /me)m log m)
• i.e., v ∗ -term in time bound is essentially replaced by m log v ∗ log m;
this is good for large v ∗ (namely, if v ∗ ≥ m log v ∗ log m)
• practical value is minor (since we will see even better methods later),
but proof method is interesting
• Lemma 3 Max-res-cap-path can be determined in time O(m log m).
• Lemma 4 O(m + m logdv ∗ /me) augmentations suffice

15
emma 5 Max-res-cap-path can be determined in time O(m log m).
• sort the edges of Gf in decreasing order of residual capacity
• let e1 , e2 , . . . , em0 be the sorted list of edges
• want to find the minimal i such that {e1 , . . . , ei } contains a path from s to t
• for fixed i we can test existence of path in time O(n + m)
• determine i by binary search in O(log m) rounds.

16
emma 6 O(m + m logdv ∗ /me) augmentations suffice
• a flow can be decomposed into at most m paths
– start with a maximal flow f
– repeatedly construct a path from s to t, saturate it, and subtract from f
• augmentation along max-res-cap-path increases flow by at least 1/m of dist
to v ∗

• let gi be the diff between v ∗ and the flow value after the i-th iteration
• g0 = v ∗
• if gi > 0, gi+1 ≤ gi − max(1, gi /m) ≤ min(gi − 1, (1 − 1/m)gi )
• gi ≤ ( m−1
m )i
g0 and hence gi ≤ m if i is such that ( m ) g0 ≤ m.
m−1 i

∗ log(v ∗ /m)
• this is the case if i ≥ logm/(m−1) (v /m) = log m/(m−1)

• log(m/(m − 1)) = log(1 + 1/(m − 1)) ≥ 1/(2m) for m ≥ 10


• number of iterations ≤ m + 2m log(v ∗ /m)

17
Dinic’s Algorithm (1970), General Capacities

• start with the zero flow f


• construct the layered subgraph Lf of Gf
• if t is not reachable from s, stop
• construct a blocking flow fb in Lf and augment to f , repeat

• in Lf nodes are on layers according to their BFS-distance from s and only


edges going from layer i to layer i + 1 are retained
• Lf is constructed in time O(m) by BFS
• blocking flow: a flow which saturates one edge on every path from s to t

• the number of rounds is at most n, since the depth of Lf grows in each round
(without proof, but see analysis of # of saturating pushes in preflow-push alg)
• a blocking flow can be computed in time O(nm)
• T = O(n2 m) 18
PI Informatik
An Example Run of Dinic’s Algorithm Kurt Mehlhorn

will illustrate the sequence of residual graphs and residual level graphs.

1 2
1
0 1
1 1
3 3
4
2

1 1
5

19
PI Informatik
The Computation of Blocking Flows Kurt Mehlhorn

• maintain a path p starting at s, initially p = ², let v = tail (p)


• if v = t, increase fb by saturating p, remove saturated edges, set p to the
empty path (breakthrough)
• if v = s and v has no outgoing edge, stop
• if v 6= t and v has an outgoing edge, extend p by one edge
• if v 6= t and v has no outgoing edge, retreat by removing last edge from p.

• running time is #extends + #retreats + n · #breakthroughs


• #breakthroughs ≤ m, since at least one edge is saturated
• #retreats ≤ m, since one edge is removed
• #extends ≤ #retreats + n · #breakthroughs , since a retreat cancels one extend
and a breakthrough cancels n extends
• running time is O(m + nm) = O(nm)
20
PI Informatik
Preflow-Push Algorithms Kurt Mehlhorn

• f is a preflow (Karzanov (74)): excess(v) ≥ 0 for all v 6= s, t


• residual network with respect to a preflow is defined as for flows
• Idea: preflows give additional flexibility

s v t

• manipulate a preflow by operation push(e, δ)


– Preconditions:
∗ e is residual, i.e., e = (v, w) ∈ Ef
∗ v has excess, i.e, excess(v) > 0
∗ δ is feasible, i.e, δ ≤ min(excess(v), res f (e))
– Action: push δ units of flow from v to w
∗ decrease excess(v) by δ, increase excess(w) by δ, modify f and adapt
Ef (remove e if it now saturated, add its reversal)
• Question: Which push to make?
21
• Answer: push towards t, but what does this mean?
PI Informatik Kurt Mehlhorn
The Level Function (Goldberg/Tarjan)

• a simple and highly effective notion of “towards t”


• arrange the nodes on levels, d(v) = level number of v ∈ IN
• at all times: d(t) = 0, d(s) = n
• call an edge e = (v, w) eligible iff e ∈ Ef and d(w) < d(v)
• and only push across eligible edges, i.e., from higher to lower level

Question: What to do when v has positive excess but no outgoing eligible edge?
Answer: lift it up, i.e., increase d(v) by one (relabel v)

22
PI Informatik
The Generic Push-Relabel Algorithm Kurt Mehlhorn

et f (e) = cap(e) for all edges with source(e) = s;


et f (e) = 0 for all other edges;
et d(s) = n and d(v) = 0 for all other nodes;
while there is a node v 6= s, t with positive excess
let v be any such node node;
if there is an eligible edge e = (v, w) in Gf
{ push δ across e for some δ ≤ min(excess(v), res cap(e)); }
else
{ relabel v; }

• obvious choice for δ: δ = min(excess(v), res cap(e))


• push with δ = res cap(e) saturating push
• push with δ < res cap(e) non-saturating push
• need to bound the number of relabels, the number of pushes, need to explain
23
how to find nodes with positive excess and eligible edges
PI Informatik
A Sample Run Kurt Mehlhorn

s a t
2 1

nd here comes the sequence of residual graphs (residual capacities are shown)

24
PI Informatik
No Steep Edges Kurt Mehlhorn

n edge e = (v, w) ∈ Gf is called steep if d(w) < d(v) − 1, i.e., if it reaches down
y two or more levels.
emma 7 The algorithm maintains a preflow and does not generate steep edges.
he nodes s and t stay on levels 0 and n, respectively.
roof:
• the algorithm maintains a preflow by the restriction on δ

• after initialization: edges in Gf go sidewards or upwards


• when v is relabeled, no edge in Gf out of v goes down. After relabeling,
edges out of v go down at most one level.
• a push across an edge e = (v, w) ∈ Gf may add the edge (w, v) to Gf . This
edge goes up.

• s and t are never relabeled

25
PI Informatik
The Maximum Level Stays Below 2n Kurt Mehlhorn

emma 8 If v is active then there is a path from v to s in Gf . No distance label


ver reaches 2n.
roof: Let S be the set of nodes that are reachable from v in Gf and let
= V \S. Then
X X X
excess(u) = f (e) − f (e),
u∈S e∈E∩(T ×S) e∈E∩(S×T )

here is no edge (v, w) ∈ Gf with v ∈ S and w ∈


/ S. Thus, f (e) = 0 for every
P
∈ E ∩ (T × S). We conclude u∈S excess(v) ≤ 0.
ince s is the only node whose excess may be negative and since excess(v) > 0 we
must have s ∈ S.
ssume that a node v is moved to level 2n. Since only active nodes are relabeled
his implies the existence of a path (and hence simple path) in Gf from a node on
vel 2n to s (which is on level n). Such a path must contain a steep edge.

26
PI Informatik
Partial Correctness Kurt Mehlhorn

heorem 6 When the algorithm terminates, it terminates with a maximum flow.


roof: When the algorithm terminates, all nodes different from s and t have
xcess zero and hence the algorithm terminates with a flow. Call it f .
n Gf there can be no path from s to t since any such path must contain a steep
dge (since s is on level n, t is on level 0). Thus, f is a maximum flow by the
max-flow-min-cut theorem.

n order to prove termination, we bound the number of relabels, the number of


aturating pushes and the number of non-saturating pushes.
he former two quantities are easily bounded.
We have to work harder for the number of non-saturating pushes.

27
On the Number of Relabels and Saturating Pushes
PI Informatik Kurt Mehlhorn

emma 9 There are at most 2n2 relabels and at most nm saturating pushes.
roof:
• no distance label ever reaches 2n.
• therefore, each node is relabeled at most 2n times
• the number of relabels is therefore at most 2n2 .

• a saturating push across an edge e = (v, w) ∈ Gf removes e from Gf .


• Claim: v has to be relabeled at least twice before the next push across e and
hence there can be at most n saturating pushes across any edge.
– only a push across erev can again add e to Gf .
– for this to happen w must be lifted by two levels, . . .

28
On the Number of Non-Saturating Pushes: Scaling
PI Informatik Kurt Mehlhorn

* scaling push-relabel algorithm (Ahuja-Orlin) for integral capacities */


et f (e) = cap(e) for all edges with source(e) = s and f (e) = 0 for all other edges;
et d(s) = n and d(v) = 0 for all other nodes;
et ∆ = 2dlog maxe cap(e)e ;
while ( ∆ > 1 )
while there is a node v 6= s, t with excess(v) ≥ ∆/2
{ let v be the lowest (!!!) such node;
if there is an eligible edge e = (v, w) in Gf
{ push δ across e for δ = min(∆/2, res cap(e)); }
else
{ relabel v; }
}
∆ = ∆/2;

• excesses are bounded by ∆, i.e., at all times and for all v 6= t: excess(v) ≤ ∆
• a non-saturating push moves ∆/2 29units of flow
On the Number of Non-Sat Pushes in Ahuja-Orlin
PI Informatik Kurt Mehlhorn

emma 10 The number of non-saturating pushes is at most 4n2 + 4n2 dlog U e,


here U is the largest capacity
We use a potential function argument (let V 0 = V \ {s, t})
X excess(v)
Φ= d(v)

v∈V 0

• Φ ≥ 0 always, Φ = 0 initially
• total decrease of Φ ≤ total increase of Φ
• a relabel increases Φ by at most one
• every push decreases Φ
• a non-saturating push decreases Φ by 1/2
• a change of ∆ increases Φ by at most 2n2
• ∆ is changed dlog U e times
• (1/2)#non sat pushes ≤ total decrease
30 ≤ total increase ≤ 2n2 + 2n2 dlog U e
PI Informatik
Maintaining the Set of High Excess Nodes Kurt Mehlhorn

• we have 2n buckets, one for each level


• the i-the bucket Bi contains all nodes v with d(v) = i and excess(v) ≥ ∆/2
• at the beginning of a ∆-phase: initialize buckets by a scan over all nodes
• maintain a index i∗ , buckets Bi with i < i∗ are empty
• search for a high excess node: advance i∗ until a non-empty bucket is found
• pushes may require to decrease i∗ by one
• summary: total number of changes of i∗ ≤ 2n + number of pushes

31
PI Informatik
The Search for Eligible Edges Kurt Mehlhorn

• every node v stores the list of all edges (out and in) incident to it
• every node stores its height
• every edge stores its capacity and the current flow across it
• an out-edge e = (v, w) is eligible for pushing out of v iff f (e) < cap(e) and
d(w) < d(v)
• an in-edge e = (w, v) is eligible for pushing out of v iff f (e) > 0 and
d(w) < d(v)
• L 11 An edge can become eligible for pushing out of v only by a relabel of v
– consider a non-eligible out-edge e = (v, w), i.e., either d(w) ≥ d(v) or
f (e) = cap(e).
– the latter condition can only be changed by a push across the reversal of e.
– such a push is only possible if d(w) > d(v). Hence e cannot be eligible
after the push.

32
PI Informatik
The Search for Eligible Edges Kurt Mehlhorn

• every node maintains a pointer into its edge list (= the current edge)
• invariant: no edge to the left of the current edge is eligible

• in order to search for an eligible edge for pushing out of v, v advances its
current edge pointer until
– either an eligible edge is found
– or the end of the list is reached. Then v is relabeled and the current edge
pointer is reset to the beginning of the list
• correctness follows from Lemma on preceding slide
• time is O(deg(v)) between relabels of v and hence
P
• total time required to search for eligible edges = 2n · v deg(v) = O(nm)

33
On the Number of Non-Sat Pushes in the Generic Algorithm
PI Informatik Kurt Mehlhorn

• pushes are made as large as possible, i.e., ∆ = min(excess(v), res cap(e))


• (persistence) when an active node v is selected, pushes out of v are performed
until either v becomes inactive (because of a non-saturating push out of v) or
until there are no eligible edges out of v anymore. In the latter case v is
relabeled.
• we study three rules for the selection of active nodes
Arbitrary : an arbitrary active node is selected.
#non sat pushes = O(n2 m), Goldberg and Tarjan
FIFO: the active nodes are kept in a queue and the first node in the queue
is always selected. When a node is relabeled or activated the node is
added to the rear of the queue, #non sat pushes = O(n3 ), Goldberg
Highest-Level : an active node on the highest level, i.e., with maximal
2

d-value is selected, #non sat pushes = O(n m), Cheriyan and Maheshwari
• in all three cases: running time of preflow-push is O(nm + #non sat pushes )

34
PI Informatik
The Arbitrary Rule Kurt Mehlhorn

emma 12 When the Arbitrary-rule is used, the number of non-saturating


ushes is O(n2 m).
roof:
X
Φ= d(v).
v∈V 0 ;v is active

• Φ ≥ 0 always, and Φ = 0 initially.


• a non-saturating push decreases Φ by at least one, since it deactivates the
source of the push (may activate the target)
• a relabeling increases Φ by one.
• a saturating push increases Φ by at most 2n, since it may activate the target
• total increase of Φ ≤ n2 + nm2n = n2 (1 + 2m)
• #non sat pushes ≤ total increase of Φ

35
PI Informatik
The FIFO Rule Kurt Mehlhorn

• active nodes are in a queue, head of queue is selected for pushing/relabeling


• relabeled and activated nodes are added to the rear of the queue
• we split the execution into phases
• first phase starts at the beginning of the execution
• a phase ends when all nodes that were active at the beginning of the phase
have been selected from the queue
• each node is selected at most once in each phase: #non sat pushes ≤ n · #phases
emma 13 When the FIFO-rule is used, the number of phases is O(n2 ).
roof: Use Φ = max {d(v) ; v is active }
• Φ ≥ 0 always, and Φ = 0 initially.
• a phase containing no relabel operation decreases Φ by at least one, since all
nodes on the highest level become inactive.
• a phase containing a relabel operation increases Φ by at most one, since a
relabel increases the highest level by at most one.

36
2

emma 14 When the Highest-Level-rule is used, #non sat pushes = O(n m).
Warning: Proof in Ahuja/Magnanti/Orlin is wrong, proof here Cheriyan/M

• let K = m. For a node v, let d0 (v) = |{w; d(w) ≤ d(v)}|/K.
P
• potential function Φ = d0 (v).
v;v is active

• execution is split into phases


• phase = all pushes between two consecutive changes of
d∗ = max {d(v) ; v is active }
• phase is expensive if it contains more than K non-sat pushes, cheap otherwise.
We show:
1) The number of phases is at most 4n2 .
2) The number of non-saturating pushes in cheap phases is at most 4n2 K.
3) Φ ≥ 0 always, and Φ ≤ n2 /K initially.
4) A relabeling or a sat push increases Φ by at most n/K.
5) A non-saturating push does not increase Φ.
6) An expensive phase with Q ≥ K non-sat
37 pushes decreases Φ by at least Q.
1) The number of phases is at most 4n2 .
2) The number of non-saturating pushes in cheap phases is at most 4n2 K.
3) Φ ≥ 0 always, and Φ ≤ n2 /K initially.
4) A relabeling or a sat push increases Φ by at most n/K.
5) A non-saturating push does not increase Φ.
6) An expensive phase with Q ≥ K non-sat pushes decreases Φ by at least Q.

• Suppose that we have shown (1) to (6).


• (4) and (5) imply total increase of Φ ≤ (2n2 + mn)n/K
• above + (3): total decrease can be at most this number plus n2 /K
• #non sat pushes in expensive phases ≤ (2n3 + n2 + mn2 )/K.

above + (2) #non sat pushes ≤ (2n3 + n2 + mn2 )/K + 4n2 K

since n ≤ m: #non sat pushes ≤ 4mn2 /K + 4n2 K = 4n2 (m/K + K)


√ √
K = m: #non sat pushes ≤ 8n m.
2

38
PI Informatik Kurt Mehlhorn
Proving (1) to (5)

1) The number of phases is at most 4n2 :


we have d∗ = 0 initially, d∗ ≥ 0 always, and only relabels increase d∗ . Thus,
d∗ is increased at most 2n2 times, decreased no more than this, and hence
changed at most 4n2 times.
2) The number of non-saturating pushes in cheap phases is at most 4n2 K:
follows immediately from (1) and the definition of a cheap phase.
3) Φ ≥ 0 always, and Φ ≤ n2 /K initially: obvious
4) A relabeling or a sat push increases Φ by at most n/K:
follows from the observation that d0 (v) ≤ n/K for all v and at all times. Also
a relabel of v cannot increase any of the other labels d0 (w).
5) A non-saturating push does not increase Φ:
observe that a non-sat push across an edge (v, u) deactivates v, activates u (if
it is not already active), and that d0 (u) ≤ d0 (v).

39
PI Informatik Kurt Mehlhorn
Proving (6)

6) An expensive phase with Q ≥ K non-sat pushes decreases Φ by at least Q:


• consider an expensive phase containing Q ≥ K non-sat pushes.
• d∗ is constant during a phase and hence all Q non-saturating pushes must
be out of nodes at level d∗ .
• The phase is finished either because level d∗ becomes empty or because a
node is moved from level d∗ to level d∗ + 1.
• In either case, we conclude that level d∗ contains Q ≥ K nodes at all
times during the phase.
• Thus, each non-saturating push in the phase decreases Φ by at least one
(since d0 (u) ≤ d0 (v) − 1 for a push from v to u).

40
Heuristic Improvements, see LEDAbook, pages 465Kurt
PI Informatik
– Mehlhorn
487

• at the start of the alg, all edges out of s are saturated


• some of the flow pushed into the network will make it to t
• part of the flow must be routed back to s
• this requires to lift (some, many) nodes above level n
• thus running time is Ω(n2 ) even if total number of pushes is small
• heuristic improvements attempt to lift nodes faster that the standard
relabeling procedure

ggressive local relabeling: when a node is relabeled, continue to relabel it


until there is an eligible edge out of it, i.e.,
set d(v) to 1 + min {d(w) ; (v, w) ∈ Gf }
aggressive local relabeling has cost O(1), it may increase d(v) by more than
one.

41
PI Informatik
Heuristic Improvements, Continued Kurt Mehlhorn

lobal relabeling: after O(m) edge inspections, update the dist-values of all
nodes by setting


 µ(v, t) if there is a path from v to t in Gf




d(v) = n + µ(v, s) if there is a path from v to s in Gf but no

 path from v to t in Gf




2n − 1 otherwise

Here µ(v, t) and µ(v, s) denote the lengths (= number of edges) of the
shortest paths from v to t, respectively s, in Gf .
global relabeling has cost O(m).
ap heuristic: when a level i, 1 ≤ i < n, becomes empty (because we lift the
last node on this level to a higher level),
lift all nodes in levels i + 1 to n − 1 to level n.
gap heuristic has cost proportional to the number of nodes moved to level n.

42
PI Informatik
Experimental Findings Kurt Mehlhorn

Gen Rule BASIC HL LRH GRH GAP LEDA


rand FF 5.84 6.02 4.75 0.07 0.07 —
33.32 33.88 26.63 0.16 0.17 —
HL 6.12 6.3 4.97 0.41 0.11 0.07
27.03 27.61 22.22 1.14 0.22 0.16
MF 5.36 5.51 4.57 0.06 0.07 —
26.35 27.16 23.65 0.19 0.16 —
nd = random graphs, we used n = 1000 and n = 2000, m = 3n.
F = first-in-first-out selection rule
L = highest level selection rule
F = modified FF-rule (relabels reinsert at front, pushes insert at end)
ASIC = generic preflow push
L = nodes above level n are treated slightly differently (not explained in lectures)
RH = aggressive local relabeling
LH = global relabeling heuristic
AP = gap heuristic
43
EDA = improved storage organization
PI Informatik
Asymptotics of our Implementations Kurt Mehlhorn

Gen Rule GRH GAP LEDA


rand FF 0.16 0.41 1.16 0.15 0.42 1.05 — — —
HL 1.47 4.67 18.81 0.23 0.57 1.38 0.16 0.45 1.09
MF 0.17 0.36 1.06 0.14 0.37 0.92 — — —
CG1 FF 3.6 16.06 69.3 3.62 16.97 71.29 — — —
HL 4.27 20.4 77.5 4.6 20.54 80.99 2.64 12.13 48.52
MF 3.55 15.97 68.45 3.66 16.5 70.23 — — —
CG2 FF 6.8 29.12 125.3 7.04 29.5 127.6 — — —
HL 0.33 0.65 1.36 0.26 0.52 1.05 0.15 0.3 0.63
MF 3.86 15.96 68.42 3.9 16.14 70.07 — — —
AMO FF 0.12 0.22 0.48 0.11 0.24 0.49 — — —
HL 0.25 0.48 0.99 0.24 0.48 0.99 0.12 0.24 0.52
MF 0.11 0.24 0.5 0.11 0.24 0.48 — — —

G1, CG2, and AMO are problem generators, see LEDAbook for details.
or each generator we ran the cases n = 5000 · 2i for i = 0, 1, and 2.

or the random graph generator we used m = 3n.


44

You might also like