graph theory and optimization flow: ford-fulkerson ... · graph theory and optimization flow:...

97
Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur, Inria, CNRS, I3S, France October 2018 N. Nisse Graph Theory and applications 1/24

Upload: others

Post on 25-Jun-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Graph Theory and OptimizationFlow: Ford-Fulkerson Algorithm

Max Flow- Min Cut duality

Nicolas Nisse

Université Côte d’Azur, Inria, CNRS, I3S, France

October 2018

N. Nisse Graph Theory and applications 1/24

Page 2: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Outline

1 Transportation Problem

2 Elementary Flow Network

3 Upper bound on Flow: Cut

4 Ford-Fulkerson Algorithm

5 Min Cut=Max flow

6 Application to Connectivity: Menger Theorem

7 Application to Matching

N. Nisse Graph Theory and applications 2/24

Page 3: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: ModelingDirected weighted graph: D = (V ,A), A : set of arcs, (x ,y) ∈ A ordered pair

arrows

a

b

d

e

h

j

g

c

f

i

3

5

1

2

3

4

2

1

2

1

3

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

N. Nisse Graph Theory and applications 3/24

Page 4: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: ModelingDirected weighted graph: D = (V ,A)On vertices: production: pmax : V → R+; consumption: consmax : V → R+

On arcs: capacity: c : A→ R+

3

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

4

16

3

7

1

g

1

18

55

N. Nisse Graph Theory and applications 3/24

Page 5: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: ModelingWhat is the main amount of goods that can be exchanged?Actual production: p : V → R+ and actual consumption: cons : V → R+

flow: f : A→ R+: satisfies capacity and flow conservation

3

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

4

16

3

7

1

g

1

18

55

N. Nisse Graph Theory and applications 3/24

Page 6: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: Modelingflow: f : A→ R+: feasibility: ∀v ∈ V , p(v)≤ pmax (v), cons(v)≤ consmax (v)capacity constraint: ∀a ∈ A, f (a)≤ c(a).flow conservation: ∀v ∈ V , p(v)+ ∑

w∈N−(v)f (wv) = c(v)+ ∑

w∈N+(v)

f (vw)

1

1

3

3

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

4

16

3

7

1

g

1

18

55

1

N. Nisse Graph Theory and applications 3/24

Page 7: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: Modelingflow: f : A→ R+: feasibility: ∀v ∈ V , p(v)≤ pmax (v), cons(v)≤ consmax (v)capacity constraint: ∀a ∈ A, f (a)≤ c(a).flow conservation: ∀v ∈ V , p(v)+ ∑

w∈N−(v)f (wv) = c(v)+ ∑

w∈N+(v)

f (vw)

2

11

3

3

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

4

16

3

7

1

g

1

18

55

1

N. Nisse Graph Theory and applications 3/24

Page 8: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: Modelingflow: f : A→ R+: feasibility: ∀v ∈ V , p(v)≤ pmax (v), cons(v)≤ consmax (v)capacity constraint: ∀a ∈ A, f (a)≤ c(a).flow conservation: ∀v ∈ V , p(v)+ ∑

w∈N−(v)f (wv) = c(v)+ ∑

w∈N+(v)

f (vw)

3

13

4

3

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

4

16

3

7

1

g

1

18

55

4

3

4

N. Nisse Graph Theory and applications 3/24

Page 9: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: Modelingflow: f : A→ R+: feasibility: ∀v ∈ V , p(v)≤ pmax (v), cons(v)≤ consmax (v)capacity constraint: ∀a ∈ A, f (a)≤ c(a).flow conservation: ∀v ∈ V , p(v)+ ∑

w∈N−(v)f (wv) = c(v)+ ∑

w∈N+(v)

f (vw)

3

13

4

3

a

b

d

e

h

j

c

f

i

3,3

5

1

2

3

4

2,2

1

2,23,2

4

4,2

5

4,4

4,2

3,1

2,1

3

2,2

1

4

3

2,12

5,1

3

4

16

3

7

1

g

1

18

55

4

3

4

N. Nisse Graph Theory and applications 3/24

Page 10: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Transportation problem: Modeling

Simplification: one single source and one single destination

3

13

4

3

a

b

d

e

h

j

c

f

i

3,3

5

1

2

3

4

2,2

1

2,23,2

4

4,2

5

4,4

4,2

3,1

2,1

3

2,2

1

4

3

2,12

5,1

3

4

16

3

7

1

g

1

18

55

4

3

4a

b

d

e

h

j

c

f

i

3,3

5

1

2

3

4

2,2

1

2,23,2

4

4,2

5

4,4

4,2

3,1

2,1

3

2,2

1

4

3

2,12

5,1

3

1

g

s d

3,3

4,4

16,0

7,4

1,1

18,4

5,3

3,3

5,0

One source s: ∀v ∈ V add one arc (s,v) with capacity pmax(v)One destination d : ∀v ∈ V add one arc (v ,d) with capacity consmax(v)

Flows are “equivalent" in both networks

N. Nisse Graph Theory and applications 3/24

Page 11: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Outline

1 Transportation Problem

2 Elementary Flow Network

3 Upper bound on Flow: Cut

4 Ford-Fulkerson Algorithm

5 Min Cut=Max flow

6 Application to Connectivity: Menger Theorem

7 Application to Matching

N. Nisse Graph Theory and applications 4/24

