Divide and Conquer - jhc.sjtu.edu.cn

68
Network Flow Max-Flow: Edmonds-Karp Algorithm, Dinitzโ€™s Algorithm Max Bipartite Matching: Hopcroftโ€“Karpโ€“Karzanov algorithm

Transcript of Divide and Conquer - jhc.sjtu.edu.cn

Network Flow

Max-Flow: Edmonds-Karp Algorithm, Dinitzโ€™s AlgorithmMax Bipartite Matching: Hopcroftโ€“Karpโ€“Karzanov algorithm

Residual Network ๐บ๐‘“

Given ๐บ = (๐‘‰, ๐ธ), ๐‘, and a flow ๐‘“

๐บ๐‘“ = (๐‘‰, ๐ธ๐‘“) and the associated capacity ๐‘๐‘“: ๐ธ๐‘“ โ†’ โ„+ are defined as follows:

โ–ช ๐‘ข, ๐‘ฃ โˆˆ ๐ธ๐‘“ if one of the followings holdsโ€“ ๐‘ข, ๐‘ฃ โˆˆ ๐ธ and ๐‘“ ๐‘ข, ๐‘ฃ < ๐‘(๐‘ข, ๐‘ฃ): in this case, ๐‘๐‘“ ๐‘ข, ๐‘ฃ = ๐‘ ๐‘ข, ๐‘ฃ โˆ’ ๐‘“(๐‘ข, ๐‘ฃ)

โ€“ ๐‘ฃ, ๐‘ข โˆˆ ๐ธ and ๐‘“ ๐‘ฃ, ๐‘ข > 0: in this case, ๐‘๐‘“ ๐‘ข, ๐‘ฃ = ๐‘“ ๐‘ฃ, ๐‘ขu

ts

v

20/20

20/30

10

20/2010

u

ts

v

10

10

๐บ ๐บ๐‘“

20

20

20 10

Last Lecture โ€“ Ford-Fulkerson Method

โ–ช Always terminates for integer/rational capacities

โ–ช Not guaranteed to terminate for irrational capacities

โ–ช Time complexity for integer capacities: ๐‘‚ ๐ธ โ‹… ๐‘ฃ(๐‘“)max

โ€“ not a polynomial time

Edmonds-Karp Algorithm

EdmondsKarp(๐บ = ๐‘‰, ๐ธ , ๐‘ , ๐‘ก, ๐‘):

1. initialize ๐‘“ such that โˆ€๐‘’ โˆˆ ๐ธ: ๐‘“ ๐‘’ = 0; initialize ๐บ๐‘“ โ† ๐บ;

2. while there is an ๐‘ -๐‘ก path on ๐บ๐‘“:

3. find such a path ๐’‘ by BFS;

4. find an edge ๐‘’ โˆˆ ๐‘ with minimum capacity ๐‘;

5. update ๐‘“ that pushes ๐‘ units of flow along ๐‘;

6. update ๐บ๐‘“;

7. endwhile

8. return ๐‘“

Edmonds-Karp Algorithm

Why BFS?

โ–ช BFS maintains the distancesโ€“ distance: num of edges, not weighted distance

๐‘ ๐‘ก

dist = 1 dist = 2 dist = 3 dist = 4dist = 5

dist = 6dist = 0

A path found by an iteration of Edmonds-Karp Algorithm

Why BFS?

โ–ช In the residual network ๐บ๐‘“, a new appeared edge can only goes from a vertex at distance ๐‘ก + 1 to a vertex at distance ๐‘ก.

โ–ช Addition of such edges does not decrease the distance between ๐‘ and ๐‘ข for every ๐‘ข โˆˆ ๐‘‰.

โ–ช [Key Observation in this lecture!] Thus, dist(๐‘ข) is non-decreasing throughout the algorithm for every ๐‘ข โˆˆ ๐‘‰.

๐‘ ๐‘ก

