+ All Categories
Home > Documents > Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important...

Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important...

Date post: 25-Jun-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
69
Max-flow and min-cut
Transcript
Page 1: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Max-flow and min-cut

Page 2: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Max-Flow and Min-Cut

Two important algorithmic problems, which yield a beautifulduality

Myriad of non-trivial applications, it plays an important role in theoptimization of many problems:Network connectivity, airline schedule (extended to all means oftransportation), image segmentation, bipartite matching,distributed computing, data mining, · · · · · ·

Page 3: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Flow Networks

Network diagraph G = (V ,E ) s.t. it has

I source vertex s ∈ V

I sink vertex t ∈ V

I edge capacities c : E → R+ ∪ 0

1

a

s t

b

2

21

1

2

Flow f : V × V → R+ ∪ 0 s.t.Kirchoff’s laws:

I ∀(u, v) ∈ E , 0 ≤ f (u, v) ≤ c(u, v),

I (Flow conservation) ∀v ∈ V − s, t,∑u∈V f (u, v) =

∑z∈V f (v , z)

I The value of a flow

|f | =∑v∈V

f (s, v) = f (s,V ) = f (V , t).Value |f|=3

a

s t

b

2

1

2 1

2/ 1

21/ 2/

1/

1/

Page 4: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

The Maximum flow problem

INPUT: Given a flow network (G = (V ,E ), s, t, c)QUESTION: Find a flow of maximum value on G .

2/2

S

A D

T

E

B

C

2/2

5/5

5/5

1/1

1/5

0/9

0/3

2/4

4/41/2

The value of the max-flow is 7 = 4 + 1 + 2 = 5 + 2.

Notice: Although the flow exiting s is not maximum, the flowgoing into t is maximum (= max. capacity).Therefore the total flow is maximum.

Page 5: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

The s − t cut

Given (G = (V ,E ), s, t, c) a s − t cut is a partition of V = S ∪ Tso S ∩ T = ∅), with s ∈ S and t ∈ T .

The flow across the cut:f (S) =

∑u∈S

∑v∈T f (u, v)−

∑v∈S

∑u∈T f (v , u).

The capacity of the cut: c(S) =∑

u∈S∑

v∈T f (u, v)

capacity of cut (S ,T ) = sum of weights leaving S .

Notice because of the capacity constrain: f (S) ≤ c(S)

f(S,T)=(2+1+5)+(0+2−1−2)=7

2/2

5/5

5/5

1/1

1/5

0/9

0/3

2/4

4/41/2

s

c e

t

d

b

a

T=a,b,e,t

S = s,c,d

2/2

c(S,T)=(4+5+5)+(3+2)=19

Page 6: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

The s − t cut

Given (G = (V ,E ), s, t, c) a s − t cut is a partition of V = S ∪ Tso S ∩ T = ∅), with s ∈ S and t ∈ T .

The flow across the cut:f (S) =

∑u∈S

∑v∈T f (u, v)−

∑v∈S

∑u∈T f (v , u).

The capacity of the cut: c(S) =∑

u∈S∑

v∈T f (u, v)

Notice because of the capacity constrain: f (S) ≤ c(S)

2/2

2/2

5/5

5/5

1/1

1/5

0/9

0/3

2/4

4/41/2

s

c e

t

d

b

aS = s,c,a

T=d,b,e,t

c(S,T)=2+5+5=12

f(S,T)=2+1+5−1=7

Page 7: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

NotationGiven v ∈ G and cut (S ,T ) and a v ∈ S , let S ′ = S − v. Then

I Denote f (S ′,T ) flow between S ′ and T (without passing byv), i.e.f (S ′,T ) =

∑u∈S ′

∑w∈T f (u,w)−

∑w∈T

∑u∈S ′ f (w , u)

with (u,w) ∈ E and (u,w) ∈ E ,

I denote f (v ,T ) flow v → T i.e. f (v ,T ) =∑

u∈T f (v , u),

I denote f (T , v) flow T → v i.e. f (T , v) =∑

u∈T f (u, v),

I denote f (S ′, v) flow S ′ → v i.e. f (S ′, v) =∑

u∈S ′ f (u, v),

I denote f (v ,S ′) flow v → S ′ i.e. f (v ,S ′) =∑

u∈S ′ f (v , u),

ts

v

T

S

S’

Page 8: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Any s − t cut has the same flow

TheoremGiven (G , s, t, c) the flow through any s − t cut (S ,T ) isf (S) = |f |.Proof (Induction on |S |)I If S = s then f (S) = |f |.I Assume it is true for S ′ = S − v, i.e. f (S ′) = |f |.

