Augmenting Paths Math 482, Lecture 25 Misha Lavrov April 3, 2020 - - PowerPoint PPT Presentation

augmenting paths
SMART_READER_LITE
LIVE PREVIEW

Augmenting Paths Math 482, Lecture 25 Misha Lavrov April 3, 2020 - - PowerPoint PPT Presentation

The greedy algorithm Augmenting paths The residual graph Augmenting Paths Math 482, Lecture 25 Misha Lavrov April 3, 2020 The greedy algorithm Augmenting paths The residual graph Lecture plan We know how to find a max flow using an LP.


slide-1
SLIDE 1

The greedy algorithm Augmenting paths The residual graph

Augmenting Paths

Math 482, Lecture 25 Misha Lavrov April 3, 2020

slide-2
SLIDE 2

The greedy algorithm Augmenting paths The residual graph

Lecture plan

We know how to find a max flow using an LP. But this is inefficient; there are many many algorithms that are faster.

slide-3
SLIDE 3

The greedy algorithm Augmenting paths The residual graph

Lecture plan

We know how to find a max flow using an LP. But this is inefficient; there are many many algorithms that are faster. Plan for today:

1 Describe a simple greedy algorithm that tries to find a max

flow.

slide-4
SLIDE 4

The greedy algorithm Augmenting paths The residual graph

Lecture plan

We know how to find a max flow using an LP. But this is inefficient; there are many many algorithms that are faster. Plan for today:

1 Describe a simple greedy algorithm that tries to find a max

flow.

2 See it get stuck.

slide-5
SLIDE 5

The greedy algorithm Augmenting paths The residual graph

Lecture plan

We know how to find a max flow using an LP. But this is inefficient; there are many many algorithms that are faster. Plan for today:

1 Describe a simple greedy algorithm that tries to find a max

flow.

2 See it get stuck. 3 Make the algorithm more powerful.

slide-6
SLIDE 6

The greedy algorithm Augmenting paths The residual graph

Directed s, t-paths

Definition In a network, a directed path from s to t is a sequence s, v1, v2, . . . , vk, t where v1, v2, . . . , vk ∈ N and (s, v1), (v1, v2), . . . , (vk, t) ∈ A.

slide-7
SLIDE 7

The greedy algorithm Augmenting paths The residual graph

Directed s, t-paths

Definition In a network, a directed path from s to t is a sequence s → v1 → v2 · · · → vk → t where v1, v2, . . . , vk ∈ N and (s, v1), (v1, v2), . . . , (vk, t) ∈ A.

slide-8
SLIDE 8

The greedy algorithm Augmenting paths The residual graph

Directed s, t-paths

Definition In a network, a directed path from s to t is a sequence s → v1 → v2 · · · → vk → t where v1, v2, . . . , vk ∈ N and (s, v1), (v1, v2), . . . , (vk, t) ∈ A. Example: s t a b c d

0/10 0/10 0/12 0/10 0/4 0/8 0/4 0/4

slide-9
SLIDE 9

The greedy algorithm Augmenting paths The residual graph

Directed s, t-paths

Definition In a network, a directed path from s to t is a sequence s → v1 → v2 · · · → vk → t where v1, v2, . . . , vk ∈ N and (s, v1), (v1, v2), . . . , (vk, t) ∈ A. Example: directed path s → a → b → t s t a b c d

0/10 0/10 0/12 0/10 0/4 0/8 0/4 0/4

slide-10
SLIDE 10

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

0/10 0/10 0/12 0/10 0/4 0/8 0/4 0/4

slide-11
SLIDE 11

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

0/10 0/10 0/12 0/10 0/4 0/8 0/4 0/4

slide-12
SLIDE 12

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 10/12 0/10 0/4 0/8 0/4 0/4

slide-13
SLIDE 13

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 10/12 0/10 0/4 0/8 0/4 0/4

slide-14
SLIDE 14

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 10/12 0/10 0/4 0/8 0/4 0/4

slide-15
SLIDE 15

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 10/12 4/10 4/4 4/8 0/4 0/4

slide-16
SLIDE 16

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 10/12 4/10 4/4 4/8 0/4 0/4

slide-17
SLIDE 17

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 10/12 4/10 4/4 4/8 0/4 0/4

slide-18
SLIDE 18

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 12/12 6/10 4/4 4/8 2/4 0/4

slide-19
SLIDE 19

The greedy algorithm Augmenting paths The residual graph

Using a directed path

Whenever we have a directed path from s to t and all arcs along the path are below capacity, we can use it to increase the flow. s t a b c d

10/10 10/10 12/12 6/10 4/4 4/8 2/4 0/4