dist โ‰ฅ 1 dist โ‰ฅ 2 dist โ‰ฅ 3 dist โ‰ฅ 4dist โ‰ฅ 5

dist โ‰ฅ 6dist = 0

The updates to the edges in ๐บ๐‘“

Weak Monotonicity to Strong Monotonicity

โ–ช dist(๐‘ข) can only be one of 0, 1, 2,โ€ฆ , |๐‘‰|,โˆžโ€“ It can only be increased for |๐‘‰| + 1 times!

โ–ช Itโ€™s great that BFS buys us distance monotonicity!

โ–ช However, weak monotonicity is not enough.

โ–ช To make a progress, we need dist(๐‘ข) strictly increases for some ๐‘ข โˆˆ ๐‘‰, so that we can upper bound the number of iterations.

Counterexample: dist for all vertices remain unchanged after an iteration.

3

3

4

10

2

1

1

5

1

2

5

s

a

d

c

e

b

t

2

1

4

10

2

1

1

5

1

2

5

s

a

d

c

e

b

t3

Towards Strong Monotonicityโ€ฆ

โ–ช Observation: At least one edge (๐‘ข, ๐‘ฃ) on ๐‘ is โ€œsaturatedโ€, and this edge will be deleted in the next iteration.

โ–ช Each iteration will remove an edge from a vertex at distance ๐‘– to a vertex at distance ๐‘– + 1.

โ–ช Intuitively, we cannot keep removing such edges while keeping the distances of all vertices unchanged.

Towards Strong Monotonicity

โ–ช Suppose we are at the ๐‘– + 1 -th iteration. ๐‘“๐‘– is the current flow, and ๐‘ is the path found in ๐บ๐‘“๐‘– at the ๐‘– + 1 -thiteration.

โ–ช We say that an edge (๐‘ข, ๐‘ฃ) is critical if the amount of flow pushed along ๐‘ is ๐‘๐‘“๐‘–(๐‘ข, ๐‘ฃ).

โ–ช A critical edge disappears in ๐บ๐‘“๐‘–+1 , but it may reappear in the futureโ€ฆ

โ–ช We will try to bound the number of times (๐‘ข, ๐‘ฃ) becomes critical.

Between two โ€œcriticalโ€

๐‘  ๐‘ก

๐‘ข ๐‘ฃ

๐‘

A flow along ๐‘ in ๐บ๐‘“๐‘– where (๐‘ข, ๐‘ฃ) becomes critical

๐‘  ๐‘ก

๐‘ข ๐‘ฃIn ๐บ๐‘“๐‘–+1, (๐‘ข, ๐‘ฃ) disappears, and (๐‘ฃ, ๐‘ข) appears.

Before the next time (๐‘ข, ๐‘ฃ) becomes critical again, (๐‘ข, ๐‘ฃ) must first reappear!

๐‘  ๐‘ก

๐‘ข ๐‘ฃBefore (๐‘ข, ๐‘ฃ) reappears, the algorithm must have found ๐‘ going through (๐‘ฃ, ๐‘ข).

Between two โ€œcriticalโ€

๐‘  ๐‘ก

๐‘ข ๐‘ฃ

๐‘

๐‘  ๐‘ก

๐‘ข ๐‘ฃ

dist๐‘– ๐‘ฃ = dist๐‘– ๐‘ข + 1

dist๐‘–+๐‘— ๐‘ข = dist๐‘–+๐‘— ๐‘ฃ + 1

โ–ช Distance monotonicity: dist๐‘–+๐‘— ๐‘ฃ โ‰ฅ dist๐‘– ๐‘ฃ .

โ–ช Thus, dist๐‘–+๐‘— ๐‘ข = dist๐‘–+๐‘— ๐‘ฃ + 1 โ‰ฅ dist๐‘– ๐‘ฃ + 1 โ‰ฅ dist๐‘– ๐‘ข + 2.