Page 12: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Elementary Flow NetworkDirected graph: D = (V ,A), source s ∈ V , destination d ∈ V , capacity c : A→ R+.

N−(s) = /0 and N+(d) = /0

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

1

g

s d

3

4

16

7

1

18

5

3

5

flow f : A→ R+ such that : capacity constraint: ∀a ∈ A, f (a)≤ c(a)conservation constraint: ∀v ∈ V \{s,d}, ∑

w∈N−(v)

f (wv) = ∑w∈N+(v)

f (vw)

value of flow: v(f ) = ∑w∈N+(s)

f (sw).

Exercise: v(f ) = ∑w∈N−(d)

f (wd)

N. Nisse Graph Theory and applications 5/24

Page 13: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Elementary Flow NetworkDirected graph: D = (V ,A), source s ∈ V , destination d ∈ V , capacity c : A→ R+.

N−(s) = /0 and N+(d) = /0

a

b

d

e

h

j

c

f

i

3,3

5

1,1

2

3

4,1

2

1

2,23

4,1

4,3

5

4

4

3

2

3

2

1,1

4

3

22

5

3

1,1

g

s d

3

4,2

16,1

7,2

1

18

5,1

3

5,4

Value(f)=5flow f : A→ R+ such that : capacity constraint: ∀a ∈ A, f (a)≤ c(a)conservation constraint: ∀v ∈ V \{s,d}, ∑

w∈N−(v)

f (wv) = ∑w∈N+(v)

f (vw)

value of flow: v(f ) = ∑w∈N+(s)

f (sw).

Exercise: v(f ) = ∑w∈N−(d)

f (wd)

N. Nisse Graph Theory and applications 5/24

Page 14: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Elementary Flow NetworkDirected graph: D = (V ,A), source s ∈ V , destination d ∈ V , capacity c : A→ R+.

N−(s) = /0 and N+(d) = /0

a

b

d

e

h

j

c

f

i

3,3

5

1,1

2

3

4,1

2

1

2,23

4,1

4,3

5

4

4

3

2

3

2

1,1

4

3

22

5

3

1,1

g

s d

3

4,2

16,1

7,2

1

18

5,1

3

5,4

Value(f)=5flow f : A→ R+ such that : capacity constraint: ∀a ∈ A, f (a)≤ c(a)conservation constraint: ∀v ∈ V \{s,d}, ∑

w∈N−(v)

f (wv) = ∑w∈N+(v)

f (vw)

value of flow: v(f ) = ∑w∈N+(s)

f (sw).Exercise: v(f ) = ∑

w∈N−(d)

f (wd)

N. Nisse Graph Theory and applications 5/24

Page 15: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Elementary Flow Network: Max Flow

How to compute a flow with maximum value?

a

b

d

e

h

j

c

f

i

3,3

5

1,1

2

3

4,1

2

1

2,23

4,1

4,3

5

4

4

3

2

3

2

1,1

4

3

22

5

3

1,1

g

s d

3

4,2

16,1

7,2

1

18

5,1

3

5,4

Value(f)=5

N. Nisse Graph Theory and applications 6/24

Page 16: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Elementary Flow Network: Max Flow

How to compute a flow with maximum value?

a

b

d

e

h

j

c

f

i

3,3

5

1,1

2

3

4,1

2

1

2,23

4,1

4,3

5

4

4

3

2

3

2

1,1

4

3

22

5

3

1,1

g

s d

3,1

4,2

16,1

7,2

1,1

18

5,1

3

5,4

Value(f)=6

Possible to “push" flow along available path

N. Nisse Graph Theory and applications 6/24

Page 17: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Elementary Flow Network: Max Flow

How to compute a flow with maximum value?

a

b

d

e

h

j

c

f

i

3,3

5

1,1

2

3

4,1

2,2

1

2,23

4,2

4,3

5

4

4

3

2

3

2

1,1

4

3

22

5

3

1,1

g

s d

3,3

4,2

16,1

7,2

1,1

18

5,2

3

5,5

Value(f)=8

Possible to “push" flow along available path

N. Nisse Graph Theory and applications 6/24

Page 18: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Elementary Flow Network: Max Flow

How to compute a flow with maximum value?

a

b

d

e

h

j

c

f

i

3,3

5

1,1

2

3

4

2,2

1

2,13

4,1

4,3

5

4

4

3

2

3

2

1

4

3

22

5

3

1,1

g

s d

3,3

4,2

16,1

7,2

1,1

18

5,2

3

5,5

Value(f)=8

Possible to “push" flow along available pathMay be useful to “remove useless flow"

N. Nisse Graph Theory and applications 6/24

Page 19: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Outline

1 Transportation Problem

2 Elementary Flow Network

3 Upper bound on Flow: Cut

4 Ford-Fulkerson Algorithm

5 Min Cut=Max flow

6 Application to Connectivity: Menger Theorem

7 Application to Matching

N. Nisse Graph Theory and applications 7/24

Page 20: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Max Flow, upper bound: Min cut

a cut gives an upper bound on the value of your flow

s d

S D2

11

3

1

2

10

N. Nisse Graph Theory and applications 8/24

Page 21: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Max Flow, upper bound: Min cut

Is this flow maximum?: a cut gives an upper bound on the value of your flow

a

b

d

e

h

j

c

f

i

3,3

5

1,1

2

3

4

2,2

1

2,13

4,1

