The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review...

Post on 25-Jun-2020

2 views 0 download

Transcript of The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review...

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

The Push-Relabel AlgorithmA Better Solution to the Max-Flow Problem

Hao Lu Yu Shi Boyuan Kong Jiefeng Chen

Department of Computer ScienceShanghai Jiao Tong University

2015–11–24

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Outline

1 A Consice Review of the Max-Flow ProblemMax-Flow Problem and Ford-Fulkerson MethodAn example where FF never terminatesImprovements by Specifying the Order of Path Choice

2 Generic Push-Relabel AlgorithmConcepts and Basic OperationsAn Intuitive Example

3 Push-Relabel Algorithm AnalysisCorrectness of Push-Relabel AlgorithmRunning Time Analysis of Push-Relabel Algorithm

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Outline

1 A Consice Review of the Max-Flow ProblemMax-Flow Problem and Ford-Fulkerson MethodAn example where FF never terminatesImprovements by Specifying the Order of Path Choice

2 Generic Push-Relabel AlgorithmConcepts and Basic OperationsAn Intuitive Example

3 Push-Relabel Algorithm AnalysisCorrectness of Push-Relabel AlgorithmRunning Time Analysis of Push-Relabel Algorithm

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Outline

1 A Consice Review of the Max-Flow ProblemMax-Flow Problem and Ford-Fulkerson MethodAn example where FF never terminatesImprovements by Specifying the Order of Path Choice

2 Generic Push-Relabel AlgorithmConcepts and Basic OperationsAn Intuitive Example

3 Push-Relabel Algorithm AnalysisCorrectness of Push-Relabel AlgorithmRunning Time Analysis of Push-Relabel Algorithm

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Max-Flow Problem and Ford-Fulkerson Method

• G = (V ,E , c), c : V × V 7→ R+

• Find a flow that maximize val(f ) =∑

v∈V f (s, v)

• Fold-Fulkerson Method

Ford-Fulkerson-Method(G , s, t)

1 f ← 02 while there exists an augmenting path p

from s to t in Gf

3 f ← f + fp4 return f

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Max-Flow Problem and Ford-Fulkerson Method

• G = (V ,E , c), c : V × V 7→ R+

• Find a flow that maximize val(f ) =∑

v∈V f (s, v)

• Fold-Fulkerson Method

Ford-Fulkerson-Method(G , s, t)

1 f ← 02 while there exists an augmenting path p

from s to t in Gf

3 f ← f + fp4 return f

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Initialization

v2v1

s

v3 v4

t

MM

M

e1, r0 e3, r

0 e2, r1

MM

M

• r =√5−12 , r2 + r1 = r0, rn+2 + rn+1 = rn

• M ≥ 1 + r

• p ′ = s → v2 → v3 → t

• p0 = s → v4 → v3 → v2 → v1 → t

• p1 = s → v2 → v3 → v4 → t

• p2 = s → v1 → v2 → v3 → t

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0 r1r0

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0 − r1

r1 r1

r1

r0 − r1

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0 − r1

r1 r1

r1

r0 − r1

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0 − r1

r1

r1

r0

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r2

r1

r1

r0

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0

r3

r1 − r3

r2

r0 − r2

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r0

r3

r1 − r3

r2

r0 − r2

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Step 0–4

v2v1

s

v3 v4

t

MM

M

r2

r0 − r2

r3

r1 − r3r0

MM

M

• p ′ = s → v2 → v3 → t, send flow: r0

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r1

• p1 = s → v2 → v3 → v4 → t, send flow: r1

• p0 = s → v4 → v3 → v2 → v1 → t, send flow: r2

• p2 = s → v1 → v2 → v3 → t, send flow: r2

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Iteration

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

v2v1

s

v3 v4

t

MM

M

r2

r0−r2

r3

r1−r3r0

MM

M

• After Step 4n, e1 : r2n, e2 : r

2n+1, e3 : r0

• Send flow: r0 + 2∑∞

i=1 ri = 1 + 2 · r

1−r = 3 + 2r

• Max flow: 2M + 1

• If M > 1 + r , it even not converges to the max-flow’s value!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Iteration

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