โ–ช The distance of ๐‘ข from ๐‘  increases by 2 between two โ€œcriticalโ€.

Putting Together

โ–ช The distance of ๐‘ข from ๐‘  increases by 2 between two โ€œcriticalโ€.

โ–ช Distance takes value from 0, 1,โ€ฆ , ๐‘‰ ,โˆž , and never decrease.

โ–ช Thus, each edge can only be critical for ๐‘‚( ๐‘‰ ) times.

โ–ช At least 1 edge become critical in one iteration.

โ–ช Total number of iterations is ๐‘‚( ๐‘‰ โ‹… ๐ธ ).

โ–ช Each iteration takes ๐‘‚ ๐ธ time.

โ–ช Overall time complexity for Edmonds-Karp: ๐‘‚ ๐‘‰ โ‹… ๐ธ 2 .

โ–ช It can handle the issue with irrational numbers!

Can we improve?

โ–ช Each iteration takes ๐‘‚ ๐ธ time to find a shortest ๐‘ -๐‘ก path by BFS.

โ–ช However, each shortest ๐‘ -๐‘ก path has length at most |๐‘‰|.

โ–ช Idea: push flow from multipleshortest ๐‘ -๐‘ก paths in one iteration!

Dinicโ€™s Algorithm (Dinitzโ€™s Algorithm)

โ–ช Proposed by Yefim Dinitz

โ–ช Updated by Shimon Even and Alon Itai

โ–ช Time complexity: ๐‘‚ ๐‘‰ 2 โ‹… ๐ธ

Dinicโ€™s Algorithm โ€“ high-level ideas

โ–ช Build a level graph:โ€“ Vertices at Level ๐‘– are at distance ๐‘–.

โ€“ Only edges go from a level to the next level are kept.

โ€“ Can be done in ๐‘‚ ๐ธ time using a similar idea to BFS.

3

3

4

10

2

1

1

5

1

2

5

s

a

d

c

e

b

t3

3

4

2

1

1

5

2

5

s

a

d

c

e

b

t

Level 1 Level 2 Level 3

Dinicโ€™s Algorithm โ€“ high-level ideas

โ–ช Find a blocking flow on the level graph:โ€“ Push flow on multiple ๐‘ -๐‘ก paths.

โ€“ Each ๐‘ -๐‘ก path must contain a critical edge!

3

2/3

4/4

2/2

1

1

4/5

2/2

4/5

s

a

d

c

e

b

t

Level 1 Level 2 Level 3

Dinicโ€™s Algorithm โ€“ high-level ideas

โ–ช Find a blocking flow on the level graph:โ€“ Push flow on multiple ๐‘ -๐‘ก paths.

โ€“ Each ๐‘ -๐‘ก path must contain a critical edge!

1/3

1/3

4/4

1/2

1/1

1

4/5

2/2

4/5

s

a

d

c

e

b

t

a blocking flow

1/3

3

4/4

2

1/1

1

4/5

1/2

4/5

s

a

d

c

e

b

t

not a blocking flow: path s-a-b-t contains no critical edge

Dinicโ€™s Algorithm โ€“ Overview

โ–ช Initialize ๐‘“ to be the empty flow and ๐บ๐‘“ = ๐บ.

โ–ช Iteratively do the followings until dist ๐‘ก = โˆž:

โ€“ Construct the level graph ๐บ๐ฟ๐‘“ for ๐บ๐‘“.

โ€“ Find a blocking flow on ๐บ๐ฟ๐‘“.

โ€“ Update ๐‘“ and ๐บ๐‘“.

Questions Remain

1. How many iterations do we need before termination?

2. How do we find a blocking flow?

Questions Remain

1. How many iterations do we need before termination?

2. How do we find a blocking flow?

Simple yet important observations

โ–ช In the level graph ๐บ๐ฟ๐‘“๐‘– at every iteration ๐‘–, every ๐‘ -๐‘ก path has

length dist๐‘– ๐‘ก .

