Lecture 5 Lecture 5 Previously in Opt 2 The maximum flow problem - - PowerPoint PPT Presentation

lecture 5 lecture 5
SMART_READER_LITE
LIVE PREVIEW

Lecture 5 Lecture 5 Previously in Opt 2 The maximum flow problem - - PowerPoint PPT Presentation

Lecture 5 Lecture 5 Previously in Opt 2 The maximum flow problem Input G = (N, E), a directed graph The node set N contains: A source node, s A sink node, t u ij = edge capacity; u ij 0 Objective: To maximize


slide-1
SLIDE 1

Lecture 5

slide-2
SLIDE 2

Lecture 5

Previously in Opt 2 …

slide-3
SLIDE 3

The maximum‐flow problem

  • Input

– G = (N, E), a directed graph – The node set N contains:

  • A source node, s
  • A sink node, t

– uij = edge capacity; uij ≥ 0

  • Objective: To maximize net flow into t, subject to

constraints:

– Capacity constraints – Flow conservation constraints: Net flow out of node i = 0

(for each node i in N, except s and t)

slide-4
SLIDE 4

The maximum‐flow problem

  • Input

– G = (N, E), a directed graph – The node set N contains:

  • A source node, s
  • A sink node, t

– uij = edge capacity; uij ≥ 0

  • Objective: To maximize net flow into t, subject to

constraints:

– Capacity constraints – Flow conservation constraints: Total flow into i = total flow out of i

(for each node i in N, except s and t)

slide-5
SLIDE 5

The maximum‐flow problem

  • Example:

s A B t C D

40 15 20 10 15 10 20

slide-6
SLIDE 6

The maximum‐flow problem

  • Example:

Flow value = 15

s A B t C D

40 15 20 10 15 10 20 15 15 15

slide-7
SLIDE 7

Cuts and cut capacities

  • Example:

s A B t C D

40 15 20 10 15 10 20

slide-8
SLIDE 8

Q1 (i>clicker)

slide-9
SLIDE 9

Q1: Which of the following pairs of sets (S, T) is a valid cut, and what is its corresponding cut capacity?

  • A. S = {t, B, C}, T = {s, A, D}, capacity = 50
  • B. S = {s, B, C}, T = {A, t}, capacity = 70
  • C. S = {s, B, C}, T = {A, B, C, t}, capacity = 80
  • D. S = {s, B, C}, T = {A, D, t}, capacity = 70
  • E. S = {s, B, C}, T = {A, D, t},

capacity = 80

s A B t C D

40 15 20 10 15 10 20

slide-10
SLIDE 10

Q1: Which of the following pairs of sets (S, T) is a valid cut, and what is its corresponding cut capacity?

  • A. S = {t, B, C}, T = {s, A, D}, capacity = 50
  • B. S = {s, B, C}, T = {A, t}, capacity = 70
  • C. S = {s, B, C}, T = {A, B, C, t}, capacity = 80
  • D. S = {s, B, C}, T = {A, D, t}, capacity = 70
  • E. S = {s, B, C}, T = {A, D, t},

capacity = 80

s A B t C D

40 15 20 10 15 10 20

S

slide-11
SLIDE 11

Q1: Which of the following pairs of sets (S, T) is a valid cut, and what is its corresponding cut capacity?

  • A. S = {t, B, C}, T = {s, A, D}, capacity = 50
  • B. S = {s, B, C}, T = {A, t}, capacity = 70
  • C. E = {s, B, C}, T = {A, B, C, t}, capacity = 80
  • D. S = {s, B, C}, T = {A, D, t}, capacity = 70
  • E. S = {s, B, C}, T = {A, D, t},

capacity = 80

s A B t C D

40 15 20 10 15 10 20

S

slide-12
SLIDE 12

s A B t C D

40 15 20 10 15 10 20

S

slide-13
SLIDE 13

The maximum‐flow problem and capacities of cuts

Claim 1 The value of any feasible flow

is less than or equal to the capacity of any cut

Claim 2 The maximum flow value

is less than or equal to the capacity of any cut

slide-14
SLIDE 14

Today: Maxflow, continued

More on cuts, flows, and Ford‐Fulkerson’s algorithm

slide-15
SLIDE 15

The maximum‐flow and the minimum‐cut problems

Theorem 1 Consider a maxflow problem with input G = (N, E) and capacities uij for each (i, j) in E. If x* is a feasible flow and (S, T) is a valid cut with the property that

the value of flow of x* = capacity of the cut (S, T),