Notice f (S ′) = f (S ′,T ) + f (S ′, v)− f (v , S ′). Moreover fromthe flow conservation, f (S ′, v) + f (T , v) = f (v , S ′) + f (v ,T )⇒ f (v ,T )− f (T , v) = f (S ′, v)− f (v ,S ′)︸ ︷︷ ︸

∗I Then f (S) = f (S ′,T ) + f (v ,T )− f (T , v), using (∗)

f (S) = f (S ′) = |f | 2

ts

v

T

S

S’

Page 9: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Residual network

Given a network (G = (V ,E ), s, t, c) together with a flow f on it,the residual network, (Gf = (V ,Ef ), cf ) is the network with thesame vertex set and edge set:

I if c(u, v)− f (u, v) > 0 then (u, v) ∈ Ef andcf (u, v) = c(u, v)− f (u, v) > 0 (forward edges), and

I if f (u, v) > 0 then (v , u) ∈ Ef and cf (v , u) = f (u, v)(backward edges). i.e. there are f (u, v) units of flow we canundo, by pushing flow backward

I the cf are denoted residual capacity.

s

a

s t

b

2/3

2/2

0/1

0/1

2/2a

t

b

2

2

21

1

1

Gf

Page 10: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Residual network: Augmenting paths

Given G = (V ,E ) and a flow f on G , an augmenting path P isany simple path in Gf (using forward and backward edges, butP : s t).

Given f : s t in G and P in Gf define the bottleneck (P, f ) to bethe minimum residual capacity of any edge in P, with respect to f .

1/3

a

t

b

s

1

1

2

1

2

2

a

t

b

2

2

1s 2

1

1

P: dotted line

GfG

a

t

b

s

11/

1/1 2/2

2/2

Page 11: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Residual network: Augmenting paths

Given G = (V ,E ) and a flow f on G , an augmenting path P isany simple path in Gf .

Given f s → t in G and P in Gf define the bottleneck (P, f ) to bethe minimum residual capacity of any edge in P.

Augment(P, f )b=bottleneck (P, f )for each (u, v) ∈ P do

if (u, v) is forward edge in G thenIncrease f (u, v) in G by b

elseDecrease f (u, v) in G by b

end ifend forreturn f

f’

a

s t

b

1/3

1/1 2/2

/22 1/1

Page 12: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Residual network: Augmenting paths

LemmaConsider f ′ =Augment(P, f ), then f ′ is a flow in G .

Proof: We have to prove that (1) ∀e ∈ E , 0 ≤ f (e) ≤ c(e) andthat ∀v flow to v = flow out of v .

I Capacity law Forward edges (u, v) ∈ P we increase f (u, v) byb, as b ≤ c(u, v)− f (u, v) thenf ′(u, v) = f (u, v) + b ≤ c(u, v).Backward edges (u, v) ∈ P we decrease f (v , u) by b, asb ≤ f (v , u), f ′(v , u) = f (u, v)− b ≥ 0.

I Conservation law, ∀v ∈ P given edges e1, e2 in P and incidentto v , it is easy to check the 4 cases based whether e1, e2 areforward or backward edges. 2

Page 13: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Max-Flow Min-Cut theorem

TheoremFor any (G , s, t, c) the value of the max flow f ∗ is equal to thecapacity of the min s − t-cut (over all s − t cuts in G )

This is typical example of LP duality!Proof:

I For any s − t cut (S ,T ) in G ⇒ f (S) ≤ c(S ,T ).

I Suppose by hypothesis that f ∗ in G is a max flow, i.e. f ∗ hasno augmenting path, then Gf ∗ has no s ; t path. LetSs = v ∈ V |∃s ; v in Gf ∗, notice t 6∈ Ss and moreover(Ss ,V − Ss) is a s − t cut in Gf ∗ ⇒ ∀v ∈ Ss , u ∈ V − Sswe have not residual edges in the cut, so that in Gf ∗(v , u) = c(v , u), and thereforec(Ss ,V − Ss) = f ∗(Ss ,V − Ss) in G .

I As any max-flow must be ≤ min-cut, then in particular(Ss ,V − Ss) is a min-cut in G and it is equal to themax-flow f ∗. 2

Page 14: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Ford-Fulkerson algorithm

L.R. Ford, D.R. Fulkerson:Maximal flow through anetwork. Canadian J. of Math.1956.

Ford-Fulkerson(G , s, t, c)for all (u, v) ∈ E let f (u, v) = 0Gf = Gwhile there is an s − t path in Gf do

find a simple path P in Gf (use DFS)f ′ = Augment(f ,P)Update f to f ′

Update Gf to Gf ′

end whilereturn f

30

G f=0

Gf

P

a

s t

b

a

s t

b

0/300/10

0/10

0/20 0/15

15

10

10

20

Page 15: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Ford-Fulkerson algorithm