โ–ช Every shortest ๐‘ -๐‘ก path in ๐บ๐‘“๐‘– also appears in ๐บ๐ฟ๐‘“๐‘–.

ts

๐บ๐ฟ๐‘“๐‘–

Distance Monotonicity

โ–ช After one iteration, a new edge (๐‘ข, ๐‘ฃ) appearing in ๐บ๐‘“๐‘–+1

(but not in ๐บ๐‘“๐‘–) must be โ€œbackwardโ€: dist๐‘– ๐‘ข = dist๐‘– ๐‘ฃ + 1.

ts

Level ๐‘˜ Level ๐‘˜ + 1

๐บ๐ฟ๐‘“๐‘–

u

vA new edge that will appear in ๐บ๐‘“๐‘–+1

Distance Monotonicity

โ–ช After one iteration, a new edge (๐‘ข, ๐‘ฃ) appearing in ๐บ๐‘“๐‘–+1

(but not in ๐บ๐‘“๐‘–) must satisfy dist๐‘– ๐‘ข = dist๐‘– ๐‘ฃ + 1.

โ–ช Such additions of edges cannot reduce the distance for any vertex!

โ–ช We again have that dist(๐‘ข) is non-decreasing!

โ–ช Can we have strong monotonicity?

Taking a closer lookโ€ฆ

โ–ช All the paths in ๐บ๐ฟ๐‘“๐‘– with length dist๐‘–(๐‘ก) are โ€œblockedโ€ after

the ๐‘–-th iteration.

โ–ช Thus, a path in the (๐‘– + 1)-th iteration must use some edges that are not in ๐บ๐ฟ

๐‘“๐‘–.

Taking a closer lookโ€ฆ

โ–ช This new edge may be a โ€œbackwardโ€ edge whose reverse was a critical edge in the previous iteration.

โ–ช In this case, dist(๐‘ก) is increased by at least 2.

ts

๐บ๐ฟ๐‘“๐‘–

Taking a closer lookโ€ฆ

โ–ช Or, it may be an edge in ๐บ๐‘“๐‘–, but not in ๐บ๐ฟ๐‘“๐‘–.

โ–ช In this case, dist(๐‘ก) is increased by at least 1.

ts

๐บ๐ฟ๐‘“๐‘–

Taking a closer lookโ€ฆ

โ–ช In both cases: dist๐‘–+1 ๐‘ก > dist๐‘–(๐‘ก)

โ–ช Letโ€™s prove it rigorously thenโ€ฆ

Proving dist๐‘–+1 ๐‘ก > dist๐‘–(๐‘ก)

โ–ช Consider an arbitrary ๐‘ -๐‘ก path ๐‘ in ๐บ๐ฟ๐‘“๐‘–+1 with length dist๐‘–+1(๐‘ก).

โ–ช We have dist๐‘–+1 ๐‘ก โ‰ฅ dist๐‘–(๐‘ก) by monotonicity.

โ–ช Suppose for the sake of contraction that dist๐‘–+1 ๐‘ก = dist๐‘–(๐‘ก).

โ–ช Case 1: all edges in ๐‘ also appear in ๐บ๐ฟ๐‘“๐‘–

โ–ช Then ๐‘ is a shortest path containing no critical edges in ๐บ๐ฟ๐‘“๐‘–

โ–ช Contracting to the definition of blocking flow!

Proving dist๐‘–+1 ๐‘ก > dist๐‘–(๐‘ก)

โ–ช Case 2: ๐‘ contains an edge (๐‘ข, ๐‘ฃ) that is not in ๐บ๐ฟ๐‘“๐‘–

โ–ช If (๐‘ข, ๐‘ฃ) was not in ๐บ๐‘“๐‘–, then (๐‘ฃ, ๐‘ข) was critical in the last iteration. We have dist๐‘– ๐‘ข = dist๐‘– ๐‘ฃ + 1.