At this point, there are no more directed paths where all arcs are below capacity. But is this the maximum flow?

slide-20
SLIDE 20

The greedy algorithm Augmenting paths The residual graph

A further improvement

If we redirect some a → b → t flow to go a → d → t, we can send more flow along the path s → c → d → t. . . s t a b c d

10/10 12/12 4/4 6/10 2/4 10/10 0/4 4/8

slide-21
SLIDE 21

The greedy algorithm Augmenting paths The residual graph

A further improvement

If we redirect some a → b → t flow to go a → d → t, we can send more flow along the path s → c → d → t. . . s t a b c d

10/10 12/12 4/4 6/10 2/4 10/10 0/4 4/8

Increase flow along red edges, decrease flow along blue edge.

slide-22
SLIDE 22

The greedy algorithm Augmenting paths The residual graph

A further improvement

If we redirect some a → b → t flow to go a → d → t, we can send more flow along the path s → c → d → t. . . s t a b c d

10/10 12/12 4/4 6/10 2/4 10/10 0/4 4/8

Increase flow along red edges, decrease flow along blue edge. Note: s → c → b ← a → d → t is almost a directed path.

slide-23
SLIDE 23

The greedy algorithm Augmenting paths The residual graph

Augmenting paths

Definition Given a network (N, A) and a feasible flow x, an augmenting path for x is a sequence of nodes s = v0, v1, v2, . . . , vk, vk+1 = t such that for each pair vi, vi+1: either e = (vi, vi+1) is an arc below capacity (e ∈ A and xe < ce)

slide-24
SLIDE 24

The greedy algorithm Augmenting paths The residual graph

Augmenting paths

Definition Given a network (N, A) and a feasible flow x, an augmenting path for x is a sequence of nodes s = v0, v1, v2, . . . , vk, vk+1 = t such that for each pair vi, vi+1: either e = (vi, vi+1) is an arc below capacity (e ∈ A and xe < ce)

  • r e = (vi+1, vi) is an arc with positive flow

(e ∈ A and xe > 0).

slide-25
SLIDE 25

The greedy algorithm Augmenting paths The residual graph

Augmenting paths

Definition Given a network (N, A) and a feasible flow x, an augmenting path for x is a sequence of nodes s = v0, v1, v2, . . . , vk, vk+1 = t such that for each pair vi, vi+1: either e = (vi, vi+1) is an arc below capacity (e ∈ A and xe < ce)

  • r e = (vi+1, vi) is an arc with positive flow

(e ∈ A and xe > 0). The sequence s → c → b ← a → d → t we found on the previous slide was an augmenting path.

slide-26
SLIDE 26

The greedy algorithm Augmenting paths The residual graph

Using an augmenting path to improve x

To augment a feasible flow x along an augmenting path:

1 Let δ > 0 be the largest value such that

xe ≤ ce − δ for all forward arcs on the path; xe ≥ δ for all backward arcs on the path.

slide-27
SLIDE 27

The greedy algorithm Augmenting paths The residual graph

Using an augmenting path to improve x

To augment a feasible flow x along an augmenting path:

1 Let δ > 0 be the largest value such that

xe ≤ ce − δ for all forward arcs on the path; xe ≥ δ for all backward arcs on the path.

2 For each forward arc e, increase xe by δ.

slide-28
SLIDE 28

The greedy algorithm Augmenting paths The residual graph

Using an augmenting path to improve x

To augment a feasible flow x along an augmenting path:

1 Let δ > 0 be the largest value such that

xe ≤ ce − δ for all forward arcs on the path; xe ≥ δ for all backward arcs on the path.

2 For each forward arc e, increase xe by δ. 3 For each backward arc e, decrease xe by δ.

slide-29
SLIDE 29

The greedy algorithm Augmenting paths The residual graph

Using an augmenting path to improve x

To augment a feasible flow x along an augmenting path:

1 Let δ > 0 be the largest value such that

xe ≤ ce − δ for all forward arcs on the path; xe ≥ δ for all backward arcs on the path.

2 For each forward arc e, increase xe by δ. 3 For each backward arc e, decrease xe by δ.

When we do this, flow is still conserved at internal nodes of the augmenting path. There are four possible cases: · · · +δ − − → p +δ − − → · · · · · · +δ − − → q

−δ

← − − · · · · · ·

−δ

← − − r

− − → · · · · · ·

−δ

← − − s

−δ

← − − · · ·

slide-30
SLIDE 30

The greedy algorithm Augmenting paths The residual graph

Example of augmenting

s t a b c d

10/10 12/12 4/4 6/10 2/4 10/10 0/4 4/8

1 Find the augmenting path.

slide-31
SLIDE 31