L.R. Ford, D.R. Fulkerson:Maximal flow through anetwork. Canadian J. of Math.1956.

Ford-Fulkerson(G , s, t, c)for all (u, v) ∈ E let f (u, v) = 0Gf = Gwhile there is an s − t path in Gf do

find a simple path P in Gf (use DFS)f ′ = Augment(f ,P)Update f to f ′

Update Gf to Gf ′

end whilereturn f

20

G

Gf

P

a

s t

b

a

s t

b

0/10

0/20 0/15

10/10 10/30

10

10

20

f=10

15

10

Page 16: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Ford-Fulkerson algorithm

L.R. Ford, D.R. Fulkerson:Maximal flow through anetwork. Canadian J. of Math.1956.

Ford-Fulkerson(G , s, t, c)for all (u, v) ∈ E let f (u, v) = 0Gf = Gwhile there is an s − t path in Gf do

find a simple path P in Gf (use DFS)f ′ = Augment(f ,P)Update f to f ′

Update Gf to Gf ′

end whilereturn f 5

G

Gf

P

a

s t

b

a

s t

b

0/10

10/10 10/30

10

10

20

15/20 15/15

f=25

15

10

15

Page 17: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Ford-Fulkerson algorithm

L.R. Ford, D.R. Fulkerson:Maximal flow through anetwork. Canadian J. of Math.1956.

Ford-Fulkerson(G , s, t, c)for all (u, v) ∈ E let f (u, v) = 0Gf = Gwhile there is an s − t path in Gf do

find a simple path P in Gf (use DFS)f ′ = Augment(f ,P)Update f to f ′

Update Gf to Gf ′

end whilereturn f

20/20

G

Gf

a

s t

b

a

s t

b

10/10

10

15/15

15

10

15

5

15/30

10/10 f=30

15

15

No P

Page 18: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Analysis of Ford Fulkerson

We are considering networks that initial flow and capacities areintegers,

Lemma (Integrality invariant)

At every iteration of the Ford-Fulkerson algorithm, the flow valuesf (e) and the residual capacities in Gf are integers.

Proof: (induction)

I The statement is true before the while loop.

I Inductive Hypothesis: The statement is true after j iterations.

I iteration j + 1: As all residual capacities in Gf are integers,then bottleneck (P, f ) ∈ Z, for the augmenting path found initeration j + 1. Thus the flow f ′ will have integer values ⇒ sowill the capacities in the new residual graph. 2

Page 19: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Integrality theorem

Theorem (Integrality theorem)

There exists a max-flow f ∗ for which every flow value f ∗ is aninteger.

Proof:Since the algorithm terminates, the theorem follows from theintegrality invariant lemma. 2

Notice the integrality theorem doesn’t say that every max-flow isinteger valued, it only says at least one max-flow has the propertyof being integer valued.

Page 20: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Analysis of Ford Fulkerson

LemmaIf f is a flow in G and f ′ is the flow after an augmentation, then|f | < |f ′|.Proof: Let P be the augmenting path in Gf . The first edge e ∈ Pleaves s, and as G has no incoming edges to s, e is a forward edge.Moreover P is simple ⇒ never returns to s. Therefore, the value ofthe flow increases in edge e. 2

Page 21: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Correctness of Ford-Fulkerson

Consequence of the Max-flow min-cut theorem.

TheoremThe flow returned by Ford-Fulkerson f ∗ is the max-flow.

Proof:

I For any flow f and s − t cut (S ,T ) we have |f | ≤ c(S ,T ).

I The flow f ∗ is such that |f ∗| = c(S∗,T ∗), for some s − t cut(S∗,T ∗) ⇒ f ∗ is the max-flow. 2

Therefore, for any (G , s, t, c) the value of the max s − t flow isequal to the capacity of the minimum s − t cut.

Page 22: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Analysis of Ford Fulkerson: Running time

LemmaLet C be the minimum cut value, Ford-Fulkerson terminates afterfinding at most C augmenting paths.

Proof: The value of the flow increases by ≥ 1 after eachaugmentation. 2

I The number of iterations is ≤ C . At each iteration:

I We have to modify Gf , with E (Gf ) ≤ 2m, to time O(m).

I Using DFS, the time to find an augmenting path P isO(n + m)

I Total running time is O(C (n + m)) = O(Cm)

I Is that polynomic?

Page 23: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Running time of Ford-Fulkerson

The number of iterations ofFord-Fulkerson could be Ω(C )As it is described Ford-Fulkerson canalternate C times between the blueand red paths if the figure.

in a G with 4 vertices!!

a

s t

b

C=1000000000

1/C

1/C

1/1 1/1

2/C

2/C

2000 million iteractions