โ–ช If (๐‘ข, ๐‘ฃ) was in ๐บ๐‘“๐‘– but not ๐บ๐ฟ๐‘“๐‘–, by the definition of level

graph, we have dist๐‘– ๐‘ข โ‰ฅ dist๐‘– ๐‘ฃ .

โ–ช In both cases above, dist๐‘– ๐‘ข โ‰ฅ dist๐‘– ๐‘ฃ .

โ–ช We have dist๐‘–+1 ๐‘ข โ‰ฅ dist๐‘–(๐‘ข) by monotonicity,

โ–ช and we have dist๐‘–+1 ๐‘ฃ, ๐‘ก โ‰ฅ dist๐‘–(๐‘ฃ, ๐‘ก). (why?)

Proving dist๐‘–+1 ๐‘ก > dist๐‘–(๐‘ก)

โ–ช Case 2: ๐‘ contains an edge (๐‘ข, ๐‘ฃ) that is not in ๐บ๐ฟ๐‘“๐‘–

โ–ช Fact i: dist๐‘– ๐‘ข โ‰ฅ dist๐‘– ๐‘ฃ .

โ–ช Fact ii: dist๐‘–+1 ๐‘ข โ‰ฅ dist๐‘– ๐‘ข .

โ–ช Fact iii: dist๐‘–+1 ๐‘ฃ, ๐‘ก โ‰ฅ dist๐‘–(๐‘ฃ, ๐‘ก).

Putting together:dist๐‘–+1 ๐‘ก = dist๐‘–+1 ๐‘ข + 1 + dist๐‘–+1(๐‘ฃ, ๐‘ก)

โ‰ฅ dist๐‘– ๐‘ข + 1 + dist๐‘–(๐‘ฃ, ๐‘ก)

โ‰ฅ dist๐‘– ๐‘ฃ + 1 + dist๐‘–(๐‘ฃ, ๐‘ก)

โ‰ฅ dist๐‘– ๐‘ก + 1

(Fact ii and iii)

(Fact i)

(triangle inequality)

Putting Togetherโ€ฆ

โ–ช dist(๐‘ก) is increased by at least 1 after each iteration.

โ–ช dist(๐‘ก) takes value from {0, 1, โ€ฆ , ๐‘‰ ,โˆž}, so it can be increased for at most ๐‘‚ ๐‘‰ times.

โ–ช Total number of iterations is at most ๐‘‚ ๐‘‰ .

Questions Remain

1. How many iterations do we need before termination?โ€“ ๐‘‚ ๐‘‰

2. How do we find a blocking flow?

Finding a blocking flow in a level graphโ€ฆ

Iteratively do the followings, until no path from ๐‘  to ๐‘ก:

โ–ช Find an arbitrary maximal path in ๐บ๐ฟ๐‘“ starting from ๐‘ :

โ€“ At every vertex, find an arbitrary edge in ๐บ๐ฟ๐‘“ and append it to the

path.

โ–ช Two possibilities:โ€“ End up at ๐‘ก: in this case, we update ๐‘“ (by pushing flow along the

path) and remove the critical edge

โ€“ End up at a dead-end, a vertex ๐‘ฃ with no out-going edges in ๐บ๐ฟ๐‘“: in

this case, we remove all the incoming edges of ๐‘ฃ

Finding a blocking flow in a level graphโ€ฆ

โ–ช At least one edge is removed after each search.โ€“ Total number of searches: ๐‘‚ ๐ธ

โ–ช Each search takes at most |๐‘‰| steps.

โ–ช Time complexity for each iteration of Dinicโ€™s algorithm: ๐‘‚ ๐‘‰ โ‹… ๐ธ .

Overall Time Complexity for Dinicโ€™s Algorithm

โ–ช Each iteration: ๐‘‚ ๐‘‰ โ‹… ๐ธ .

โ–ช We need at most ๐‘‚ ๐‘‰ iterations.

