Chapter 8 The Max-Flow Min-Cut Theorem Prof. Tesler Math 154 - - PowerPoint PPT Presentation

chapter 8 the max flow min cut theorem
SMART_READER_LITE
LIVE PREVIEW

Chapter 8 The Max-Flow Min-Cut Theorem Prof. Tesler Math 154 - - PowerPoint PPT Presentation

Chapter 8 The Max-Flow Min-Cut Theorem Prof. Tesler Math 154 Winter 2020 Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 1 / 60 Flows B D A E C Consider sending things through a network Application Rate (e.g., amount per unit time)


slide-1
SLIDE 1

Chapter 8 The Max-Flow Min-Cut Theorem

  • Prof. Tesler

Math 154 Winter 2020

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 1 / 60

slide-2
SLIDE 2

Flows

E A C B D

Consider sending things through a network

Application Rate (e.g., amount per unit time) Water/oil/fluids through pipes GPM: gallons per minute Electrical current through circuit A: amperage = coulombs/sec Trains along rail network Kilotons/year Data through computer network Mbps: megabits/sec

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 2 / 60

slide-3
SLIDE 3

Flows

E A C B D

We send things through a digraph from a source vertex, s, to a sink vertex, t. For the network above, we’ll use s = A and t = E.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 3 / 60

slide-4
SLIDE 4

Flows

E A C B D

Simplifications

Graph is directed and simple (no loops, no multiple edges). Source s has edges going out, but not in; Sink t has edges going in, but not out. If (x, y) is an edge, then (y, x) isn’t. These are simplifications for our first time through it. We’ll remove these restrictions later.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 4 / 60

slide-5
SLIDE 5

Flows

3 3 3 E D C A B

Send 3 units from source to sink on path ABCE.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 5 / 60

slide-6
SLIDE 6

Flows

5 2 3 3 2 D A C E B

Also send 2 units from source to sink on path ABDE. The total units along each edge is marked. Both paths contribute to the flow on edge AB.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 6 / 60

slide-7
SLIDE 7

Flows

5 2 3 3 2 D A C E B

We consider static flows, meaning no time-dependence. Examples: Steady state: 5 units/sec on AB, 2 on BD, etc. Aggregated flow: each month, 5 units on AB, 2 on BD, etc. A static st-flow means a static flow from source s to sink t (similar to terminology uv-paths).

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 7 / 60

slide-8
SLIDE 8

Flow function

5 2 3 3 2 D A C E B

A flow from s to t is a function f : E(G) → R0 from the edges to the nonnegative reals, such that for all vertices x except s and t,

  • w∈N−(x)

f(w, x) =

  • y∈N+(x)

f(x, y) B : 5 = 3 + 2 C : 3 = 3 D : 2 = 2

flow into x = flow out of x

The flow is shown as numbers on the edges ( f(x, y) = 0 if not shown or if (x, y) is not an edge).

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 8 / 60

slide-9
SLIDE 9

Flow function

5 2 3 3 2 D A C E B

A flow from s to t is a function f : E(G) → R0 from the edges to the nonnegative reals, such that for all vertices x except s and t,

  • w∈N−(x)

f(w, x) =

  • y∈N+(x)

f(x, y) B : 5 = 3 + 2 C : 3 = 3 D : 2 = 2

flow into x = flow out of x

This equation is called Kirchhoff’s Law. Kirchhoff developed this law for electrical circuits.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 9 / 60

slide-10
SLIDE 10

Flow function

5 2 3 3 2 D A C E B

1

We started with a flow f(x, y) = 0 everywhere.

2

We added yellow path ABCE:

Increases in- & out-flow at B and C by 3, keeping them balanced. Adds 3 to out-flow at source A / in-flow at sink E, so they’re not balanced.

3

Green path ABDE increases in- & out-flow at B and D by 2 (keeping them balanced) and adds 2 to out-flow at A / in-flow at E.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 10 / 60

slide-11
SLIDE 11

Value of a flow

5 2 3 3 2 D A C E B

The value of a flow is v( f) =

  • y∈N+(s)

f(s, y) −

  • w∈N−(s)

f(w, s) (using source) =

  • w∈N−(t)

f(w, t) −

  • y∈N+(t)

f(t, y) (using sink) At source A: v( f) = 5 − 0 = 5. At sink E: v( f) = (3 + 2) − 0 = 5.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 11 / 60

