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

93
Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm Analysis Summary The Push-Relabel Algorithm A Better Solution to the Max-Flow Problem Hao Lu Yu Shi Boyuan Kong Jiefeng Chen Department of Computer Science Shanghai Jiao Tong University 2015–11–24

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

Page 1: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 2: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 3: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 4: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 5: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 6: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 7: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 8: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 9: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 10: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 11: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 12: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 13: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 14: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 15: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 16: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 17: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 18: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 19: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 20: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 21: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 22: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 23: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 24: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

• · · ·

Page 25: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 26: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 27: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 28: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 29: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 30: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 31: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 32: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 33: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 34: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 35: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 36: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 37: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 38: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 39: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 40: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 41: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 42: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 43: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 44: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 45: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 46: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 47: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 48: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 49: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 50: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 51: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 52: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 53: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 54: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 55: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 56: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 57: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 58: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 59: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 60: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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!

Page 61: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 62: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 63: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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)

Page 64: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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)

Page 65: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 66: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 67: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 68: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 69: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 70: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 71: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 72: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 73: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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).

Page 74: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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).

Page 75: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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).

Page 76: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 77: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 78: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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}

Page 79: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 .

Page 80: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 81: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 82: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 83: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 84: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 85: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 86: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 87: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 88: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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.

Page 89: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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

Page 90: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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)

Page 91: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 92: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |)

Page 93: The Push-Relabel Algorithm - SJTUdominik/teaching/2015... · Slides by Hao Lu Max-Flow Review Push-Relabel Algorithm AnalysisSummary Outline 1 A Consice Review of the Max-Flow Problem

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 |).