v2v1

s

v3 v4

t

MM

M

r2

r0−r2

r3

r1−r3r0

MM

M

• After Step 4n, e1 : r2n, e2 : r

2n+1, e3 : r0

• Send flow: r0 + 2∑∞

i=1 ri = 1 + 2 · r

1−r = 3 + 2r

• Max flow: 2M + 1

• If M > 1 + r , it even not converges to the max-flow’s value!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Iteration

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

v2v1

s

v3 v4

t

MM

M

r2

r0−r2

r3

r1−r3r0

MM

M

• After Step 4n, e1 : r2n, e2 : r

2n+1, e3 : r0

• Send flow: r0 + 2∑∞

i=1 ri = 1 + 2 · r

1−r = 3 + 2r

• Max flow: 2M + 1

• If M > 1 + r , it even not converges to the max-flow’s value!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Iteration

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

v2v1

s

v3 v4

t

MM

M

r2

r0−r2

r3

r1−r3r0

MM

M

• After Step 4n, e1 : r2n, e2 : r

2n+1, e3 : r0

• Send flow: r0 + 2∑∞

i=1 ri = 1 + 2 · r

1−r = 3 + 2r

• Max flow: 2M + 1

• If M > 1 + r , it even not converges to the max-flow’s value!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Iteration

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

v2v1

s

v3 v4

t

MM

M

r2

r0−r2

r3

r1−r3r0

MM

M

• After Step 4n, e1 : r2n, e2 : r

2n+1, e3 : r0

• Send flow: r0 + 2∑∞

i=1 ri = 1 + 2 · r

1−r = 3 + 2r

• Max flow: 2M + 1

• If M > 1 + r , it even not converges to the max-flow’s value!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Non-termination of FF

Iteration

v2v1

s

v3 v4

t

MM

M

r0 r1

r0

MM

M

v2v1

s

v3 v4

t

MM

M

r2

r0−r2

r3

r1−r3r0

MM

M

• After Step 4n, e1 : r2n, e2 : r

2n+1, e3 : r0

• Send flow: r0 + 2∑∞

i=1 ri = 1 + 2 · r

1−r = 3 + 2r

• Max flow: 2M + 1

• If M > 1 + r , it even not converges to the max-flow’s value!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Improvements

Several Improvement Ideas

• Some thought: Select one path with the largest capacity

• Edmonds Karp: Select one shortest path

• · · ·

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Preflow

s

u

v

t

1/2

1/1

1/1

1/3

• It’s a flow!

• It’s not a flow, but apreflow!

• e(u) = 2 − 1 = 1

• Overflowing: e(u) > 0

• A preflow is a flow where:• inflow(u) > outflow(u) is allowed• Flow conservation is relaxed

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Preflow

s

u

v

t

2/2

1/1

1/1

1/3

• It’s a flow!

• It’s not a flow, but apreflow!

• e(u) = 2 − 1 = 1

• Overflowing: e(u) > 0

• A preflow is a flow where:• inflow(u) > outflow(u) is allowed• Flow conservation is relaxed

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Preflow

s

u

v

t

2/2

1/1

1/1

1/3

• It’s a flow!

• It’s not a flow, but apreflow!

• e(u) = 2 − 1 = 1

• Overflowing: e(u) > 0

• A preflow is a flow where:• inflow(u) > outflow(u) is allowed• Flow conservation is relaxed

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Preflow

s

u

v

t

3/2

1/1

1/1

2/3

• It’s a flow!

• It’s not a flow, but apreflow!

• e(u) = 2 − 1 = 1

• Overflowing: e(u) > 0

• A preflow is a flow where:• inflow(u) > outflow(u) is allowed• Flow conservation is relaxed

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Preflow

s

u

v

t

3/2

1/1

1/1

2/3

• It’s a flow!

• It’s not a flow, but apreflow!

• e(u) = 2 − 1 = 1

• Overflowing: e(u) > 0

• A preflow is a flow where:• inflow(u) > outflow(u) is allowed• Flow conservation is relaxed

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Height Function

0

1

2

3

u

v1

v2