slide-12
SLIDE 12

Value of a flow

The value of a flow is v( f) =

  • y∈N+(s)

f(s, y) −

  • w∈N−(s)

f(w, s) (using source) =

  • w∈N−(t)

f(w, t) −

  • y∈N+(t)

f(t, y) (using sink) Usually, there are no edges into a source or out from a sink, so the subtracted sums are 0. However, this formula allows for such edges (in which case the subtracted sums might not be 0). Alternate notation: | f| is common instead of v( f).

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 12 / 60

slide-13
SLIDE 13

Capacities

0/20 2/15 0/3 3/5 2/10 3/30 5/30 C E D B A

Each edge has an upper limit on its flow, called the capacity.

A 2 inch steel water pipe has a maximum flow of 45 gallons/minute. Wi-Fi download speed capped at 25 Mbps. Cell phone capped at 5 Mbps. These are examples, and may vary by company / equipment / etc.

Notation: Write two numbers on each edge: flow / capacity

E.g., edge DE: 2/10 means the flow is 2, out of a capacity 10. It is not division giving 0.2. It is not a fraction; can’t replace 2/10 by 1/5.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 13 / 60

slide-14
SLIDE 14

Capacities

0/20 2/15 0/3 3/5 2/10 3/30 5/30 C E D B A

For each edge: f(x, y) = flow on edge (x, y) c(x, y) = capacity on edge (x, y) We require 0 f(x, y) c(x, y) for every edge.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 14 / 60

slide-15
SLIDE 15

Maximum Flow

0/20 2/15 0/3 3/5 2/10 3/30 5/30 C E D B A

Goal: Find a flow maximizing v( f), subject to the capacities. Strategy: Keep finding augmenting paths from source to sink, on which we can add flow. The two paths so far are examples.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 15 / 60

slide-16
SLIDE 16

Paths with backwards edges

0/20 2/15 0/3 3/5 2/10 3/30 5/30 A C B D E

We will allow paths with backwards edges! Consider path ACBDE above. Edge CB is traversed backwards; other edges are forwards. We will “send” 2 units along the yellow path.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 16 / 60

slide-17
SLIDE 17

Paths with backwards edges

0/20 2/15 0/3 3/5 2/10 3/30 5/30 A C B D E 0/20 4/15 2/3 1/5 4/10 3/30 5/30 A C B D E

Add 2 to the flow on each forwards edge. Subtract 2 from the flow on each reverse edge. This keeps the internal nodes balanced, and increases v( f) by 2.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 17 / 60

slide-18
SLIDE 18

Paths with backwards edges

0/20 2/15 0/3 3/5 2/10 3/30 5/30 A C B D E 0/20 4/15 2/3 1/5 4/10 3/30 5/30 A C B D E

Interpretation of using backwards edges: Nothing actually goes backwards! Instead, some paths are rerouted and spliced together differently. 2 units on A → B → C → E are redirected to A → B → D → E. So BC and CE go down 2, while BD and DE go up 2. The 2 units just lost on CE are replaced by 2 new units from AC.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 18 / 60

slide-19
SLIDE 19

Residual capacity

0/20 2/15 0/3 3/5 2/10 3/30 5/30 A C B D E

Back up to before we added 2 to the yellow path. How much could we have added to this path, without going over any edge’s capacity?

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 19 / 60

slide-20
SLIDE 20

Residual capacity

0/20 2/15 0/3 3/5 2/10 3/30 5/30 A C B D E

Let x0 x1 . . . xr be a path in the undirected graph from x0 = s to xr = t. Using edges in the wrong direction is allowed. The residual capacity of an edge is cf (u, v) =    c(u, v) − f(u, v) if (u, v) ∈ E(G); f(v, u) if (v, u) ∈ E(G);

  • therwise.

cf (A, C) = 3, cf (C, B) = 3, cf (B, D) = 13, cf (D, E) = 8.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 20 / 60

slide-21
SLIDE 21

Residual capacity

0/20 2/15 0/3 3/5 2/10 3/30 5/30 A C B D E

Residual capacities along path: cf (A, C) = 3, cf (C, B) = 3, cf (B, D) = 13, cf (D, E) = 8. Let ǫ be the minimum of these: ǫ = min

  • cf (xi−1, xi) : i = 1, . . . , r
  • (here, ǫ = 3)