Recall a pseudopolynomial algorithm is an algorithm that ispolynomial in the unary encoding of the input.

So the complexity of Ford-Fulkerson algorithm is equivalent to thePD Algorithm for 0-1 Knapsack.

Is there a polynomial time algorithm for the max-flow problem?

Page 24: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Edmonds-Karp, Dinic algorithm

J.Edmonds, R. Karp: Theoretical improvements in algorithmicefficiency for network flow problems. Journal ACM 1972.

Y. Dinic: Algorithm for solution of a problem of maximum flow ina network with power estimation. Doklady Ak.N. 1970

Choosing a goodaugmenting path can leadto a faster algorithm.Use BFS to find shorteraugmenting paths in Gf .

Using BFS on Gf we can find the shortest augmenting path P inO(m), independently of max capacity C .

Page 25: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Edmonds-Karp algorithm

Uses BFS to find the augmenting path at each Gf with fewernumber of edges.

Edmonds-Karp(G , s, t, c)For all e = (u, v) ∈ E let f (u, v) = 0G0 = Gwhile there is an s t path in Gf

doP = BFS(Gf , s, t)f ′ = Augment(f ,P)Update Gf = Gf ′ and f = f ′

end whilereturn f

or

a

s t

b

11

CC

C C

The BFS in EK will

choose:

Page 26: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Level graphGiven G = (V ,E ), s, define LG = (V ,EG ) to be its the level graphby:

I `(v) = number of edges in shortest path s v in G ,

I LG = (V ,EG ) is the subgraph of G that contains only edges(v ,w) ∈ E s.t. `(w) = `(v) + 1.

Notice:

I Using BFS we can compute LG in O(n + m)

I Important property: P is a shortest s ; t in G iff P is ans ; t path in LG .

G

s

c e

t

da

42

3

5

5

2 4

2

b5

9 1

1 2 3

c e

t

da

42

5

5

4

2

b5

1

1 2 3

s

G L

Page 27: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

The working of the EK algorithm

4/5

s

c e

t

da

42

2

b5

1

3

9

4

1

4

1

2

G f

s

c e

t

da

42

2

b5

1

3

9

s

c e

t

da

4

2

b

4/4

4/5

4/5

3

9

4/4

4/5

1/5

1/11/2

22

G,f´G,f

t s

c e

da

b

1L

s

c e

t

da

4

2

b

1

3

9

4

1

4

1

2

G

11

1

44

4

4s

c e

da

4

2

b

1L

1/1

1/5

1/2

t3

1/2

1/4

f’

1/1

23

2

Page 28: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

The working of the EK algorithm

5/5

s

c e

t

da

b

1

3

2

1/41/1

1/2

1

s

c e

t

da

b

1

3

9

4

1

4

1

2

G

1

1

4

4

s

c e

t

da

b

1

1

24

111

3

f’’

L f’’

s

c e

t

da

b 3

9

2

1/2

4/4

4/5

4/5

1/12/21/4

1/5

s

c e

t

da

b

9

2

4/4

4/5

2/2

1/5

1

1

1

2/4

2/2

1/1

1/3

G,f’’

G,f*

Page 29: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

EK algorithm: Properties

LemmaThroughout the algorithm, the length of the shortest path neverdecreases.

Proof:I Let f and f ′ be the flow before and after a shortest path

augmentationI let L and L′ be the levels graphs of Gf and Gf ′ .I Only back edges added to Gf ′ . 2

LemmaAfter at most m shortest path augmentations, the length of P ismonotonically increasing.

Proof:I The bottleneck edge is deleted from L after each

augmentation.I No new edge is added to L until length of shortest path

strictly increases 2

Page 30: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Complexity of Edmonds-Karp algorithm

Using the the previous lemmas, we prove

TheoremThe EK algorithms runs in O(m2n) steps. Therefore it is apolynomial time algorithm.

Proof:

I Need time O(m + n) to find the augmenting path using BFS.

I Need O(m) augmentations for paths of length k .

I Every augmentation path is simple ⇒ 1 ≤ k ≤ n ⇒ O(nm)augmentations 2

Page 31: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Finding a min-cut

Given (G , s, t, c) to find a min-cut:

1. Compute the max-flow f ∗ in G .

2. Obtain Gf ∗ .

3. Find the set S = v ∈ V |s ; v in Gf ∗ .

4. Output the cut(S ,V − S) = (v , u)|v ∈ Sandu ∈ V − S in G .

The running time is the same than the algorithm to find themax-flow.

S

2/2

5/5

5/5

1/1

1/5

0/9

0/3

2/4

4/41/2

s

c e

tb

a

2/2d

s

c e

tb

a d

1

19

2

2

4

5

5

2

1

2

4

1

3

Page 32: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

The max-flow problems: History

I Ford-Fulkerson (1956) O(mC ), where C is max capacity.

I Dinic (1970) (blocking flow) O(n2m)

I Edmond-Karp (1972) (shortest augmenting path) O(nm2)

I Karzanov (1974), O(n2m) Goldberg-Tarjant (1986) (pushre-label preflow + dynamic trees) O(nm lg(n2/m)) (for thistime uit uses parallel implementation)

I King-Rao-Tarjan (1998) O(nm logm/n lg n n).

I J. Orlin (2013) O(nm) (clever follow up to KRT-98)

Page 33: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Maximum matching problem

Given an undirected graph G = (V ,E ) a subset of edges M ⊆ E isa matching if each node appears at most in one edge (a node maynot appear at all).

A perfect matching in G is a matching M such that |M| = |V |/2

The maximum matching problem given a graph G a matching withmaximum cardinality.

Page 34: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Maximum matching in graphs bipartiteA graph G = (V ,E ) is said to be bipartite if V can be partite in Land R, L ∪ R = V , L ∩ R = ∅, such that every e ∈ E connects Lwith R.

The max matching bipartite graph problem: given a bipartiteG = (L ∪ R,E ) with 2n vertices find a maximum matching.

Max matchings = 4

Page 35: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Maximum matching: flow formulation

Given a bipartite graph G = (L ∪ R,E ) construct G = (V , E ):

I Add vertices s and t: V = L ∪ R ∪ s, t.I Add directed edges s → L with capacity 1. Add directed

edges R → t with capacity 1.

I Direct the edges E from L to R, and give them capacity ∞.

I E = s → L ∪ E ∪ R → t.

t

1

1 1

1

s

Page 36: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Maximum matching: flow formulation

Given a bipartite graph G = (L ∪ R,E ) construct G = (V , E ):

I Add vertices s and t: V = L ∪ R ∪ s, t.I Add directed edges s → L with capacity 1. Add directed

edges R → t with capacity 1.

I Direct the edges E from L to R, and give them capacity ∞.

I E = s → L ∪ E ∪ R → t.

t

1

1 1

1

s

Page 37: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Maximum matching: Analysis

TheoremMax flow in G=Max bipartite matching in G .

Proof ≤Given a matching M in G with k-edges,consider the flow F that sends 1 unit along each one of the kpaths.f is a flow and has value k .

1

1

1 1

1

s t

1

1

1

1

0

0

1

1

1

1

1

1

1

Page 38: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Maximum matching: Analysis

Max flow ≤Max bipartite matching

I If there is a flow f in G , |f | = k , as capacities are Z∗ ⇒ anintegral flow existsis.

I Consider the cut C = (s ∪ L,R ∪ t) in G .

I Let F be the set of edges in C with flow=1, then |F | = k .

I Each node in L is in at most one e ∈ F and every node in R isin at most one head of an e ∈ F

I Therefore, exists a bipartite matching F in G with |F | ≤ |f | 2

1

1 1

1

s t

1

1

1

1

1

1

1

1

1

1

1

1

0

0

Page 39: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Disjoint path problem

Given a digraph (G = (V ,E ), s, t), a set of paths is edge-disjoint iftheir edges are disjoint (although them may go through some ofthe same vertices)

The disjoint path problem given G , s, t find the max number ofedge disjoint paths s ; t

c

a b

e

st

d

Page 40: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Disjoint path problem

Given a digraph (G = (V ,E ), s, t), a set of paths is edge-disjoint iftheir edges are disjoint (although them may go through some ofthe same vertices)

The disjoint path problem given G , s, t find the max number ofedge disjoint paths s ; t

c

a b

e

st

d

Page 41: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Disjoint path problem: Max flow formulation

Assign unit capacity to every edge

TheoremThe max number of edge disjoint paths s ; t is equal to the maxflow value

Max flow=3

a b

e

st

d

c

a b

e

st

d

c1

1

11

1

1

1

1

1

1

11

1

1

11

1

1

1

1

1

1

1

Page 42: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Disjoint path problem: Proof of the Theorem

Number of disjoints paths ≤ max flowIf we have k edge-disjoints paths s ; t in G then making f (e) = 1for each e in a path, we get a flow = k

Number of disjoints paths ≥ max flowIf max flow |f ∗| = k ⇒ ∃ 0-1 flow f ∗ with value k⇒ ∃k edges (s, v) s.t. f (s, v) = 1, by flow conservation we canextend to k paths s ; t, where each edge is a path carries flow= 1. 2

If we have an undirected graph, with two distinguised nodes u, v ,how would you apply the max flow formulation to solve the problemof finding the max number of disjoint paths between u and t?

Page 43: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Circulation with demands

Given a graph G = (V ,E ) with capacities c in the edges, suchthat each v ∈ V is associate with a demand d(v), where

I If d(v) > 0 ⇒ v is a sink, v canreceive d(v) units of flow morethan it sends.

I If d(v) < 0 ⇒ v is a source, v cansend d(v) units of flow more thanit receives.

I If d(v) = 0 then v is neither asource or a sink.

I Let S be the set of sources and Tthe set of sinks.

−3

2

4

2 2

3 3

2−3

Page 44: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Circulation with demands problem

Given G = (V ,E ) with c ≥ 0 and d(v)v∈V , define a circulationas a function f : E → R+ s.t.

1. capacity: For eache ∈ E , 0 ≤ f (e) ≤ c(e),

2. conservation: For each v ∈ V ,∑(u,v)∈E

f (u, v)−∑

(v ,z)∈E

f (v , z) = d(v). 2/

2

4

2

2

−3

−3

2/ 3

2/

31/

2/ 2

Circulation with demands feasibility problem: Given G = (V ,E )with c ≥ 0 and d(v)v∈V , does it exists a feasible circulation?Feasible circulation: a function f on G with c ≥ 0 and d(v)v∈V ,such that it satisfies (1) and (2)?

Page 45: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Circulation with demands problem

Notice that if f is a feasible circulation, then

∑v∈V

d(v) =∑v∈V

(u,v)∈E

f (u, v)

︸ ︷︷ ︸edges to v

−∑

(v ,z)∈E

f (v , z)

︸ ︷︷ ︸edges out of v

.

For each e ∈ E we are counting twice f (e), then∑

v∈V d(v) = 0.And we have,So If there is a feasible circulation with demands d(v)v∈V , then∑

v∈V d(v) = 0.

Therefore as S = v ∈ V |d(v) > 0and T = v ∈ V |d(v) < 0, thenD =

∑v∈S d(v) =

∑v∈T d(v).

2/

2

4

2

2

−3

−3

2/ 3

2/

31/

2/ 2

Page 46: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Circulation with demands: Max-flow formulation

Extend G = (V ,E ) to G ′ = (V ′,E ′) by

I Add new source s and sink s.

I For each v ∈ S (d(v) < 0) add (s, v) with capacity −d(v).

I For each v ∈ T (d(v) > 0) add (v , s) with capacity d(v).

G2

4

2

2

−3

−3

3

2

3

2

4

2

2

−3

−3

33

s

t

2

3

3

2

4T

S

G’

Page 47: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Analysis

1.- Every flow f : s ; t in G ′ must be |f | ≤ DThe capacity c(s,V ) = D ⇒ by max-flow min-cut Thm. anymax-flow f in G ′, |f | ≤ D.

2.- If there is a feasible circulation f with d(v)v∈V in G , then wehave a max-flow f : s ; t in G with |f | = D∀(s, v) ∈ E ′, f ′(s, v) = −d(v) and ∀(u, t) ∈ E ′, f ′(u, t) = d(v).

2G’G2

4

2

−3

−3

33

s

t

3

3

4

1/

2/

2/

2

4

2

2

−3

−3

3

2/ 2

2/ 3

4/

3/

3/

1/

2/

2/

2/2/2/ 2

2

Page 48: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Analysis

3.- If there is a flow f ′ : s ; t in G ′ with |f | = D:

1. ∀(s, v) ∈ E ′ and ∀(u, t) ∈ E ′ must be saturated ⇒ if wedelete these edges in G ′ we obtain a circulation f in G .

2. f satisfies d(v) =∑

(u,v)∈E

f (u, v)

︸ ︷︷ ︸edges to v

−∑

(v ,z)∈E

f (v , z)

︸ ︷︷ ︸edges out of v

.

2G’G2

4

2

−3

−3

33

s

t

3

3

4

1/

2/

2/

2

4

2

2

−3

−3

3

2/ 2

2/ 3

4/

3/

3/

1/

2/

2/

2/2/2/ 2

2

Page 49: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Main results

Theorem (Circulation integrality theorem)

If all capacities and demands are integers, and there exists acirculation, then there exists an integer valued circulation.

Sketch Proof Max-flow formulation + integrality theorem formax-flow 2

From the previous discussion, we can conclude:

Theorem (Necessary and sufficient condition)

There is a feasible circulation with d(v)v∈V in G iff themax-flow in G ′ has value D.

Page 50: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Circulations with demands and lower bounds: Max-flowformulation

Generalization of the previous problem: besides satisfy demands atnodes, we want to force the flow to use certain edges.Introduce a new constrain `(e) on each e ∈ E , indicating themin-value the flow must be on e.