v3

v4

× A height function h : V 7→ N• h(t) = 0, h(s) = |V |• h(v) ≤ h(u) + 1,∀ 〈v , u〉 ∈ Ef

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Height Function

0

1

2

3

u

v1

v2

v3

v4

× A height function h : V 7→ N• h(t) = 0, h(s) = |V |• h(v) ≤ h(u) + 1,∀ 〈v , u〉 ∈ Ef

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Push Operation

0

1

2

3

u

v1

v2 v

3/4

2/2

3/4

• u is overflowing

• cf (u, v) > 0

• h(u) = h(v) + 1

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Push Operation

0

1

2

3

u

v1

v2 v

A saturating push

3/4

2/2

4/4

• u is overflowing

• cf (u, v) > 0

• h(u) = h(v) + 1

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Push Operation

0

1

2

3

u

v1

v2 v

A saturating push

3/4

2/2

4/4

• u is overflowing

• cf (u, v) > 0

• h(u) = h(v) + 1

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Push Operation

0

1

2

3

u

v1

v2 v

3/4

0/2

0/4

• u is overflowing

• cf (u, v) > 0

• h(u) = h(v) + 1

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Push Operation

0

1

2

3

A non-saturating push

u

v1

v2 v

3/4

0/2

3/4

• u is overflowing

• cf (u, v) > 0

• h(u) = h(v) + 1

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Relabel Operation

0

1

2

3

u

v1

v2

v3

• u is overflowing

• h(u) ≤ h(v),∀ 〈u, v〉 ∈ Ef

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Relabel Operation

0

1

2

3

u

v1

v2

v3

• u is overflowing

• h(u) ≤ h(v),∀ 〈u, v〉 ∈ Ef

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Relabel Operation

0

1

2

3

u

v1

v2

v3

• u is overflowing

• h(u) ≤ h(v),∀ 〈u, v〉 ∈ Ef

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

The Relabel Operation

0

1

2

3

u v1

v2

v3

• u is overflowing

• h(u) ≤ h(v),∀ 〈u, v〉 ∈ Ef

• Height function maintains

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Basics

Generic Algorithm

Push-Relabel(G )

1 h(u) = 0 except h(s) = |V |2 f (u, v) = 0 except f (s, v) = c(s, v),∀v connected to s3 while there exists an applicable push or relabel operation4 do it5 return f

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s+0 0

v2+0 0

v1+0 0

v3+0 0

t+0 0

12

14

5

16

8

7

10

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v2+14 0

v1+12 0

v3+0 0

t+0 0

12

14

5

16

8

7

10

• Initial the preflow

• Relabel v1

• Push 12 from v1 to t

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v2+14 0

v1+12 1

v3+0 0

t+0 0

12

14

5

16

8

7

10

• Initial the preflow

• Relabel v1

• Push 12 from v1 to t

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v1+0 1

v2+14 0

v3+0 0

t+12 0

12

14

5

4

12

8

7

10

• Initial the preflow

• Relabel v1

• Push 12 from v1 to t

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v1+0 1

v2+14 1

v3+0 0

t+12 0

12

14

5

4

12

8

7

10

• Relabel v2

• Push 8 from v2 to v3

• Relabel v3

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v1+0 1

v2+6 1

v3+8 0

t+12 0

12

14

5

4

12

8

7

10

• Relabel v2

• Push 8 from v2 to v3

• Relabel v3

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v1+0 1

v2+6 1

v3+8 1

t+12 0

12

14

5

4

12

8

7

10

• Relabel v2

• Push 8 from v2 to v3

• Relabel v3

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v1+0 1

v2+6 1

v3+0 1

t+20 0

12

14

5

4

12

8

7

2

8

• Push 8 from v3 to t

• Relabel v2

• Push 6 from v2 to s

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−26 5

v1+0 1

v2+6 6

v3+0 1

t+20 0

12

14

5

4

12

8

7

2

8

• Push 8 from v3 to t

• Relabel v2

• Push 6 from v2 to s

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Example

Example

s−20 5

v1+0 1

v2+0 6

v3+0 1

t+20 0

12

6

8