This is the maximum that we can increase the flow along the path (we have to pick a number that works for all edges on the path). If a path has ǫ > 0, it is called an augmenting path.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 21 / 60

slide-22
SLIDE 22

Residual capacity

0/20 2/15 0/3 3/5 2/10 3/30 5/30 A C B D E 0/20 5/15 3/3 0/5 5/10 3/30 5/30 A C B D E

Use this augmenting path to increase the flow by ǫ = 3. Along the path, add ǫ to the flow for each forwards edge, and subtract it for each reverse edge.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 22 / 60

slide-23
SLIDE 23

Ford-Fulkerson Algorithm

Ford-Fulkerson Algorithm / Method

Given a digraph G, source s, sink t, and edge capacities c(x, y):

1

Initialize f(x, y) = 0 for all vertices x, y.

2

While there is any augmenting path (from s to t with ǫ > 0):

Increase f by ǫ along forwards edges of the path, and decrease f by ǫ along reverse edges.

Ford & Fulkerson didn’t say the specific way to find the paths. People have improved this by developing specific ways to find augmenting paths. Edmonds-Karp Algorithm: use breadth first search to find a shortest (# edges) augmenting path at each step.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 23 / 60

slide-24
SLIDE 24

Ford-Fulkerson Algorithm

0/20 0/15 0/3 0/5 0/10 0/30 0/30 A C B D E 0/20 0/15 0/3 5/5 0/10 5/30 5/30 A C B D E

Start over with the same graph. Originally we sent 3 units on this yellow path, ABCE. Now instead, we use the maximum amount possible: ǫ = 5.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 24 / 60

slide-25
SLIDE 25

Ford-Fulkerson Algorithm

0/20 0/15 0/3 5/5 0/10 5/30 5/30 A C B D E 0/20 10/15 0/3 5/5 10/10 5/30 15/30 A C B D E

Send ǫ = 10 on path ABDE.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 25 / 60

slide-26
SLIDE 26

Ford-Fulkerson Algorithm

0/20 10/15 0/3 5/5 10/10 5/30 15/30 A C B D E 3/20 13/15 3/3 2/5 10/10 8/30 15/30 A C B D E

Send ǫ = 3 on path ACBDCE.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 26 / 60

slide-27
SLIDE 27

Ford-Fulkerson Algorithm

3/20 13/15 3/3 2/5 10/10 8/30 15/30 E D B A C 5/20 15/15 3/3 2/5 10/10 10/30 17/30 A C B D E

Send ǫ = 2 on path ABDCE.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 27 / 60

slide-28
SLIDE 28

Ford-Fulkerson Algorithm

5/20 15/15 3/3 2/5 10/10 10/30 17/30 A C B D E 5/20 15/15 3/3 5/5 10/10 13/30 20/30 A C B D E

Send ǫ = 3 on path ABCE.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 28 / 60

slide-29
SLIDE 29

Ford-Fulkerson Algorithm

5/20 15/15 3/3 5/5 10/10 13/30 20/30 E A C B D

Starting at A, we have to go on edge AB (it has residual capacity, while AC does not). But at B, there is no residual capacity on BD or BC. We’re stuck! We got v( f) = 23. Could a different choice of paths have lead to a higher flow value?

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 29 / 60

slide-30
SLIDE 30

Ford-Fulkerson Algorithm

(15−x) /20 15/15 3/3 5/5 x/10 20/30 (23−x) /30 E A C B D

We will see that v( f) = 23 is the maximum possible; however, there are multiple flows achieving this maximum. Above, any real number x ∈ [0, 10] gives a flow with v( f) = 23. If you use integer capacities, the Ford-Fulkerson Algorithm (and algorithms based on it) only produces flows with integer values on each edge, even though there may be non-integer solutions.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 30 / 60

slide-31
SLIDE 31

Ford-Fulkerson Algorithm

(15−x) /20 15/15 3/3 5/5 x/10 20/30 (23−x) /30 E A C B D

With integer capacities, Ford-Fulkerson must terminate (flow increases by 1 for each iteration, while capacity is finite). With real # capacities, there are examples where certain choices

  • f paths lead to an infinite loop that may not even converge to the

correct answer; yet, if paths are chosen carefully, it will terminate. The Edmonds-Karp Algorithm chooses paths carefully to terminate in about |V| |E|2 steps.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 31 / 60

slide-32
SLIDE 32

Cuts

3/20 13/15 3/3 2/5 10/10 8/30 15/30 B C D A E

A cut is a partition (S, T) of the vertices with s ∈ S and t ∈ T:

As a set partition, S ∪ T = V(G) and S ∩ T = ∅. So T = V(G) \ S. Our book denotes T by S.

The capacity of a cut is the sum of capacities of edges xy with x ∈ S and y ∈ T: c(S, T) =

  • x∈S
  • y∈T

c(x, y)

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 32 / 60

slide-33
SLIDE 33

Cuts

3/20 13/15 3/3 2/5 10/10 8/30 15/30 B C D A E

Here the cut (red line) is S = {A, B, C} and T = {D, E}. Edges crossing from S to T are BD and CE. The capacity of this cut is c(S, T) = c(B, D) + c(C, E) = 15 + 30 = 45. This sum does not use edges from T to S: DC. Nor edges with both ends in S (AB, AC, BC) or both in T (DE).

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 33 / 60

slide-34
SLIDE 34

Cuts

3/20 13/15 3/3 2/5 10/10 8/30 15/30 B C D A E

Here the cut (red line) is S = {A, B, C} and T = {D, E}. In principle, with n 2 vertices, there are 2n−2 possible cuts. In practice, for the cuts we actually use, you can often draw a line/curve separating S on one side and T on the other.

The side with the source (s) is S and the side with the sink (t) is T. G[S] and G[T] are connected for the cuts we actually use (but that’s not required for an arbitrary cut). For planar embeddings and some

  • ther drawings, it’s feasible to draw such a line/curve.
  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 34 / 60

slide-35
SLIDE 35

Computing value of a flow using a cut

Lemma

For any flow f and any cut (S, T): v( f) =

  • x∈S
  • y∈T

f(x, y) −

  • w∈T
  • x∈S

f(w, x) Proof: The net flow at a vertex x is: g(x) =

  • y∈N+(x)

f(x, y) −

  • w∈N−(x)

f(w, x) By Kirchhoff’s Law, g(x) = 0 for all vertices besides s and t. Also, the value of a flow is defined as v( f) = g(s) (using source). Compute

x∈S g(x):

It equals v( f) since s ∈ S gives g(s) = v( f), and all other x ∈ S give g(x) = 0.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 35 / 60

slide-36
SLIDE 36

Computing value of a flow using a cut

Lemma

For any flow f and any cut (S, T): v( f) =

  • x∈S
  • y∈T

f(x, y) −

  • w∈T
  • x∈S

f(w, x) Proof, continued: So far, we have v( f) =  

x∈S

  • y∈N+(x)

f(x, y)   −  

x∈S

  • w∈N−(x)

f(w, x)   The terms of this correspond to certain edges of the graph. Edges with both ends in S give + f(x, y) in 1st sum − f(x, y) in 2nd sum, and cancel. Only edges with one end in S and the other in T survive.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 36 / 60

slide-37
SLIDE 37

Computing value of a flow using a cut — Example

3/20 13/15 3/3 2/5 10/10 8/30 15/30 B C D A E

Cut S = {A, B, C} T = {D, E} Computing

x∈S g(x):

  • x∈S
  • y∈N+(x)

f(x, y) −

  • x∈S
  • w∈N−(x)

f(w, x)

x = A gives v( f):

= f(A, B) + f(A, C)

x = B gives 0:

+ f(B, D) + f(B, C) − f(A, B)

x = C gives 0:

+ f(C, E) − f(A, C) − f(B, C) − f(D, C)

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 37 / 60

slide-38
SLIDE 38

Computing value of a flow using a cut — Example

3/20 13/15 3/3 2/5 10/10 8/30 15/30 B C D A E

Cut S = {A, B, C} T = {D, E} Computing

x∈S g(x): Cancellations

  • x∈S
  • y∈N+(x)

f(x, y) −

  • x∈S
  • w∈N−(x)

f(w, x) = f(A, B) + f(A, C) + f(B, D) + f(B, C) − f(A, B) + f(C, E) − f(A, C) − f(B, C) − f(D, C)

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 38 / 60

slide-39
SLIDE 39

Computing value of a flow using a cut — Example

3/20 13/15 3/3 2/5 10/10 8/30 15/30 B C D A E

Cut S = {A, B, C} T = {D, E} Computing

x∈S g(x): Surviving terms

  • x∈S
  • y∈N+(x)

f(x, y) −

  • x∈S
  • w∈N−(x)

f(w, x) = f(B, D) + f(C, E) − f(D, C) =

  • x∈S
  • y∈T

f(x, y) −

  • w∈T
  • x∈S

f(w, x)

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 39 / 60

slide-40
SLIDE 40

Comparing formulas for value of a flow

Formulas for the value of a flow

v( f) =

  • y∈N+(s)

f(s, y) −

  • w∈N−(s)

f(w, s) (using source) =

  • w∈N−(t)

f(w, t) −

  • y∈N+(t)

f(t, y) (using sink) =

  • x∈S
  • y∈T

f(x, y) −

  • w∈T
  • x∈S

f(w, x) (using cut) First two formulas in terms of the third: Source: S = {s} T = V(G) \ {s} Sink: S = V(G) \ {t} T = {t}

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 40 / 60

slide-41
SLIDE 41

For every flow and every cut, v( f) c(S, T)

For any flow and any cut, v( f) c(S, T) (flow value cut capacity):

  • x∈S
  • y∈T

f(x, y) −

  • w∈T
  • x∈S

f(w, x)

  • =v( f)
  • x∈S
  • y∈T

f(x, y)

  • x∈S
  • y∈T

c(x, y)

  • =c(S,T)

Maximize the left side over all flows, and minimize the right side over all cuts: max {v( f) : flows f}

  • min {c(S, T) : cuts (S, T)}

We will show these are equal!

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 41 / 60

slide-42
SLIDE 42

Choosing a cut to maximize the flow

Input: Digraph G, source s, sink t, edge capacities c(x, y), flow f(x, y). Output: We will construct a particular cut, denoted (Sf , Tf ). Set Sf = {s}. Iteratively add vertices connected to Sf by edges with residual capacity > 0. That is:

Forwards: If f(x, y) < c(x, y) for some x ∈ Sf and y Sf , then add y to Sf . Reverse: If f(w, x) > 0 for some w Sf and x ∈ Sf , then add w to Sf . Keep going till we can’t add any more vertices this way.

After constructing this, check if t ∈ Sf :

If t ∈ Sf , then there is an augmenting path from s to t, so we could increase the flow. Thus, it’s not a maximum flow. If t Sf , the Ford-Fulkerson algorithm terminates. Is it a max flow?

We’ll use the cut (Sf , Tf ) where Tf = V(G) \ Sf .

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 42 / 60

slide-43
SLIDE 43

Choosing a cut to maximize the flow — continued

We just constructed a particular cut (Sf , Tf ) based on a flow f when Ford-Fulkerson terminates. Is it a maximum flow? No more vertices can be added to Sf , so:

FWD: If (x, y) ∈ E(G) with x ∈ Sf and y ∈ Tf , then f(x, y) = c(x, y). REV: If (w, x) ∈ E(G) with x ∈ Sf and w ∈ Tf , then f(w, x) = 0.

For otherwise, we could have added more vertices to Sf . Flow value: v( f) =

  • x∈Sf
  • y∈Tf

f(x, y) −

  • w∈Tf
  • x∈Sf

f(w, x) =

  • x∈Sf
  • y∈Tf

c(x, y) −

  • w∈Tf
  • x∈Sf

= c(Sf , Tf ) − 0 = c(Sf , Tf ) There’s no gap between v( f) and c(Sf , Tf )! So this is simultaneously the maximum flow and the minimum cut.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 43 / 60

slide-44
SLIDE 44

Max-Flow Min-Cut Theorem

Max-Flow Min-Cut Theorem

The maximum flow value equals the minimum cut capacity.

5/20 15/15 3/3 5/5 10/10 13/30 20/30 A B C E D

Flow we found with Ford-Fulkerson has value v( f) = 23. Cut Sf = {A, B}, Tf = {D, E, F} has capacity c(S, T) = c(A, C) + c(B, C) + c(B, D) = 3 + 5 + 15 = 23

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 44 / 60

slide-45
SLIDE 45

Extending types of graphs allowed

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 45 / 60

slide-46
SLIDE 46

Allowing multiple edges

Multiple edges

2

e3 e1 5/6 7/8 3/4 5/6 7/8

Subdivide edges Or merge edges

15/18 3/4 5/6 3/4 7/8 y x x x y y e

Various options to extend to multigraphs: Specify flows, capacities, paths, Kirchhoff’s Law, etc. using edge labels instead of pairs of vertices. Everything works the same but the notation is more cumbersome. Or, subdivide edges to make an equivalent graph w/o multiedges. Or, merge into one edge by adding their flows and capacities. For loops, subdivide them or delete them.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 46 / 60

slide-47
SLIDE 47

Allowing edges both ways

2/15 2/20 0/3 0/5 0/4 0/10 2/30 2/30 C A E D B 2/15 0/20 0/3 5/5 3/4 5/10 2/30 7/30 C A E D B

For path ABCDE, there are edges both ways (C, D) and (D, C). Adding 5 units of flow here requires handling CD specially. Decrease DC (pink) by 2 and increase CD (yellow) by 3.

Residual capacity formula allowing edges both ways

cf (u, v) = c(u, v) − f(u, v)

  • remaining forwards capacity

+ f(v, u)

  • amount cancelable in reverse
  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 47 / 60

slide-48
SLIDE 48

Flows on undirected graphs

6/8 w/capacities

  • 3. Directed graph

w/flow

  • 1. Undirected graph

w/capacities s t /8 /7 /5 /4 /3 s t /7 /7 /5 /5 /8 /8 /4 /3 /4 /3 s t s t 0/7 3/7 5/5 0/5 4/4 0/4 0/8 6/8 2/3 0/3

  • 4. Undirected graph

w/directed flow 5/5 2/3 4/4 3/7

  • 2. Directed graph

1

Input: Undirected graph; source and sink; edge capacities.

2

Each edge → two directed edges.

3

Find directed flow.

4

Output: Directed flow on original undirected edges.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 48 / 60

slide-49
SLIDE 49

Relation to other results

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 49 / 60

slide-50
SLIDE 50

Relation to other results

It turns out that the following theorems are much easier to prove as consequences of each other, than to prove any of them from scratch. Hall’s Theorem. König’s Theorem on Maximum Matchings: Any bipartite graph has α′(G) = β(G). König’s Edge Coloring Theorem: Any bipartite graph has χ′(G) = ∆(G). Menger’s Theorems (both vertex and edge versions). The Max-Flow Min-Cut Theorem. And some other results beyond this course.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 50 / 60

slide-51
SLIDE 51

Max-Flow Min-Cut ⇒ Menger’s Theorem edge−disjoint paths Minimum size edge separator Max # of pairwise u v u v

Menger’s Theorem (Edge Form)

Let u and v be distinct vertices of an undirected graph G. The minimum size of a uv-edge-separator equals the maximum number of pairwise edge-disjoint uv-paths.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 51 / 60

slide-52
SLIDE 52

Max-Flow Min-Cut ⇒ Menger’s Theorem

0/1

u v

1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 0/1 0/1 0/1

Assign all edges a capacity 1. All capacities are integers, so there’s a max flow with integer values. Let k be the max flow value.

Since edge capacities are 1, and edge flows are either 0 or 1, the flow breaks into k paths of flow 1 from u to v. No edge can be used twice, so the paths are pairwise edge-disjoint.

Let (S, T) be a minimum cut, so c(S, T) = k also.

So there are k edges xy with x ∈ S, y ∈ T. These edges are a uv-edge-separator.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 52 / 60

slide-53
SLIDE 53

Max-Flow Min-Cut ⇒ Menger’s Theorem

Alternate proof

Input: Undirected graph G, source s, and sink t. Form digraph H with V(H) = V(G), and each edge xy of G gives edges (x, y) and (y, x) in H, both with capacity 1. All capacities are integers, so there’s a max flow with integer values. Let k be the max flow value in H. There are k directed paths in H from u to v, each with flow 1. Call them P1, . . . , Pk. They can’t share any edges in common, but what if for some pair

  • f vertices, both (x, y) and (y, x) are used?

If a path has . . . , x, y, . . . , y, x, . . ., delete the underlined part. If it’s in different paths Pi = u, [A], x, y, [B], v Pj = u, [C], y, x, [D], v then replace these by Pi = u, [A], x, [D], v Pj = u, [C], y, [B], v.

Let (S, T) be a minimum cut in H, so c(S, T) = k also.

So there are k edges xy with x ∈ S, y ∈ T. These edges are a uv-edge-separator.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 53 / 60

slide-54
SLIDE 54

Representing matchings in bipartite graphs with flows

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 54 / 60

slide-55
SLIDE 55

Representing matchings in bipartite graphs with flows

H 2 3 4 1 a b c d 2 3 1 a b c d 4 A B G t s

Let G be a bipartite graph with parts A and B. Form directed graph H with vertices A ∪ B ∪ {s, t}:

s and t are two new vertices. Take all edges of G, and orient them from A to B. Add directed edges (s, a) for all a ∈ A, and (b, t) for all b ∈ B. All edges of H have capacity 1.

In the drawing of H above, all edges are directed downwards, and all edge capacities are 1.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 55 / 60

slide-56
SLIDE 56

Representing matchings in bipartite graphs with flows

A B 2 3 1 a b c d 4 t s H

In the drawing of H above, all edges are directed downwards, and all capacities are 1, so we don’t mark these on the edges. Highlighted edges: Flow 1/1 (downwards) Plain edges: Flow 0/1 (downwards)

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 56 / 60

slide-57
SLIDE 57

Representing matchings in bipartite graphs with flows

2 3 4 1 a b c d A B G 2 3 1 a b c d 4 t s H

Every matching in G corresponds to a flow in H:

Matching {a1, b1} , . . . , {ar, br}. Add flow of 1 along a path s ai bi t for i = 1, . . . , r.

Flow paths are pairwise internally vertex disjoint:

Each ai ∈ A can be used in at most one flow path since c(s, ai) = 1 and flows are integers, so either 0 or 1. Similarly, each bi ∈ B can be used at most once since c(bi, t) = 1.

A matching with k edges corresponds to a flow with v( f) = k. A max matching (size α′(G)) corresponds to a max flow in H.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 57 / 60

slide-58
SLIDE 58

Max-Flow Min-Cut ⇒ König’s Theorem

Any bipartite graph has α′(G) = β(G) (size of max matching = size of min vertex cover)

H A B 2 3 1 a b c d 4 t s

Let (S, T) be a cut in H. Its capacity is c(S, T) = # edges sx with x ∈ A ∩ T (1) + # edges xy with x ∈ A ∩ S & y ∈ B ∩ T (2) + # edges yt with y ∈ B ∩ S (3) If xy is an edge of form (2), let S′ = S ∪ {y}, T ′ = T \ {y}.

In c(S′, T ′), (1) doesn’t change; (2) goes down 1; (3) goes up 1. So c(S′, T ′) c(S, T). Iterate till there are no edges of form (2).

Applying that to a min cut gives a min cut where term (2) is 0.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 58 / 60

slide-59
SLIDE 59

Max-Flow Min-Cut ⇒ König’s Theorem

Any bipartite graph has α′(G) = β(G) (size of max matching = size of min vertex cover)

H A B 2 3 1 a b c d 4 t s

Let (S, T) be a cut in H. Its capacity is c(S, T) = # edges sx with x ∈ A ∩ T (1) + # edges xy with x ∈ A ∩ S & y ∈ B ∩ T (2) + # edges yt with y ∈ B ∩ S (3) = |A ∩ T| + |B ∩ S| if term (2) is 0 Let C = (A ∩ T) ∪ (B ∩ S).

If term (2) is 0, then C is a vertex cover in G: all edges xy with x ∈ A and y ∈ B have x ∈ A ∩ T or y ∈ B ∩ S.

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 59 / 60

slide-60
SLIDE 60

Max-Flow Min-Cut ⇒ König’s Theorem

Any bipartite graph has α′(G) = β(G) (size of max matching = size of min vertex cover)

H 2 3 4 1 a b c d A B G 2 3 1 a b c d 4 t s

Right:

Max flow f (1 on each highlighted path, downwards), value k. Min cut with no edges from A ∩ S to B ∩ T. Edges crossing the cut: s to A ∩ T (sd) and B ∩ S to t (1t, 2t). Total # edges crossing cut: |A ∩ T| + |B ∩ S| = k.

Left:

Max matching (magenta) = middle edge of highlighted paths. Min vertex cover (A ∩ T) ∪ (B ∩ S) = {d, 1, 2} (pink vertices).

  • Prof. Tesler
  • Ch. 8: Flows

Math 154 / Winter 2020 60 / 60