The greedy algorithm Augmenting paths The residual graph

Example of augmenting

s t a b c d

10/10 12/12 4/4 6/10 2/4 10/10 0/4 4/8

1 Find the augmenting path s → c → b ← a → d → t.

slide-32
SLIDE 32

The greedy algorithm Augmenting paths The residual graph

Example of augmenting

s t a b c d

10/10 12/12 4/4 6/10 2/4 10/10 0/4 4/8

1 Find the augmenting path s → c → b ← a → d → t. 2 Find the value δ we can augment by.

slide-33
SLIDE 33

The greedy algorithm Augmenting paths The residual graph

Example of augmenting

s t a b c d

10/10 12/12 4/4 6/10 2/4 10/10 0/4 4/8

1 Find the augmenting path s → c → b ← a → d → t. 2 Find the value δ we can augment by: here, δ = 2.

slide-34
SLIDE 34

The greedy algorithm Augmenting paths The residual graph

Example of augmenting

s t a b c d

10/10 12/12 4/4 8/10 4/4 8/10 2/4 6/8

1 Find the augmenting path s → c → b ← a → d → t. 2 Find the value δ we can augment by: here, δ = 2. 3 Increase or decrease the flow along each edge by δ.

slide-35
SLIDE 35

The greedy algorithm Augmenting paths The residual graph

Example of augmenting

s t a b c d

10/10 12/12 4/4 8/10 4/4 8/10 2/4 6/8

1 Find the augmenting path s → c → b ← a → d → t. 2 Find the value δ we can augment by: here, δ = 2. 3 Increase or decrease the flow along each edge by δ.

slide-36
SLIDE 36

The greedy algorithm Augmenting paths The residual graph

The residual graph

We define a residual graph to help us find augmenting paths. Definition Given a network (N, A) and a feasible flow x, the residual graph is a network with:

slide-37
SLIDE 37

The greedy algorithm Augmenting paths The residual graph

The residual graph

We define a residual graph to help us find augmenting paths. Definition Given a network (N, A) and a feasible flow x, the residual graph is a network with: The same set of nodes N as the original network.

slide-38
SLIDE 38

The greedy algorithm Augmenting paths The residual graph

The residual graph

We define a residual graph to help us find augmenting paths. Definition Given a network (N, A) and a feasible flow x, the residual graph is a network with: The same set of nodes N as the original network. For each arc (i, j) ∈ A with xij < cij, a “forward” arc (i, j) with residual capacity cij − xij.

slide-39
SLIDE 39

The greedy algorithm Augmenting paths The residual graph

The residual graph

We define a residual graph to help us find augmenting paths. Definition Given a network (N, A) and a feasible flow x, the residual graph is a network with: The same set of nodes N as the original network. For each arc (i, j) ∈ A with xij < cij, a “forward” arc (i, j) with residual capacity cij − xij. For each arc (i, j) ∈ A with xij > 0, a “backward” arc (j, i) with residual capacity xij.

slide-40
SLIDE 40

The greedy algorithm Augmenting paths The residual graph

The residual graph

We define a residual graph to help us find augmenting paths. Definition Given a network (N, A) and a feasible flow x, the residual graph is a network with: The same set of nodes N as the original network. For each arc (i, j) ∈ A with xij < cij, a “forward” arc (i, j) with residual capacity cij − xij. For each arc (i, j) ∈ A with xij > 0, a “backward” arc (j, i) with residual capacity xij. Idea: augmenting paths for x are directed paths in the residual graph.

slide-41
SLIDE 41

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10/10 6/10 10/10 0/4 2/4 4/4 12/12 4/8

slide-42
SLIDE 42

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 6/10 10/10 0/4 2/4 4/4 12/12 4/8

slide-43
SLIDE 43

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10/10 0/4 2/4 4/4 12/12 4/8

slide-44
SLIDE 44

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10 0/4 2/4 4/4 12/12 4/8

slide-45
SLIDE 45

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10 4 2/4 4/4 12/12 4/8

slide-46
SLIDE 46

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10 4 2 2 4/4 12/12 4/8

slide-47
SLIDE 47

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10 4 2 2 4 12/12 4/8

slide-48
SLIDE 48

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10 4 2 2 4 12 4/8

slide-49
SLIDE 49

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10 4 2 2 4 12 4 4

slide-50
SLIDE 50

The greedy algorithm Augmenting paths The residual graph

Residual graph example

We construct the residual graph for our next-to-last feasible flow: s t a b c d

10 4 6 10 4 2 2 4 12 4 4

We can find the augmenting path s → b ← a → d → t by following only forward arrows (of either color) in the residual graph; δ = 2 is the smallest number along those arrows.