Given G = (V ,E ) with c(e), c(e) ≥ `(e) ≥ 0, for each e ∈ E andd(v)v∈V , define a circulation as a function f : E → R+ s.t.

1. capacity: For each e ∈ E ,`(e) ≤ f (e) ≤ c(e),

2. conservation: For each v ∈ V ,∑(u,v)∈E

f (u, v)−∑

(v ,z)∈E

f (v , z) = d(v).

[

2

4

2 2

3

2−3

−3

3]2,

Circulation problems with lower bounds: Given (G , c , `, d(v)),does there exists a feasible circulation?

Page 51: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Circulations with demands and lower bounds:Max-flow formulation

Let (G = (V ,E ), c , `, d(·)) be a graph, constructG ′ = (V ,E ), c ′, d ′), where for each e = (u, v) ∈ E , with `(e) > 0:

I c ′(e) = c(e)− `(e) (sent `(e) units along e).

I Update the demands on both ends of e (d ′(u) = d(u) + `(e)and d ′(v) = d(v)− `(e))

G’2

4

2 2

3

2−3

−3

3]2,[

2

4

2 2

3

2

1

−5

−1

G

Page 52: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Main result

TheoremThere exists a circulation in G iff there exists a circulation in G ′.Moreover, if all demands, capacities and lower bounds in G areintegers, then there is a circulation in G that is integer-valued.

Sketch Proof Need to prove f (e) is a circulation in G ifff ′(e) = f (e)− `(e) is a circulation in G ′.The integer-valued circulation part is a consequence of theinteger-value circulation Theorem for f ′ in G ′. 2

Page 53: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Survey design problemProblem:Design a survey among customers of productsI Each customer will receive questions about some products.I Each customer i can only be asked bout a number of products

between ci and c ′i ([ci , c′i ]) which he has purchased.

I For each product j we want to collect date for a minimum ofpj distinct customers and a maximum of p′j ([pj , p

′j ])

Page 54: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Survey design problem

Measuring customer satisfaction.Formally we want to model the problem as:

I A bipartite graph G = (C ∪ P,E ), where C = i is the set ofcustomers and P = i is the set of products.

I There is an (i , j) ∈ E is i has purchased product j .

I For each i ∈ 1, . . . , n we we have bounds [ci , c′i ] on the

number of products i can be asked about.

I For each j ∈ 1, . . . , n we we have bounds ([pj , p′j ]) on the

number of customers that can be asked about it.

Page 55: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Survey design problem: Bipartite graph G

6: [1,2]

PC

a

b

c

d

1

2

3

4

5

6

Customers C=a,b,c,d

Products P=1,2,3,4,5,6

Customer

a

b

Buys

c

d

1,2

1,2,4

3,63,4,5,6

G

a:[1,2]

b:[1,3]c:[1,2]

d:[2,4]

1: [1,2]

2: [1,2]3: [1,2]

4: [1,2]

5: [0,1]

Page 56: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Survey design problem: Max flow formulation

We construct G ′ from G , by adding:Edges: s → C, P → t, and(t, s).Capacities: c(t, s) =∞c(i , j) = 1,c(s, i) = [ci , c

′i ],

c(j , t) = [pj , p′j ].

0,1

0,

p,p´ji

s t

c,c´0,1

Notice if f is the flow:

I f (i , j) = 1⇒ customer i is asked about product j ,

I f (s, i) # products to ask customer i for opinion,

I f (j , t) = # customers to be asked to review product j ,

I f (t, s) is the number of questions asked.

Page 57: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Max flow formulation: Example

2

a

b

c

d

1,2

1,2,4

3,6

3,4,5,6

a

b

c

d

1

2

3

4

5

6

a:[1,2]

b:[1,3]

c:[1,2]

1: [1,2]

2: [1,2]

3: [1,2]

4: [1,2]

5: [0,1]

6: [1,2]

s

t

[1,2]

[1,3]

[1,2][1,2]

[1,2]

[1,2]

[1,2]

[1,2]

[0,1]

1

1

1

1

1

1

1

11

d:[2,3]

[2,3]1

1

2

2

2

2

10

2

3

3

Page 58: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Main result

Theorem G ′ has a feasible circulation iff there is a feasible way todesign the survey.

Proof if there is a feasible way to design the survey:

I if i is asked about j then f (i , j) = 1,

I f (s, i) = number questions asked to i ,

I f (j , t) = number of customers who were asked about j ,

I f (t, s) = total number of questions.

I easy to verify that f is feasible in G ′

If there is an integral, feasible circulation in G ′:

I if f (i , j) = 1 then i will be asked about j ,

I the constrains (ci , c′i , pj , p

′j) will be satisfied. 2

Page 59: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Pixels and digital image

I In digital imaging, a pixel is the smallest controllable elementof a picture represented on the screen.

I Digital images are represented by a raster graphics image, adot matrix data structure representing rectangular grid ofpixels, or points of color

I The address of a pixel corresponds to its physical coordinates.

Page 60: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Image segmentation

Given a set of pixels classify each pixel as part of the main objector as part of the background.Important problem in different techniques for image processing.

Page 61: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Foreground/background segmentation

I We aim to label each pixel as belonging to the foreground orthe background

I Picture pixels as a grid of dots.

I Define the undirected graph G = (V ,E ), where, V = setpixels in image, E = pairs of neighbors of pixels (in the grid)

I For each pixel i , ai ≥ 0 is likelihood that i is in the foregroundand bi ≥ 0 is likelihood that i is in the background.

I For each (i , j) of neighboring pixels, there is a separationpenalty pij ≥ 0 for placing one in the foreground and theother in the background.

Page 62: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Foreground/background segmentation

Goals:

I For i isolated, if ai > bi we prefer to label i as foreground(otherwise we label i as background)

I If many neighbors of i are labeled foreground we prefer tolabel i as foreground. This makes the labeling smoother byminimizing the amount of foreground/background

I We want to partition V into A (set of foreground pixels) andB (set of background pixels), such that we maximize theobjective function:∑

i∈Aai +

∑j∈B

bj −∑

(i ,j)∈E ,|A∩i ,j|=1

pij

Page 63: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Formulate as a min-cut problem

Segmentation has the flavor of a cut problem, but

I it is a maximization different than the min-cut,

I G is undirected,

I it does not have sink s and source t.

Page 64: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

From maximization to minimization

Recall we want to max(∑i∈A

ai +∑j∈B

bj −∑

(i ,j)∈E ,|A∩i ,j|=1

pij︸ ︷︷ ︸(∗)

)

I Let Q =∑

i∈V (ai + bi ) =∑i∈V

bi +∑j∈V

aj︸ ︷︷ ︸Θ(1)

, then

∑i∈A ai +

∑j∈B bj = Q − (

∑i∈A bi +

∑j∈B aj)

I So, (∗) ≡ Q −∑

i∈A bi −∑

j∈B aj)−∑