โ–ช Overall time complexity for Dinicโ€™s algorithm: ๐‘‚ ๐‘‰ 2 โ‹… ๐ธ .

Other Algorithms for Max-Flow

โ–ช Improvements to Dinicโ€™s algorithm:โ€“ [Malhotra, Kumar & Maheshwari, 1978]: ๐‘‚ ๐‘‰ 3

โ€“ Dynamic tree: ๐‘‚ ๐‘‰ โ‹… ๐ธ โ‹… log ๐‘‰

โ–ช Push-relabel algorithm [Goldberg & Tarjan, 1988]

โ€“ ๐‘‚ ๐‘‰ 2 ๐ธ , later improved to ๐‘‚ ๐‘‰ 3 , ๐‘‚ ๐‘‰ 2 ๐ธ , ๐‘‚ ๐‘‰ ๐ธ log๐‘‰ 2

๐ธ

โ–ช [King, Rao & Tarjan, 1994] and [Orlin, 2013]: ๐‘‚ ๐‘‰ โ‹… ๐ธ

โ–ช Interior-point-method-based algorithms:

โ€“ [Kathuria, Liu & Sidford, 2020] ๐ธ4

3+๐‘œ(1)๐‘ˆ

1

3

โ€“ [BLNPSSSW, 2020] [BLLSSSW, 2021] เทจ๐‘‚ ๐ธ + ๐‘‰3

2 log๐‘ˆ

โ€“ [Gao, Liu & Peng, 2021] เทจ๐‘‚ ๐ธ3

2โˆ’

1

328 log๐‘ˆ

Hopcroftโ€“Karpโ€“Karzanov algorithm

โ–ช Find a maximum bipartite matching in ๐‘‚ ๐ธ โ‹… ๐‘‰ time.

โ–ช Proposed independently by Hopcroft-Karp and Karzanov.

โ–ช Can be viewed as a special case of Dinicโ€™s algorithm.

Conversion to Max-Flow Problem

s

t

1111

1

1111111

1 11

11

11

1 1

1

Set the capacity to 1 for all edges.

Conversion to Max-Flow Problem

s

t

1111

1

1111111

1 11

11

11

1 1

1

Dinicโ€™s algorithm runs in ๐‘‚ ๐ธ โ‹… ๐‘‰ time for this special case.

Conversion to Max-Flow Problem

โ–ช Integrality theorem also holds for Dinicโ€™s algorithm:โ€“ The flow output by Dinicโ€™s algorithm in our case is integral.

โ–ช We aim to show Dinicโ€™s algorithm runs in ๐‘‚ ๐ธ โ‹… ๐‘‰ time.

โ–ช Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธtime.

โ–ช Step 2: Number of iterations is at most 2 ๐‘‰ .

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

Iteratively do the followings, until no path from ๐‘  to ๐‘ก:

โ–ช Perform DFS from ๐‘ 

โ–ช If we reach ๐‘ก, delete all edges on the ๐‘ -๐‘ก path (why can we do this?) and start over from ๐‘ .

โ–ช If we ever go backward, delete the edge just travelled. (why can we do this?)

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

An ๐‘ -๐‘ก path is found, remove all edges from the path.

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Start overโ€ฆ

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

We have to go backward now; delete the edge just travelled.

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Again, we have to go backward; delete the edge just travelled.

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Again, we have to go backward; delete the edge just travelled.

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Again, we have to go backward; delete the edge just travelled.

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

Find another ๐‘ -๐‘ก path; delete all edges on the path

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

We are done!

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

s t

We have obtained a blocking flow!

Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธ time.

Time complexity: ๐‘‚ ๐ธ

โ–ช Each edge is visited at most once.

Step 2: Number of iterations is at most 2 ๐‘‰ .

โ–ช If the algorithm terminates within ๐‘‰ iterations, we are already done!

โ–ช Otherwise, let ๐‘“ be the flow after ๐‘‰ iterations.