4,3

5

4

4

3

2

3

2

1

4

3

22

5

3

1,1

g

s d

3,3

4,2

16,1

7,2

1,1

18

5,2

3

5,5

Value(f)=8

N. Nisse Graph Theory and applications 8/24

Page 22: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Max Flow, upper bound: Min cut

Is this flow maximum?: a cut gives an upper bound on the value of your flow

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

1

g

s d

3

4

16

7

1

18

5

3

5

Vs = {s, a, b, c, d, f, g, h, i}, Vd = {d, e, j}δ(Vs, Vd) = 24

s,d-Cut: partition (Vs,Vd) of V with s ∈ Vs and d ∈ Vd .Capacity of a s,d-cut: δ (Vs,Vd) = ∑

u∈Vs ,v∈Vd

c(uv).

N. Nisse Graph Theory and applications 8/24

Page 23: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Max Flow, upper bound: Min cutIs this flow maximum?: a cut gives an upper bound on the value of your flow

a

b

d

e

h

j

c

f

i

3

5

1

2

3

4

2

1

23

4

4

5

4

4

3

2

3

2

1

4

3

22

5

3

1

g

s d

3

4

16

7

1

18

5

3

5

Vs = {s, a, b, c, d, f, g, h, i}, Vd = {d, e, j}δ(Vs, Vd) = 24

s,d-Cut: partition (Vs,Vd) of V with s ∈ Vs and d ∈ Vd .Capacity of a s,d-cut: δ (Vs,Vd) = ∑

u∈Vs ,v∈Vd

c(uv).

Theorem: for any network flow D = (V ,A), s,d ∈ V and c : A→ R+

For any flow f : A→ R+ and s,d-cut (Vs,Vd), v(f )≤ δ (Vs,Vd)

Proof:conservation constraint: ∀v ∈ V \{s,d}, ∑

w∈N−(v)

f (wv) = ∑w∈N+(v)

f (vw).

sum over all vertices in Vs \{s}:0 = ∑

v∈Vs\{s}( ∑

w∈N−(v)f (wv)− ∑

w∈N+(v)

f (vw)) =

∑w∈N+(s)

f (sw)+ ∑v∈Vs\{s};w∈Vd

f (wv)− ∑v∈Vs ;w∈Vd

f (vw)

Sov(f )= ∑

v∈Vs ;w∈Vd

f (vw)− ∑v∈Vs\{s};w∈Vd

f (wv)≤ ∑v∈Vs ;w∈Vd

f (vw)≤ ∑v∈Vs ;w∈Vd

c(vw) = δ(Vs,Vd )

Corollary: Max flow ≤ Min Cut

N. Nisse Graph Theory and applications 8/24

Page 24: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Max Flow, upper bound: Min cut

Theorem: for any network flow D = (V ,A), s,d ∈ V and c : A→ R+

For any flow f : A→ R+ and s,d-cut (Vs,Vd), v(f )≤ δ (Vs,Vd)

Proof:conservation constraint: ∀v ∈ V \{s,d}, ∑

w∈N−(v)

f (wv) = ∑w∈N+(v)

f (vw).

sum over all vertices in Vs \{s}:0 = ∑

v∈Vs\{s}( ∑

w∈N−(v)f (wv)− ∑

w∈N+(v)

f (vw)) =

∑w∈N+(s)

f (sw)+ ∑v∈Vs\{s};w∈Vd

f (wv)− ∑v∈Vs ;w∈Vd

f (vw)

Sov(f )= ∑

v∈Vs ;w∈Vd

f (vw)− ∑v∈Vs\{s};w∈Vd

f (wv)≤ ∑v∈Vs ;w∈Vd

f (vw)≤ ∑v∈Vs ;w∈Vd

c(vw) = δ(Vs,Vd )

Corollary: Max flow ≤ Min Cut

N. Nisse Graph Theory and applications 8/24

Page 25: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Outline

1 Transportation Problem

2 Elementary Flow Network

3 Upper bound on Flow: Cut

4 Ford-Fulkerson Algorithm

5 Min Cut=Max flow

6 Application to Connectivity: Menger Theorem

7 Application to Matching

N. Nisse Graph Theory and applications 9/24

Page 26: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Algorithm for Max Flow: Intuition

s

a

c

b

e

d3

332

2

121

Let us compute a max flow from s to d .

N. Nisse Graph Theory and applications 10/24

Page 27: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Algorithm for Max Flow: Intuition

s

a

c

b

e

d3,3

3,33,32

2

121

We can “push" 3 units of flow along an available path (s,a,b,d). v(f ) = 3.The only remaining available path is (s,c,e,d)

N. Nisse Graph Theory and applications 10/24

Page 28: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Algorithm for Max Flow: Intuition

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

We can “push" 1 units of flow along (s,c,e,d). v(f ) = 4.No path from s to d remains available, but...

N. Nisse Graph Theory and applications 10/24

Page 29: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Algorithm for Max Flow: Intuition

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,1

1

We want to “push" some flow along the "path" (s,c,b,a,e,d)It is NOT a directed path (because (b,a) /∈ A)

N. Nisse Graph Theory and applications 10/24

Page 30: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Algorithm for Max Flow: Intuition

s

a

c

b

e

d3,3

3,3-13,32,+1

2,1+1

1,12,1+11,+1

Somehow, we "reverse" some flow along the arc (a,b)