(i,j)∈E ,|A∩i,j|=1 pij

I Therefore,

max(∗) = min∑i∈A

bi +∑j∈B

aj +∑

(i ,j)∈E ,|A∩i ,j|=1

pij .

Page 65: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Transforming G into an s → t network G ′

We transform G = (V ,E ) to G ′ = (V ′,E ′) by

I Add a upper node s representing the foreground

I Add a lower node t representing the background

I V ′ = V ∪ s, tI For each (v , u) ∈ E create antiparallel directed edges (u, v)

and (v , u) in E ′

I For each pixel i create directed edges (s, i) and (i , t)

I E ′ = (s, v) ∪ (v , t)v∈E ∪ (u, v) ∪ (v , u)(u,v)∈E

Page 66: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

The undirected pixel graph G and the digraph G ′

G’

G

Page 67: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Adding capacities to the edges of G ′

I For each i ∈ V , c(s, i) = ai , c(i , t) = biI For each (i , j) ∈ E , c(i , j) = c(j , i) = pij

pxv t

x

s

u

v

wax

aw

bw

bu

bv

pvu

puw

pwx

av

Page 68: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Min-cut in G ′

An s − t cut (A′,B ′) corresponds to a partition of the pixels into(A′ − s,B ′ − t), where

I Edges (s, j) with j ∈ B contributes with aj to c(A′,B ′),

I edges (i , t) where i ∈ A contributes with bj to c(A′,B ′),

I edges (i , j) where i ∈ A and j ∈ B contributes with pij toc(A′,B ′)

Therefore,

c(A′,B ′) =∑i∈A

bi+∑j∈B

aj+∑

(i ,j)∈E ,|A∩i ,j|=1

pij

We want to find the min value of theabove quantity, which is equivalent to findthe min-cut (A,B) in G ′ ⇒ find themax-flow s − t in G ′.

B′

t

x

s

u

v

wax

aw

bw

bu

bv

pvu

puw

pwx

av

pxv

A′

Page 69: Max- ow and min-cutmjserna/docencia/grauA/P16/MaxFlow-fib.pdfMax-Flow and Min-Cut Two important algorithmic problems, which yield a beautiful duality Myriad of non-trivial applications,

Conclusions

Max-Flow/ Min-Cut problem is an intuitively easy problem withlots of applications.We just presented a few ones.An alternative point of view can be obtained from duality in LP

The material in this talk has been basically obtained from twotextbooks:

I Chapter 26 of Cormen, Leiserson, Rivest, Stein: Introductionto Algorithms, and

I chapter 7 of kleinberg, Tardos: Algorithm Design.


Recommended