17
CS 312: Algorithm Analysis Lecture #28: Network Flow and Cuts This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License . es by: Eric Ringger, with contributions from Mike Jones

CS 312: Algorithm Analysis

  • Upload
    tanner

  • View
    18

  • Download
    0

Embed Size (px)

DESCRIPTION

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License . CS 312: Algorithm Analysis. Lecture #28: Network Flow and Cuts. Slides by: Eric Ringger, with contributions from Mike Jones. Objectives. - PowerPoint PPT Presentation

Citation preview

Page 1: CS 312:  Algorithm Analysis

CS 312: Algorithm Analysis

Lecture #28: Network Flow and Cuts

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

Slides by: Eric Ringger, with contributions from Mike Jones

Page 2: CS 312:  Algorithm Analysis

Objectives

Understand the idea of “changing the problem” in the max flow algorithm

Solve min-cut (using max-flow) Solve Bipartite Matching (using max-flow) See example of Padded matrix-vector

representation

Page 3: CS 312:  Algorithm Analysis

Volunteer

s

b

d

t

4 2

2 4

4

e

f

2

4

6

Page 4: CS 312:  Algorithm Analysis

Max Flow

Key points When we transform the problem we create

“imaginary edges” However, in the end our selected paths

always produce a flow schedule that involves only the original edges.

Page 5: CS 312:  Algorithm Analysis

Cut

An (s,t)-cut partitions the vertices into two disjoint sets:L contains sR contains t

s

b

d

t

4 2

2 4

4

e

f

2

4

6

To compute the capacity of a cut, add up the capacitiesof edges that flow across the cut from L to R (not R to L!).

L:SourceSide

R:SinkSide

Page 6: CS 312:  Algorithm Analysis

Max-flow min-cut Theorem

s

b

d

t

4 2

2 4

4

e

f

2

4

6

Max flow is less than or equal to the capacity of any cut. Max flow is equal to the capacity of the min cut.

Page 7: CS 312:  Algorithm Analysis

Another Example

Page 8: CS 312:  Algorithm Analysis
Page 9: CS 312:  Algorithm Analysis
Page 10: CS 312:  Algorithm Analysis
Page 11: CS 312:  Algorithm Analysis
Page 12: CS 312:  Algorithm Analysis
Page 13: CS 312:  Algorithm Analysis

We can now find the min cut in the original graph by finding all of the nodes that are reachable from the source in the final residual graph . The min cut value is equal to the max flow.

Page 14: CS 312:  Algorithm Analysis

Bipartite Matching

• We can use our solution to the max-flow problem to find maximal matchings.

Page 15: CS 312:  Algorithm Analysis

Big ideas Max-flow is a nice graphical version of the Simplex

algorithm Proceed greedily, but use slack variables so that you can

change your decisions later on. Find a quick & dirty solution (not necessarily optimal) in order to

remove some slack from the problem; then transform the problem and try again!

Max-flow can be used to solve other interesting problems Min-cut Matching

Page 16: CS 312:  Algorithm Analysis

LP: Padded Matrices & VectorsStandard Form (Step #1)

Subject to:

Matrix/vector notation (Step #1)

Subject to:

Where is an optional constant in the objective function

Standard Form (Step #2)

Subject to:

Matrix/vector notation (Step #2)

Subject to:

Where are the indices of the nonbasic (original) variables and are the indices of the basic (slack) variables.

Page 17: CS 312:  Algorithm Analysis

Project #6 Linear Programming Important: LP Notes available on the schedule

Works through the ideas up through the Simplex algorithm Sets you up to succeed on project #6 Includes the pseudo-code for Simplex (and Pivot)

HW #21: Formulate problem for Proj. #6 NO 2-hour time limit

Early day: next Thursday Due: next Friday How to Test: Use online solver to verify your result!