N. Nisse Graph Theory and applications 10/24

Page 31: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Algorithm for Max Flow: Intuition

s

a

c

b

e

d3,3

3,23,32,1

2,2

1,12,21,1

So we got a flow with value v(f ) = 5.

Exercise: Why is it optimal ?

N. Nisse Graph Theory and applications 10/24

Page 32: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Algorithm for Max Flow: Intuition

s

a

c

b

e

d3,3

3,23,32,1

2,2

1,12,21,1

Recall that Max flow ≤ Min Cut

If there is a flow f and a cut (Vs,Vd) with v(f ) = δ (Vs,Vd), thenf is maximum and (Vs,Vd) is a minimum cut.

N. Nisse Graph Theory and applications 10/24

Page 33: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

1st Phase of FF-algorithm: Compute an auxiliary graph where to find a path

For all u,v ∈ V(G), create an arc with capacity caux (uv) = c(uv)− f (uv)+ f (vu)

f (uv) current flow from u to v , f (vu) current flow from v to uc(uv)− f (uv) is the residual capacity

Remarks:

• caux (uv) may be positive even if (u,v) /∈ A(G)

• If (u,v) /∈ A(G) and (v ,u) /∈ A(G), then caux (uv) = caux (vu) = 0

N. Nisse Graph Theory and applications 11/24

Page 34: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1st Phase of FF-algorithm: Compute an auxiliary graph where to find a path

For all u,v ∈ V(G), create an arc with capacity caux (uv) = c(uv)− f (uv)+ f (vu)

f (uv) current flow from u to v , f (vu) current flow from v to uc(uv)− f (uv) is the residual capacity

Remarks:

• caux (uv) may be positive even if (u,v) /∈ A(G)

• If (u,v) /∈ A(G) and (v ,u) /∈ A(G), then caux (uv) = caux (vu) = 0

N. Nisse Graph Theory and applications 11/24

Page 35: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

2-1+0=1

1st Phase of FF-algorithm: Compute an auxiliary graph where to find a path

For all u,v ∈ V(G), create an arc with capacity caux (uv) = c(uv)− f (uv)+ f (vu)

f (uv) current flow from u to v , f (vu) current flow from v to uc(uv)− f (uv) is the residual capacity

Remarks:

• caux (uv) may be positive even if (u,v) /∈ A(G)

• If (u,v) /∈ A(G) and (v ,u) /∈ A(G), then caux (uv) = caux (vu) = 0

N. Nisse Graph Theory and applications 11/24

Page 36: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1

0-0+1=1

1st Phase of FF-algorithm: Compute an auxiliary graph where to find a path

For all u,v ∈ V(G), create an arc with capacity caux (uv) = c(uv)− f (uv)+ f (vu)

f (uv) current flow from u to v , f (vu) current flow from v to uc(uv)− f (uv) is the residual capacity

Remarks:

• caux (uv) may be positive even if (u,v) /∈ A(G)

• If (u,v) /∈ A(G) and (v ,u) /∈ A(G), then caux (uv) = caux (vu) = 0

N. Nisse Graph Theory and applications 11/24

Page 37: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1

1

3-3+0=0

1st Phase of FF-algorithm: Compute an auxiliary graph where to find a path

For all u,v ∈ V(G), create an arc with capacity caux (uv) = c(uv)− f (uv)+ f (vu)

f (uv) current flow from u to v , f (vu) current flow from v to uc(uv)− f (uv) is the residual capacity

Remarks:

• caux (uv) may be positive even if (u,v) /∈ A(G)

• If (u,v) /∈ A(G) and (v ,u) /∈ A(G), then caux (uv) = caux (vu) = 0

N. Nisse Graph Theory and applications 11/24

Page 38: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1

1

0

0-0+3=3

1st Phase of FF-algorithm: Compute an auxiliary graph where to find a path

For all u,v ∈ V(G), create an arc with capacity caux (uv) = c(uv)− f (uv)+ f (vu)

f (uv) current flow from u to v , f (vu) current flow from v to uc(uv)− f (uv) is the residual capacity

Remarks:

• caux (uv) may be positive even if (u,v) /∈ A(G)

• If (u,v) /∈ A(G) and (v ,u) /∈ A(G), then caux (uv) = caux (vu) = 0

N. Nisse Graph Theory and applications 11/24

Page 39: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

1st Phase of FF-algorithm: Compute an auxiliary graph where to find a path

For all u,v ∈ V(G), create an arc with capacity caux (uv) = c(uv)− f (uv)+ f (vu)

f (uv) current flow from u to v , f (vu) current flow from v to uc(uv)− f (uv) is the residual capacity

Remarks:

• caux (uv) may be positive even if (u,v) /∈ A(G)

• If (u,v) /∈ A(G) and (v ,u) /∈ A(G), then caux (uv) = caux (vu) = 0

N. Nisse Graph Theory and applications 11/24

Page 40: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 41: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 42: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1

1,12,11

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 43: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,1+1

1,12,11

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 44: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,33,32

2,2

1,12,11,+1

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 45: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,3-13,32

2,2

1,12,11,1

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 46: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,23,32,+1

2,2

1,12,11,1

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 47: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,23,32,1

2,2

1,12,1+11,1

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 48: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st exampleProblem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,23,32,1

2,2

1,12,21,1

s

a

c

b

e

d

1

1

0

33

1

2

1

3

11