then x* is a maximum flow.

slide-16
SLIDE 16

The maximum‐flow problem and capacities of cuts

Claim 1 The value of any feasible flow

is less than or equal to the capacity of any cut

Claim 2 The maximum flow value

is less than or equal to the capacity of any cut

slide-17
SLIDE 17

The maximum‐flow problem and capacities of cuts

Claim 1 The value of any feasible flow

is less than or equal to the capacity of any cut

Claim 2’ The maximum flow value

is less than or equal to the smallest cut capacity

slide-18
SLIDE 18

The minimum‐cut problem

  • Input

– G = (N, E), a directed graph – The node set N contains:

  • A source node, s
  • A sink node, t

– uij = edge capacity; uij ≥ 0

  • Objective: To find a cut with minimum cut capacity.

– A cut: A partition of N into sets (S, T), where S contains the source and T contains the sink – Capacity of the cut (S, T) is the sum of capacities of edges that go from S to T:

∈ ∈ ∈ T j S i E, j i ij

u

, s.t. ) , (

slide-19
SLIDE 19

The maximum‐flow and the minimum‐cut problems

Maxflow

  • Input

– G = (N, E), a directed graph – The node set N contains:

  • A source node, s
  • A sink node, t

– uij = edge capacity; uij ≥ 0

  • Objective:

To maximize net flow into t, subject to constraints:

– Capacity constraints – Flow conservation constraints: Net flow out of node i = 0

(for each node i in N, except s and t)

Mincut

  • Input

– G = (N, E), a directed graph – The node set N contains:

  • A source node, s
  • A sink node, t

– uij = edge capacity; uij ≥ 0

  • Objective: To find a cut with

minimum cut capacity.

– A cut: A partition of N into sets (S, T), where S contains the source and T contains the sink – Capacity of the cut (S, T) is the sum of capacities of edges that go from S to T:

∈ ∈ ∈ T j S i E, j i ij

u

, s.t. ) , (

slide-20
SLIDE 20

The maximum‐flow and the minimum‐cut problems

Claim 2’ The maximum flow value

is less than or equal to the minimum cut capacity

slide-21
SLIDE 21

The maximum‐flow and the minimum‐cut problems

Theorem 2 The maximum flow value

is equal to the minimum cut capacity

slide-22
SLIDE 22

The maxflow‐mincut theorem

Theorem 2 The maximum flow value

is equal to the minimum cut capacity

Proof. …

slide-23
SLIDE 23

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.
  • 2. If x is not optimal,

then find a way to improve the flow. Otherwise, if x is optimal, we’re done!

slide-24
SLIDE 24

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.
  • 2. If x is not optimal,

then find a way to improve the flow. Otherwise, if x is optimal, we’re done!

slide-25
SLIDE 25

Example: An initial feasible flow s A B t C D

40 15 20 10 15 10 20 15 15 15

slide-26
SLIDE 26

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.
  • 2. If x is not optimal,

then find a way to improve the flow. Otherwise, if x is optimal, we’re done!

slide-27
SLIDE 27

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.
  • 2. If x is not optimal,

then find a way to improve the flow. Otherwise, if x is optimal, we’re done!

slide-28
SLIDE 28

Finding a way to improve flow

Current solution, x(1) Scratchwork graph for x(1)

s A B t C D

40 15 20 10 15 10 20 15 15 15

s A B t C D

40 15 20 10 15 10 20

Flow value = 15

slide-29
SLIDE 29

Finding a way to improve flow

Current solution, x(1) Scratchwork graph for x(1)

s A B t C D

40 15 20 10 15 10 20 15 15 15

s A B t C D

40 15 20 10 15 10 20 15 15 15

Flow value = 15

slide-30
SLIDE 30

Finding a way to improve flow

Current solution, x(1) Scratchwork graph for x(1)

s A B t C D

40 15 20 10 15 10 20 15 15 15

s A B t C D

40 5 10 15 10 5

Flow value = 15

slide-31
SLIDE 31

Finding a way to improve flow

Current solution, x(1) Scratchwork graph for x(1)

s A B t C D

40 15 20 10 15 10 20 15 15 15

s A B t C D

40 5 10 15 10 5 5 5 5

Flow value = 15

slide-32
SLIDE 32

Finding a way to improve flow

Updated solution, x(2) Scratchwork graph for x(1)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

s A B t C D

40 5 10 15 10 5 5 5 5

Flow value = 20 An augmenting path of capacity 5!

slide-33
SLIDE 33

One more iteration to improve flow?

Current solution, x(2) Scratchwork graph for x(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

s A B t C D

35 5 10 15 5

Flow value = 20

slide-34
SLIDE 34

One more iteration to improve flow?

Current solution, x(2) Scratchwork graph for x(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

s A B t C D

35 5 10 15 5

No way to improve the current solution? Is x(2) an optimal flow?

Flow value = 20

slide-35
SLIDE 35

Nope! A better flow: s A B t C D

40 15 20 10 15 10 20 10 15 10 10 20 5 5 Flow value = 25

slide-36
SLIDE 36

Finding a way to improve flow

Current solution, x(2) Scratchwork graph for x(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

s A B t C D

35 5 10 15 5

Flow value = 20

slide-37
SLIDE 37

Finding a way to improve flow, v.2! By building a Residual Graph

Current solution, x(2) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

Flow value = 20

s A B t C D

35 5 10 15 5 15

slide-38
SLIDE 38

Building a Residual Graph

Current solution, x(2) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

Flow value = 20

s A B t C D

35 5 10 15 5 15 5 15 5 20

slide-39
SLIDE 39

Building a Residual Graph

Current solution, x(2) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

Flow value = 20

s A B t C D

35 5 10 15 5 15 5 15 5 20

slide-40
SLIDE 40

Building a Residual Graph

Current solution, x(2) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

Flow value = 20

s A B t C D

35 5 10 15 5 15 5 15 5 20

slide-41
SLIDE 41

Then, finding an augmenting path in the residual graph

Current solution, x(2) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

Flow value = 20

s A B t C D

35 5 10 15 5 15 5 15 5 20

An augmenting path!

slide-42
SLIDE 42

Then, finding an augmenting path in the residual graph

Current solution, x(2) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

Flow value = 20

s A B t C D

35 5 10 15 5 15 5 15 5 20

An augmenting path of capacity 5!

slide-43
SLIDE 43

Then, finding an augmenting path in the residual graph

Current solution, x(2) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 5 15 5 15 20

Flow value = 20

s A B t C D

35 5 10 15 5 15 5 15 5 20

An augmenting path of capacity 5!

5 5 5 5 5

slide-44
SLIDE 44

Finally, using the augmenting path to

  • btain a better solution

Updated solution, x(3) Residual graph for x(2), Gx(2)

s A B t C D

40 15 20 10 15 10 20 10 15 10 10 20 5 5

Flow value = 25

s A B t C D

35 5 10 15 5 15 5 15 5 20

An augmenting path of capacity 5!

5 5 5 5 5

slide-45
SLIDE 45

To proceed, repeat the steps!

Updated solution, x(3) Residual graph for x(3), Gx(3)

s A B t C D

40 15 20 10 15 10 20 10 15 10 10 20 5 5

Flow value = 25

s A B t C D

30 10 5 10 10 10 15 10 20 5 5

slide-46
SLIDE 46

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.
  • 2. If x is not optimal,

then find a way to improve the flow. Otherwise, if x is optimal, we’re done!

slide-47
SLIDE 47

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.

Construct a residual graph, Gx.

  • 2. Try to find an augmenting path in Gx.

If there is an augmenting path, then use this path to improve the flow. If there is no augmenting path, then x is optimal. We’re done!

slide-48
SLIDE 48

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.

Construct a residual graph, Gx.

  • 2. Try to find an augmenting path in Gx.

If there is an augmenting path, then use this path to improve the flow. If there is no augmenting path, then x is optimal. We’re done!

slide-49
SLIDE 49

No augmenting path = optimal?

Updated solution, x(3) Residual graph for x(3), Gx(3)

s A B t C D

40 15 20 10 15 10 20 10 15 10 10 20 5 5

Flow value = 25

s A B t C D

30 10 5 10 10 10 15 10 20 5 5

slide-50
SLIDE 50

Nodes that are reachable from s in Gx(3)

Updated solution, x(3) Residual graph for x(3), Gx(3)

s A B t C D

40 15 20 10 15 10 20 10 15 10 10 20 5 5

Flow value = 25

s A B t C D

30 10 5 10 10 10 15 10 20 5 5

slide-51
SLIDE 51

Nodes that are reachable from s in Gx(3)

Updated solution, x(3) Residual graph for x(3), Gx(3)

s A B t C D

40 15 20 10 15 10 20 10 15 10 10 20 5 5

Flow value = 25

s A B t C D

30 10 5 10 10 10 15 10 20 5 5

Cut capacity = 25

slide-52
SLIDE 52

The maximum‐flow and the minimum‐cut problems

Theorem 1 Consider a maxflow problem with input G = (N, E) and capacities uij for each (i, j) in E. If x* is a feasible flow and (S, T) is a valid cut with the property that

the value of flow of x* = capacity of the cut (S, T),

then x* is a maximum flow.

slide-53
SLIDE 53

Nodes that are reachable from s in Gx(3)

Updated solution, x(3) Residual graph for x(3), Gx(3)

s A B t C D

40 15 20 10 15 10 20 10 15 10 10 20 5 5

Flow value = 25

s A B t C D

30 10 5 10 10 10 15 10 20 5 5

Cut capacity = 25

By Theorem 1, x(3) is an optimal flow!

slide-54
SLIDE 54

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.

Construct a residual graph, Gx.

  • 2. Try to find an augmenting path in Gx.

If there is an augmenting path, then use this path to improve the flow. If there is no augmenting path, then x is optimal. We’re done! (A cut whose

capacity is equal to the flow value is found.)

slide-55
SLIDE 55

Q2 (i>clicker)

(after the break)

slide-56
SLIDE 56

Q2: Fun and Game!

You win if the number that you choose is closest to half the mean of the numbers chosen by the class.

  • A. 0
  • B. 1
  • C. 2
  • D. 3
  • E. 4
slide-57
SLIDE 57

Back to Ford‐Fulkerson

Tying loose ends

slide-58
SLIDE 58

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.

Construct a residual graph, Gx.

  • 2. Try to find an augmenting path in Gx.

If there is an augmenting path, then use this path to improve the flow. If there is no augmenting path, then x is optimal. We’re done! (A cut whose

capacity is equal to the flow value is found.)

slide-59
SLIDE 59

s A B t C D

40 15 20 10 15 10 20 15 15 15

slide-60
SLIDE 60

s A B t C D

40 15 20 10 15 10 20

slide-61
SLIDE 61

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.

Construct a residual graph, Gx.

  • 2. Try to find an augmenting path in Gx.

If there is an augmenting path, then use this path to improve the flow. If there is no augmenting path, then x is optimal. We’re done! (A cut whose

capacity is equal to the flow value is found.)

slide-62
SLIDE 62

Lazy approach: Obtaining Gx(3) directly from Gx(2)

Residual graph for x(2), Gx(2) Residual graph for x(3), Gx(3)

s A B t C D

30 10 5 10 10 10 15 10 20 5 5

s A B t C D

35 5 10 15 5 15 5 15 5 20

slide-63
SLIDE 63

The Ford‐Fulkerson method

  • 0. Find an initial feasible solution (flow)
  • 1. Consider the current solution, x.

Construct a residual graph, Gx.

  • 2. Try to find an augmenting path in Gx.

If there is an augmenting path, then use this path to improve the flow. If there is no augmenting path, then x is optimal. We’re done! (A cut whose

capacity is equal to the flow value is found.)

slide-64
SLIDE 64

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge.

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

slide-65
SLIDE 65

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

L = {s}

slide-66
SLIDE 66

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

L = {} Current node: s

slide-67
SLIDE 67

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

L = {A}. Edges: (s, A) Current node: s

slide-68
SLIDE 68

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

L = {}. Edges: (s, A) Current node: A

slide-69
SLIDE 69

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

L = {B}. Edges: (s, A), (A, B) Current node: A

slide-70
SLIDE 70

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

L = {}. Edges: (s, A), (A, B) Current node: B

slide-71
SLIDE 71

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge.

  • (repeat)

Residual graph for x(2), Gx(2)

s A B t C D

35 5 10 15 5 15 5 15 5 20

L = {C}. Edges: (s, A), (A, B), (B, C) Current node: B

slide-72
SLIDE 72

Finding an augmenting path (Finding nodes reachable from s)

A labeling algorithm: List of “checked” nodes: L = {s} While L is not empty:

  • Take the first node off the

list L, suppose it’s node i.

  • For each edge (i, j) out of i,

if j is unchecked, check it and add j to the list L. Highlight the edge.

  • (repeat)

At the end of the algorithm

  • ne of the following

happens:

  • 1. The algorithm stops, and

node t is not “checked”. Then, …

  • 2. The algorithm stops, and

node t is “checked”. Then, …

slide-73
SLIDE 73

Some history

slide-74
SLIDE 74

Harris‐Ross, 1955

“ ”