โ–ช Claim: the maximum flow in ๐บ๐‘“ has value at most ๐‘‰ .

Observation on ๐บ๐‘“

โ–ช In each iteration, for each ๐‘ฃ โˆˆ ๐‘‰ โˆ– {๐‘ , ๐‘ก}, either its in-degree is 1, or its out-degree is 1.

โ–ช Proof. By Inductionโ€ฆ

โ–ช At the beginning, this is clearly true.

t

s

1111

1

111111

1 11

11

11

1

1

in-degree = 1

out-degree = 1

Observation on ๐บ๐‘“

โ–ช In each iteration, for each ๐‘ฃ โˆˆ ๐‘‰ โˆ– {๐‘ , ๐‘ก}, either its in-degree is 1, or its out-degree is 1.

โ–ช Proof. At the beginning, this is clearly true.

โ–ช For each iteration, the amount of flow going through ๐‘ฃ is either 0 or 1.

โ–ช If it is 0, ๐‘ฃโ€™s in-degree and out-degree are unchanged.

โ–ช Otherwise, exactly one in-edge and one out-edge are flipped; the property is still maintained.

The maximum flow in ๐บ๐‘“ has value at most ๐‘‰

โ–ช Integrality Theorem: there exists a maximum integral flow ๐‘“โ€ฒ in ๐บ๐‘“.

โ–ช ๐‘“โ€ฒ consists of edge-disjoint paths.

โ–ช Edge-disjointness implies vertex-disjointness by previous observation on ๐บ๐‘“.

s t s t

violating flow conservation

The maximum flow in ๐บ๐‘“ has value at most ๐‘‰

โ–ช Max-flow on ๐บ๐‘“, ๐‘“โ€ฒ, is integral and consists of edge-disjoint paths.

โ–ช By our analysis to Dinicโ€™s algorithm, dist๐บ๐‘“๐‘ , ๐‘ก โ‰ฅ ๐‘‰ .

โ–ช Each path in ๐‘“โ€ฒ has length at least ๐‘‰ .

โ–ช There are at most ๐‘‰

๐‘‰= ๐‘‰ paths in ๐‘“โ€ฒ by vertex-disjointness.

โ–ช ๐‘ฃ ๐‘“โ€ฒ โ‰ค ๐‘‰

Step 2: Number of iterations is at most 2 ๐‘‰ .

โ–ช If the algorithm terminates within ๐‘‰ iterations, we are already done!

โ–ช Otherwise, let ๐‘“ be the flow after ๐‘‰ iterations.

โ–ช Claim: the maximum flow in ๐บ๐‘“ has value at most ๐‘‰ .

โ–ช Each iteration increase the value of flow by at least 1.

โ–ช Thus, the algorithm will terminates within at most another ๐‘‰ iterations.

โ–ช Total number of iterations: 2 ๐‘‰ .

Putting Togetherโ€ฆ

โ–ช Step 1: Finding a blocking flow in a level graph takes ๐‘‚ ๐ธtime.

โ–ช Step 2: Number of iterations is at most 2 ๐‘‰ .

โ–ช Overall time complexity: ๐‘‚ ๐ธ โ‹… ๐‘‰

Todayโ€™s Lecture

Maximum Flow Problem:

โ–ช Edmonds-Karp Algorithmโ€“ Implement Ford-Fulkerson method by BFS

โ€“ ๐‘‚ ๐‘‰ โ‹… ๐ธ 2

โ–ช Dinicโ€™s Algorithmโ€“ Push flow on multiple paths at one iterationโ€“ Level graph and blocking flow

โ€“ ๐‘‚ ๐‘‰ 2 โ‹… |๐ธ|

Maximum Bipartite Matching Problem:

โ–ช Hopcroftโ€“Karpโ€“Karzanov algorithmโ€“ Apply Dinicโ€™s algorithm

โ€“ ๐‘‚ ๐ธ โ‹… ๐‘‰