P

2nd Phase of FF-algorithm: Look for a path P from s to d in auxiliary graph

Here P = (s,c,b,a,e,d) and its minimum capacity is ε = 1 > 0

We will “push" ε units of flow along P in G

For all arcs (u,v) of P

• Add ε to the current flow of (u,v) if f (uv)+ ε ≤ c(uv)

• Otherwise add c(uv)− f (uv) to the current flow of (u,v)

note that ε− (c(uv)− f (uv)) are “lacking to be pushed"

• In the latter case, remove ε− (c(uv)− f (uv)) from the current flow from v to u.

N. Nisse Graph Theory and applications 12/24

Page 49: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,23,32,1

2,2

1,12,21,1

s

a

c

b

e

d

back to the 1st Phase of FF-algorithm: Compute in auxiliary graph

Here no path with > 0 capacity from s to d .The set of nodes reachable from s (here, only s) defines a cut

Exercise: What is the capacity of this cut? Why the flow is maximum?

N. Nisse Graph Theory and applications 13/24

Page 50: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,23,32,1

2,2

1,12,21,1

s

a

c

b

e

d

3

2

1

1

2

11

1

3

2

back to the 1st Phase of FF-algorithm: Compute in auxiliary graph

Here no path with > 0 capacity from s to d .The set of nodes reachable from s (here, only s) defines a cut

Exercise: What is the capacity of this cut? Why the flow is maximum?

N. Nisse Graph Theory and applications 13/24

Page 51: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm 1st example

Problem here: there is no path where to push flow

s

a

c

b

e

d3,3

3,23,32,1

2,2

1,12,21,1

s

a

c

b

e

d

3

2

1

1

2

11

1

3

2

back to the 1st Phase of FF-algorithm: Compute in auxiliary graph

Here no path with > 0 capacity from s to d .The set of nodes reachable from s (here, only s) defines a cut

Exercise: What is the capacity of this cut? Why the flow is maximum?

N. Nisse Graph Theory and applications 13/24

Page 52: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm

D = (V ,A), c : A→ R+ and s,d ∈ V

Let f : A→ R+ be a valid flow in D Initially, f may be null

1 Compute an auxiliary graph Daux = (V ,Aaux) and caux : Aaux → R+

∀u,v ∈ V , add an arc (u,v) ∈ Aaux with capacity

caux(uv) = c(uv)− f (uv)+ f (vu).

2 If there is a directed path P from s to d in Daux(auxiliary capacity of arcs of P must be > 0)

• Let ε > 0 be the minimum capacity caux of the arcs of P• “Push" ε units of flow along P in D

For each arc (uv) ∈ A(P) of P:f (uv)←min{c(uv); f (uv)+ ε}

push ε but if it exceeds the capacity of the linkf (vu)← f (vu)−max{0; f (uv)+ ε− c(uv)}

“reverse" some flow

• Go to 1 (Note that the value of the flow has increased)

Else Return f f is a maximum flow.

N. Nisse Graph Theory and applications 14/24

Page 53: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm

D = (V ,A), c : A→ R+ and s,d ∈ V

Let f : A→ R+ be a valid flow in D Initially, f may be null

1 Compute an auxiliary graph Daux = (V ,Aaux) and caux : Aaux → R+

∀u,v ∈ V , add an arc (u,v) ∈ Aaux with capacity

caux(uv) = c(uv)− f (uv)+ f (vu).

2 If there is a directed path P from s to d in Daux(auxiliary capacity of arcs of P must be > 0)

• Let ε > 0 be the minimum capacity caux of the arcs of P• “Push" ε units of flow along P in D

For each arc (uv) ∈ A(P) of P:f (uv)←min{c(uv); f (uv)+ ε}

push ε but if it exceeds the capacity of the linkf (vu)← f (vu)−max{0; f (uv)+ ε− c(uv)}

“reverse" some flow

• Go to 1 (Note that the value of the flow has increased)

Else Return f f is a maximum flow.

N. Nisse Graph Theory and applications 14/24

Page 54: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm

D = (V ,A), c : A→ R+ and s,d ∈ V

Let f : A→ R+ be a valid flow in D Initially, f may be null

1 Compute an auxiliary graph Daux = (V ,Aaux) and caux : Aaux → R+

∀u,v ∈ V , add an arc (u,v) ∈ Aaux with capacity

caux(uv) = c(uv)− f (uv)+ f (vu).

2 If there is a directed path P from s to d in Daux(auxiliary capacity of arcs of P must be > 0)

• Let ε > 0 be the minimum capacity caux of the arcs of P• “Push" ε units of flow along P in D

For each arc (uv) ∈ A(P) of P:f (uv)←min{c(uv); f (uv)+ ε}

push ε but if it exceeds the capacity of the linkf (vu)← f (vu)−max{0; f (uv)+ ε− c(uv)}

“reverse" some flow• Go to 1 (Note that the value of the flow has increased)

Else Return f f is a maximum flow.

N. Nisse Graph Theory and applications 14/24

Page 55: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636

2

10

3

e

f g

3

3

3

5

8

13

3

Digraph D = (V ,A), capacity c : A→ R+

Let us compute a max flow from s ∈ V to d ∈ V .

N. Nisse Graph Theory and applications 15/24

Page 56: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

Let us compute a max flow from s ∈ V to d ∈ V .start from a given initial flow: in the example v(f ) = 3.