5

4

12

8

7

2

8

• Push 8 from v3 to t

• Relabel v2

• Push 6 from v2 to s

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Correctness

Termination with a Flow

Lemma (Termination with a flow)

G , f , h, u is overflowing. Then either a push or a relabel applies to it.

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Correctness

Termination with a Flow

Lemma (Termination with a flow)

G , f , h, u is overflowing. Then either a push or a relabel applies to it.

0

1

2

3

u v1

v2

v3

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Correctness

Termination with a Flow

Lemma (Termination with a flow)

G , f , h, u is overflowing. Then either a push or a relabel applies to it.

0

1

2

3

u

v1

v2

v3

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Correctness

Non-Existence of s ; t Path

Lemma

G , f , h. There is no path from s to t in Gf .

|V |

≥|V |−1

≥|V |−2 · · ·

0

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Correctness

Non-Existence of s ; t Path

Lemma

G , f , h. There is no path from s to t in Gf .

|V |

≥|V |−1

≥|V |−2 · · ·

0

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Correctness

Correctness

Theorem

Push-Relabel Algorithm generates a max-flow.

Proof.

• Termination with a flow.

• Non-existence of s ; t path.

• Termination with a max-flow.

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Correctness

Correctness

Theorem

Push-Relabel Algorithm generates a max-flow.

Proof.

• Termination with a flow.

• Non-existence of s ; t path.

• Termination with a max-flow.

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Excess Flow Can Return

Lemma

G , f . For any overflowing vertex w , there is a simple path w ; s in Gf .

Proof.

Yes, or WHERE did the flow come from!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Excess Flow Can Return

Lemma

G , f . For any overflowing vertex w , there is a simple path w ; s in Gf .

Proof.

Yes, or WHERE did the flow come from!

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Heights

Lemma (Bound on heights)

∀v ∈ V : h(v) ≤ 2|V |− 1

Proof.

• Heights only increase during relabel operations.

• Relabel operations only applies to overflowing vertices.

• Overflowing vertices are connected to s.

• h(v) − h(s) ≤ |V |− 1

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Heights

Lemma (Bound on heights)

∀v ∈ V : h(v) ≤ 2|V |− 1

Proof.

• Heights only increase during relabel operations.

• Relabel operations only applies to overflowing vertices.

• Overflowing vertices are connected to s.

• h(v) − h(s) ≤ |V |− 1

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Relabel Operations

Lemma (Bound on relabel operations)

# Relabel operations = O(|V |2)

Proof.

• A relabel operation increases h(u) by at least 1.

• h(u) ≤ 2|V |− 1

• (|V |− 1) · (2|V |− 1) = O(|V |2)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Relabel Operations

Lemma (Bound on relabel operations)

# Relabel operations = O(|V |2)

Proof.

• A relabel operation increases h(u) by at least 1.

• h(u) ≤ 2|V |− 1

• (|V |− 1) · (2|V |− 1) = O(|V |2)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Saturating Pushes

Lemma (Bound on saturating pushes)

# Saturating pushes = O(|V ||E |)