N. Nisse Graph Theory and applications 15/24

Page 57: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

1st step: Compute the first auxiliary digraph Daux

start with same vertices as D

N. Nisse Graph Theory and applications 15/24

Page 58: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

in the example caux(sa) = 8−0+0 = 8

N. Nisse Graph Theory and applications 15/24

Page 59: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

in the example caux(as) = 0−0+0 = 0

N. Nisse Graph Theory and applications 15/24

Page 60: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

6-3+0

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

in the example caux(sc) = 6−3+0 = 3

N. Nisse Graph Theory and applications 15/24

Page 61: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

3

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

in the example caux(sc) = 6−3+0 = 3

N. Nisse Graph Theory and applications 15/24

Page 62: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

30-0+3

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

in the example caux(cs) = 0−0+3 = 3

N. Nisse Graph Theory and applications 15/24

Page 63: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

33

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

in the example caux(cs) = 0−0+3 = 3

N. Nisse Graph Theory and applications 15/24

Page 64: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

33 03

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

in the example caux(ca) = 3−3+0 = 0 and caux(ac) = 0−0+3 = 3

N. Nisse Graph Theory and applications 15/24

Page 65: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

33 03

2

6

103

3

33

2

13

3

3

5

5

1st step: Compute the first auxiliary digraph Daux

for all u,v ∈ V ×V , caux(uv) = c(uv)− f (uv)+ f (vu):

and so on

N. Nisse Graph Theory and applications 15/24

Page 66: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8 2

636,3

2

10

3,3

e

f g

3,3

3

3,3

5

8,3

13

3

s a

c

b

h

d

e

f g

8

0

33 03

2

6

103

3

33

2

13

3

3

5

5

2nd step: Find in Daux a directed s,d-path with positive capacity

in the example P = (s,a,h,g,e,d) and ε = minarc∈P caux(arc) = 3

N. Nisse Graph Theory and applications 15/24

Page 67: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,+3 2

63,+36,3

2

10,+3

3,3

e

f g

3,3-3

3

3,3

5,+3

8,3

13

3

s a

c

b

h

d

e

f g

8

0

33 03

2

6

103

3

33

2

13

3

3

5

5

2nd step: Push ε units of flow along P in D. For each arc (uv) of P:

f (uv)←min{c(uv); f (uv)+ ε} ex: f (sa) = min{8,0+3}= 3f (ge) = min{0,0+3}= 0

f (vu)← f (vu)−max{0; f (uv)+ ε− c(uv)}ex: f (eg) = 3−max{0,3+3−3}= 0

N. Nisse Graph Theory and applications 15/24

Page 68: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,3 2

63,36,3

2

10,3

3,3

e

f g

3

3

3,3

5,3

8,3

13

3

s a

c

b

h

d

e

f g

8

0

33 03

2

6

103

3

33

2

13

3

3

5

5

The flow has been increased:v(f ) = 6

N. Nisse Graph Theory and applications 15/24

Page 69: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,3 2

63,36,3

2

10,3

3,3

e

f g

3

3

3,3

5,3

8,3

13

3

s a

c

b

h

d

e

f g

1st step: We have to compute the auxiliary digraphstarting from the new current flow

N. Nisse Graph Theory and applications 15/24

Page 70: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,3 2

63,36,3

2

10,3

3,3

e

f g

3

3

3,3

5,3

8,3

13

3

s a

c

b

h

d

e

f g

2

3

3

1 3

3

6

235

3 3 3 3 3

3 2

5

3

7 3

1st step: We have to compute the auxiliary digraphstarting from the new current flow

N. Nisse Graph Theory and applications 15/24

Page 71: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,3 2

63,36,3+3

2

10,3

3,3

e

f g

3

3

3,3

5,3

8,3+3

13,+3

3,+3

s a

c

b

h

d

e

f g

2

3

3

1 3

3

6

235

3 3 3 3 3

3 2

5

3

7 3

2nd step: Find in Daux a directed s,d-path with positive capacity

in the example P = (s,c, f ,g,d) and ε = minarc∈P caux(arc) = 3and Push ε units of flow along P in D

N. Nisse Graph Theory and applications 15/24

Page 72: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,3 2

63,36,6

2

10,3

3,3

e

f g

3

3

3,3

5,3

8,6

13,3

3,3

s a

c

b

h

d

e

f g

1st step: We have to compute the auxiliary digraphstarting from the new current flow v(f ) = 9

N. Nisse Graph Theory and applications 15/24

Page 73: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,3 2

63,36,6

2

10,3

3,3

e

f g

3

3

3,3

5,3

8,6

13,3

3,3

s a

c

b

h

d

e

f g

3 3 3

33

3

3

3

235

6

2

1 3 2

26

7

6

1st step: We have to compute the auxiliary digraphstarting from the new current flow

N. Nisse Graph Theory and applications 15/24

Page 74: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,3+2 2

63,36,6

2,+2

10,3

3,3-2

e

f g

3

3

3,3

5,3+2

8,6+2

13,3

3,3

s a

c

b

h

d

e

f g

3 3 3

33

3

3

3

235

6

2

1 3 2

26

7

6

2nd step: Find in Daux a directed s,d-path with positive capacity

in the example P = (s,a,c,h,g,d) and ε = minarc∈P caux(arc) = 2and Push ε units of flow along P in D

N. Nisse Graph Theory and applications 15/24

Page 75: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,5 2

63,36,6

2,2

10,3

3,1

e

f g

3

3

3,3

5,5

8,8

13,3

3,3

s a

c

b

h

d

e

f g

1st step: We have to compute the auxiliary digraphstarting from the new current flow v(f ) = 11

N. Nisse Graph Theory and applications 15/24

Page 76: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,5+2 2,+2

6,+23,36,6

2,2

10,3+2

3,1

e

f g

3

3

3,3

5,5

8,8

13,3

3,3

s a

c

b

h

d

e

f g

53

33

3

612 6

2

2 3

31 5

3 8

7 3

1st step: We have to compute the auxiliary digraph2nd step: Find in Daux a directed s,d-path with positive capacity

in the example P = (s,a,b,e,d) and ε = minarc∈P caux(arc) = 2and Push ε units of flow along P in D

N. Nisse Graph Theory and applications 15/24

Page 77: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,7 2,2

6,23,36,6

2,2

10,5

3,1

e

f g

3

3

3,3

5,5

8,8

13,3

3,3

s a

c

b

h

d

e

f g

1st step: We have to compute the auxiliary digraphstarting from the new current flow v(f ) = 13

N. Nisse Graph Theory and applications 15/24

Page 78: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,7 2,2

6,23,36,6

2,2

10,5

3,1

e

f g

3

3

3,3

5,5

8,8

13,3

3,3

s a

c

b

h

d

e

f g

3 3

3

3

3

3

2

21

6

17

2

4 2

8

5 515

2nd step: Find in Daux a directed s,d-path with positive capacityin the example, there is no such path !!

Exercise: Prove that the current flow is maximum

N. Nisse Graph Theory and applications 15/24

Page 79: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm Example

s a

c

b

h

d

8,7 2,2

6,23,36,6

2,2

10,5

3,1

e

f g

3

3

3,3

5,5

8,8

13,3

3,3

s a

c

b

h

d

e

f g

3 3

3

3

3

3

2

21

6

17

2

4 2

8

5 515

Aux. digraph defines a cut: Vs = {vertices reachable from s}; Vd = V \Vs.δ (Vs,Vd) = 13 = v(f )⇒ f is maximum.

N. Nisse Graph Theory and applications 15/24

Page 80: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Outline

1 Transportation Problem

2 Elementary Flow Network

3 Upper bound on Flow: Cut

4 Ford-Fulkerson Algorithm

5 Min Cut=Max flow

6 Application to Connectivity: Menger Theorem

7 Application to Matching

N. Nisse Graph Theory and applications 16/24

Page 81: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Min Cut=Max flow

Exercise: Let f : A→ R+ be computed by FF-algorithm

1 Prove that f is a valid flow

2 Prove that f is a maximum flow

idea of proof of 2:FF-algorithm returns a flow f : A→ R+

it also returns a cut with capacity v(f ).

Theorem: Max Flow = Min Cut (duality)For any digraph D, c : A(D)→ R+ and s,d ∈ V (D):

maximum value of a flow from s to d = minimum capacity of a s,d-cut

N. Nisse Graph Theory and applications 17/24

Page 82: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Complexity

Remark: the FF-algorithm may not terminate

Exercise: Assume capacities are integral c : A→ N• Prove that FF-algorithm always terminates

• Prove that the maximum value of a flow is integral

Complexity with integral capacities

FF-algorithm terminates in time O(vmax |A(D)|)

N. Nisse Graph Theory and applications 18/24

Page 83: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Complexity

Remark: the FF-algorithm may not terminate

Exercise: Assume capacities are integral c : A→ N• Prove that FF-algorithm always terminates

• Prove that the maximum value of a flow is integral

Complexity with integral capacities

FF-algorithm terminates in time O(vmax |A(D)|)

N. Nisse Graph Theory and applications 18/24

Page 84: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: undirected graphs

In undirected graph G = (V ,E)

f : V ×V → R+ is defined on ordered pairs of verticesFlow conservation: for any v ∈ V \{s,d}, ∑

u∈N(v)

f (uv) = ∑u∈N(v)

f (vu)

Capacity: for any e = {u,v} ∈ E , f (uv)+ f (vu)≤ c({u,v}).

s

d

a b

c e

1 10

3

412

3 6

s

d

a b

c e

3

412

6

31 10

41

2

3

s

d

a b

c e

3,1

41,12

6,5

3,3

1,1 10,6

,41

2,2

3,2

s

d

a b

c e

1,1 10,6

3,2

4,41,12,2

3,2 6,5FF Algorithm``transform"

in directed graph

``translate"the flow

in original graph

N. Nisse Graph Theory and applications 19/24

Page 85: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Outline

1 Transportation Problem

2 Elementary Flow Network

3 Upper bound on Flow: Cut

4 Ford-Fulkerson Algorithm

5 Min Cut=Max flow

6 Application to Connectivity: Menger Theorem

7 Application to Matching

N. Nisse Graph Theory and applications 20/24

Page 86: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to Connectivity

Edge-disjoint Paths: G = (V ,E), s,d ∈ V , k ∈ NExercise: ∃ k edge-disjoint paths from s to d in G

⇔ ∃ a s,d-flow with value k in G (with capacity 1 on edges)

Idea: use the fact that there exists an integral maximum flow

S ⊆ V is a s,d-separator if s and d in different components of G \S