Proof.•• (|E |) · (2|V |− 1) = O(|V ||E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Saturating Pushes

Lemma (Bound on saturating pushes)

# Saturating pushes = O(|V ||E |)

Proof.

•0

1

2

u

v1

• (|E |) · (2|V |− 1) = O(|V ||E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Saturating Pushes

Lemma (Bound on saturating pushes)

# Saturating pushes = O(|V ||E |)

Proof.

•0

1

2

u

v1

• (|E |) · (2|V |− 1) = O(|V ||E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Saturating Pushes

Lemma (Bound on saturating pushes)

# Saturating pushes = O(|V ||E |)

Proof.

• 0

1

2

u

v1

• (|E |) · (2|V |− 1) = O(|V ||E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Non-saturating Pushes

Lemma (Bound on non-saturating pushes)

# Non-saturating pushes = O(|V |2|E |)

Proof.

Define Φ =∑

v : e(v)>0 h(v)

• A relabel operation increases Φ by at most 2|V |− 1.

• A saturating push operation increases Φ by at most 2|V |− 1.

• A non-saturating push operation decreases Φ by at least 1: u will nolonger be overflowing, v may become overflowing, h(u) = h(v) + 1

• (2|V |− 1) · (O(|V |2) + O(|V ||E |)) = O(|V |2|E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Non-saturating Pushes

Lemma (Bound on non-saturating pushes)

# Non-saturating pushes = O(|V |2|E |)

Proof.

Define Φ =∑

v : e(v)>0 h(v)

• A relabel operation increases Φ by at most 2|V |− 1.

• A saturating push operation increases Φ by at most 2|V |− 1.

• A non-saturating push operation decreases Φ by at least 1: u will nolonger be overflowing, v may become overflowing, h(u) = h(v) + 1

• (2|V |− 1) · (O(|V |2) + O(|V ||E |)) = O(|V |2|E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Non-saturating Pushes

Lemma (Bound on non-saturating pushes)

# Non-saturating pushes = O(|V |2|E |)

Proof.

Define Φ =∑

v : e(v)>0 h(v)

• A relabel operation increases Φ by at most 2|V |− 1.

• A saturating push operation increases Φ by at most 2|V |− 1.

• A non-saturating push operation decreases Φ by at least 1: u will nolonger be overflowing, v may become overflowing, h(u) = h(v) + 1

• (2|V |− 1) · (O(|V |2) + O(|V ||E |)) = O(|V |2|E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Bound on Non-saturating Pushes

Lemma (Bound on non-saturating pushes)

# Non-saturating pushes = O(|V |2|E |)

Proof.

Define Φ =∑

v : e(v)>0 h(v)

• A relabel operation increases Φ by at most 2|V |− 1.

• A saturating push operation increases Φ by at most 2|V |− 1.

• A non-saturating push operation decreases Φ by at least 1: u will nolonger be overflowing, v may become overflowing, h(u) = h(v) + 1

• (2|V |− 1) · (O(|V |2) + O(|V ||E |)) = O(|V |2|E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Running Time

Theorem (Running time)

There is an implementation of Push-Relabel Algorithm whose runningtime is O(|V |2|E |).

Proof.

There is an implementation which satisfies:

• Every push takes O(1) time, totalling O(|V |2|E |).• Every relabel takes O(|V |) time, totalling O(|V |3).? Actually, relabel operations take O(|V ||E |).

There is also an implementation, called Relabel-To-FrontAlgorithm, whose running time is O(|V |3).

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Running Time

Theorem (Running time)

There is an implementation of Push-Relabel Algorithm whose runningtime is O(|V |2|E |).

Proof.

There is an implementation which satisfies:

• Every push takes O(1) time, totalling O(|V |2|E |).• Every relabel takes O(|V |) time, totalling O(|V |3).? Actually, relabel operations take O(|V ||E |).

There is also an implementation, called Relabel-To-FrontAlgorithm, whose running time is O(|V |3).

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Running Time

Running Time

Theorem (Running time)

There is an implementation of Push-Relabel Algorithm whose runningtime is O(|V |2|E |).

Proof.

There is an implementation which satisfies:

• Every push takes O(1) time, totalling O(|V |2|E |).• Every relabel takes O(|V |) time, totalling O(|V |3).? Actually, relabel operations take O(|V ||E |).

There is also an implementation, called Relabel-To-FrontAlgorithm, whose running time is O(|V |3).

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Summary

• Augmenting paths: O(|V ||E |2)• Preflows: O(|V |3), O(|V ||E | log|E |/(|V | lg |V |)|V |)• Blocking flows: O(min(|V |2/3, |E |1/2)|E | lg(|V |2/|E |+ 2) lgC )

• A 2013 algorithm by Orlin achieves O(|V ||E |)

Slides by Hao Lu

Max-Flow Review Push-Relabel Algorithm Analysis Summary

Bibliography

Advanced Algorithms, Spring 11, Course Website.

Thomas H. Cormen, Charles E Leiserson, Ronald L Rivest, andClifford Stein.Introduction to algorithms.MIT Press, Cambridge, Mass., 3rd ed edition, 2009.

Andrew V. Goldberg and Robert Endre Tarjan.Efficient maximum flow algorithms.Commun. ACM, 57(8):82–89, 2014.

Slides by Hao Lu

Algorithm Analysis

Layering

Definition

L0 L1 L2

· · ·

Lk

• A layering is a partition V =⋃k

i=0 Li s.t.• s ∈ L0

• u ∈ Li , v ∈ Lj , 〈u, v〉 ∈ E ⇒ j ≤ i + 1

• dist(s, u) ≥ i , u ∈ Li• Canonical Layering

• Li = {v |distG (s, v) = i }• L∞ = {v | @s ; vpath}

Slides by Hao Lu

Algorithm Analysis

Basics

Preflow and Height Function

• A preflow is a function f : V × V 7→ R s.t.• Capacity Constraints: f ≤ c• Skew Symmetry: f (u, v) = −f (v , u)• Relaxation of Flow Conservation:

∑v∈V f (v , u) ≥ 0,∀u ∈ V \ {s}

• The excess flow into u is defined as e(u) =∑

v∈V f (v , u).

• A vertex v ∈ V \ {s, t} is overflowing if e(u) > 0.

• G = (V ,E ), f is a preflow; a height function h : V 7→ N is definedas:

• h(s) = |V |, h(t) = 0• h(u) ≤ h(v) + 1, ∀ 〈u, v〉 ∈ Ef

Lemma

If h(u) > h(v) + 1, then 〈u, v〉 /∈ Ef .

Slides by Hao Lu

Algorithm Analysis

Basics

The Push Operation

• Applies when:• u is overflowing• cf (u, v) > 0• h(u) = h(v) + 1

• Push min(e(u), cf (u, v)) units of flow from u to v

• Non-saturating Push, saturating push

• After a saturating push, u is no longer overflowing.

Slides by Hao Lu

Algorithm Analysis

Basics

The Relabel Operation

• Applies when:• u is overflowing• h(u) ≤ h(v),∀ 〈u, v〉 ∈ Ef

• Increase h(u) to 1 + min {h(v) | 〈u, v〉 ∈ Ef }

• Feasibility: {h(v) | 〈u, v〉 ∈ Ef } 6= ∅ since u is overflowing.

Slides by Hao Lu

Algorithm Analysis

Basics

Generic Algorithm

Push-Relabel(G )

1 h(u) = 0 except h(s) = |V |2 f (u, v) = 0 except f (s, v) = c(s, v),∀v connected to s3 while there exists an applicable push or relabel operation4 do it5 return f

Slides by Hao Lu

Algorithm Analysis

Correctness

Termination with a Flow

Lemma (Termination with a flow)

G , f , h, u is overflowing. Then either a push or a relabel applies to it.

Proof.

∀ 〈u, v〉 ∈ Ef : h(u) ≤ h(v) + 1If ∃ 〈u, v〉 ∈ Ef : h(u) = h(v) + 1, a push applies.Else, ∀ 〈u, v〉 ∈ Ef : h(u) < h(v)+1, or h(u) ≤ h(v), a relabel applies.

Slides by Hao Lu

Algorithm Analysis

Correctness

Heights Never Decrease

Lemma (Heights never decrease)

During the execution of the Push-Relabel algorithm on G , for everyu ∈ V , h(u) never decreases. Moreover, a relabel operation increasesh(u) by at least 1.

Proof.

Push operations don’t involve height changing.Before a relabel operation, ∀ 〈u, v〉 ∈ Ef : h(u) ≤ h(v). After it,h(u) = min {h(v) | 〈u, v〉 ∈ Ef }+ 1.

Slides by Hao Lu

Algorithm Analysis

Correctness

Height Function Maintains

Lemma (Height function maintains)

During the execution of the Push-Relabel algorithm on G , h willalways be a height function.

Proof.

• Relabel Operations: For 〈u, v〉 ∈ Ef ,h(u) = min {h(v) | 〈u, v〉 ∈ Ef }+ 1 ensures h(u) ≤ h(v) + 1. For〈w , u〉 ∈ Ef , before the relabel operation h(w) ≤ h(u) + 1.According to, this property maintains.

• Push Operations: During a push operation on 〈u, v〉, a new edge〈v , u〉 may appear. h(u) = h(v)+1 guarantees that h(v) ≤ h(u)−1.With a saturating push, 〈u, v〉 will disappear, but it doesn’t hurt.

Slides by Hao Lu

Algorithm Analysis

Correctness

Non-Existence of s ; t Path

Lemma

G , f , h. There is no path from s to t in Gf .

Proof.

For the sake of contradiction, Gf has some s ; t paths. Let the shortestone be p = 〈v0, v1, . . . , vk〉, where v0 = s, vk = t, k < |V |.

|V | = h(s) ≤ h(v1) + 1 ≤ · · · ≤ h(t) + k = k

which leads to a contradiction.

Slides by Hao Lu

Algorithm Analysis

Correctness

Correctness

Theorem

Push-Relabel Algorithm generates a max-flow.

Proof.

• Preflow maintains.

• Height function maintains.

• Termination with a flow.

• Non-existence of s ; t path.

• Termination with a max-flow.

Slides by Hao Lu

Algorithm Analysis

Running Time

Excess Flow Can Return

Lemma

G , f . For any overflowing vertex w , there is a simple path w ; s in Gf .

Proof.

For any overflowing vertex w , let U = {v |∃w ; v in Gf }.Claim: s ∈ U∑

u∈U

e(u) =∑u∈U

∑v∈V

f (v , u) =∑u∈U

∑v∈U

f (v , u) +∑u∈U

∑v∈U

f (v , u)

=∑u∈U

∑v∈U

f (v , u)

If s /∈ U, the sum is greater than 0, whichmeans∃u ′ ∈ U, v ′ ∈ U : f (v ′, u ′) > 0, thus ∃w ; u ′ → v ′, v ′ ∈ U.

Slides by Hao Lu

Algorithm Analysis

Running Time

Bound on Heights

Lemma (Bound on heights)

∀v ∈ V : h(v) ≤ 2|V |− 1

Proof.

• Heights only increase during relabel operations.

• Relabel operations only applies to overflowing vertices.

• Overflowing vertices are connected to s.

• h(v) − h(s) ≤ |V |− 1

Slides by Hao Lu

Algorithm Analysis

Running Time

Bound on Relabel Operations

Lemma (Bound on relabel operations)

# Relabel operations = O(|V |2)

Proof.

• A relabel operation increases h(u) by at least 1.

• h(u) ≤ 2|V |− 1

• (|V |− 1) · (2|V |− 1) = O(|V |2)

Slides by Hao Lu

Algorithm Analysis

Running Time

Bound on Saturating Pushes

Lemma (Bound on saturating pushes)

# Saturating pushes = O(|V ||E |)

Proof.

• A saturating push operation changes the direction e = 〈u, v〉.• Between two such pushes on e, h(u) + h(v) increases by at least 2.

• For each e, there are at most 2|V |− 1 saturating pushes.

• (|E |) · (2|V |− 1) = O(|V ||E |)

Slides by Hao Lu

Algorithm Analysis

Running Time

Bound on Non-saturating Pushes

Lemma (Bound on non-saturating pushes)

# Non-saturating pushes = O(|V |2|E |)

Proof.

Define Φ =∑

v : e(v)>0 h(v)

• A relabel operation increases Φ by at most 2|V |− 1.

• A saturating push operation increases Φ by at most 2|V |− 1.

• A non-saturating push operation decreases Φ by at least 1:u will no longer be overflowing, v may become overflowing,h(u) = h(v) + 1

• (2|V |− 1) · (O(|V |2) + O(|V ||E |)) = O(|V |2|E |)

Slides by Hao Lu

Algorithm Analysis

Running Time

Running Time

Theorem (Running time)

There is an implementation of Push-Relabel Algorithm whoserunning time is O(|V |2|E |).

Proof.

There is an implementation which satisfies:

• Every push takes O(1) time, totalling O(|V |2|E |).• Every relabel takes O(|V |) time, totalling O(|V |3).? Actually, relabel operations take O(|V ||E |).