Menger’s Theorem (1927): (duality)For any graph G = (V ,E), s,d ∈ V non-adjacent, k ∈ N:∃ k internally-vertex-disjoint paths from s to d ⇔ @ s,d-separator of size < k .

N. Nisse Graph Theory and applications 21/24

Page 87: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to ConnectivityVertex-disjoint Paths: G = (V ,E), s,d ∈ V , k ∈ NExercise: ∃ k (internally) vertex-disjoint paths from s to d in G

⇔ ∃ a s,d-flow with value k in G∗ (see Picture)

s

d

a b

c e

1 10

3

412

3 6

s

d

a b

c e

3

412

6

31 10

41

2

3

``transform"in directed

graph

s

d

a' b'

c e

3

1

6

310

42

3

a

c'

1

2

1

1

1

b

e'

4

1

1x

x x'

G G*

S ⊆ V is a s,d-separator if s and d in different components of G \S

Menger’s Theorem (1927): (duality)For any graph G = (V ,E), s,d ∈ V non-adjacent, k ∈ N:∃ k internally-vertex-disjoint paths from s to d ⇔ @ s,d-separator of size < k .

N. Nisse Graph Theory and applications 21/24

Page 88: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to ConnectivityVertex-disjoint Paths: G = (V ,E), s,d ∈ V , k ∈ NExercise: ∃ k (internally) vertex-disjoint paths from s to d in G

⇔ ∃ a s,d-flow with value k in G∗ (see Picture)

s

d

a b

c e

1 10

3

412

3 6

s

d

a b

c e

3

412

6

31 10

41

2

3

``transform"in directed

graph

s

d

a' b'

c e

3

1

6

310

42

3

a

c'

1

2

1

1

1

b

e'

4

1

1x

x x'

G G*

S ⊆ V is a s,d-separator if s and d in different components of G \S

Menger’s Theorem (1927): (duality)For any graph G = (V ,E), s,d ∈ V non-adjacent, k ∈ N:∃ k internally-vertex-disjoint paths from s to d ⇔ @ s,d-separator of size < k .

N. Nisse Graph Theory and applications 21/24

Page 89: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Outline

1 Transportation Problem

2 Elementary Flow Network

3 Upper bound on Flow: Cut

4 Ford-Fulkerson Algorithm

5 Min Cut=Max flow

6 Application to Connectivity: Menger Theorem

7 Application to Matching

N. Nisse Graph Theory and applications 22/24

Page 90: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to Matching

Let G = (V ,E) be a graph.Matching: A set M of pairwise disjoint edges in a graph (M ⊆ E)

Problem: Compute a matching of maximum cardinality

N. Nisse Graph Theory and applications 23/24

Page 91: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to Matching

Let G = (V ,E) be a graph.Matching: A set M of pairwise disjoint edges in a graph (M ⊆ E)

Question: is this matching maximum?

N. Nisse Graph Theory and applications 23/24

Page 92: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to Matching

Let G = (V ,E) be a graph.Matching: A set M of pairwise disjoint edges in a graph (M ⊆ E)

Question: and this one?

N. Nisse Graph Theory and applications 23/24

Page 93: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to Matching

Let G = (V ,E) be a graph.Matching: A set M of pairwise disjoint edges in a graph (M ⊆ E)

Question: and this one?

Exercise: Prove that any matching M is such that |M| ≤ b|V |/2c

N. Nisse Graph Theory and applications 23/24

Page 94: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to Matching

Example of application of matching:

stable set: set of vertices pariwise non-adjacentBipartite graph: G = (V ,E) and V = A∪B can be partitioned into 2 stablesets A and B.

N. Nisse Graph Theory and applications 23/24

Page 95: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to MatchingExample of application of matching:

stable set: set of vertices pariwise non-adjacentBipartite graph: G = (V ,E) and V = A∪B can be partitioned into 2 stablesets A and B.

Matching in bipartite graphs G = (A∪B,E)

• Hall’s Theorem (1935): ∃ matching saturating A⇔ ∀S ⊆ A, |N(S)| ≥ |S|.• Hungarian Method [Kuhn, 1955]: compute a maximum matching in time O(n3)

N. Nisse Graph Theory and applications 23/24

Page 96: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Ford-Fulkerson Algorithm: Application to Matching

G = (A∪B,E) a bipartite graph, k ∈ NExercise: Prove that there exists a matching of size ≥ k

⇔ exists a s,d-flow of value ≥ k in G∗ (see Picture)

Idea: use the fact that there exists an integral maximum flow

s

d

11 1 1 1 1 1

1 1

1 1

1

11

1

11

111 1

1111111

1

G G*

N. Nisse Graph Theory and applications 23/24

Page 97: Graph Theory and Optimization Flow: Ford-Fulkerson ... · Graph Theory and Optimization Flow: Ford-Fulkerson Algorithm Max Flow- Min Cut duality Nicolas Nisse Université Côte d’Azur,

Transportation Elementary Flow Network Cut Ford-Fulkerson Min Cut=Max flow Menger Matching

Summary: To be remembered

• flow, cut

• Ford-Fulkerson algorithm O(|E |flowmax) for rational capacities

• Min Cut = Max Flow

• Menger Theorem (max # disjoint paths = min size of separator)

• Matching (Hungarian method, Edmonds algorithm, Hall Theorem)

N. Nisse Graph Theory and applications 24/24