max-flow, min-cut, and bipartite...

17
Max-Flow, Min-Cut, and Bipartite Matching March 16, 2016

Upload: others

Post on 25-Jun-2020

25 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Max-Flow, Min-Cut, and Bipartite Matching

March 16, 2016

Page 2: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Max-flow/Min-cut

Max-flowFind flow that maximizes net flow out of the source.

Min-cutFind s− t cut with minimum capacity

Page 3: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Max-Flow

max |f | = max∑v∈V

f(s, v) ←− maximize flow from s

subject to f(u, v) ≤ c(u, v) for all (u, v) ∈ E

all edges have a max edge capacity

and for each v,∑

(u,v)∈E

f(u, v)−∑

(v,u)∈E

f(v, u) = 0

where v 6= s and v 6= t

conservation at interior nodes and 0 ≤ f(u, v)

Page 4: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Min-Cut

min∑

(u,v)∈E

c(u, v)d(u, v)

subject to d(u, v)− p(u) + p(v) ≥ 0 for all (u, v) ∈ E

p(s) = 1

p(t) = 0

p(u) ≥ 0 for all u ∈ V

and d(u, v) ≥ 0 for all (u, v) ∈ E

Page 5: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Min-Cut

I Consider a graph G = (V,E) where s and t are identified asthe source and sink nodes in V .

I An s− t cut is a partition of vertices V into two set S and T ,where S contains nodes “grouped” with s, and T containsnodes “grouped” with t

I The capacity of the cut is the sum of edge capacities leavingS.

I Min-cutFind s− t cut with minimum capacity

Page 6: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Min-Cut

I Consider a graph G = (V,E) where s and t are identified asthe source and sink nodes in V .

I An s− t cut is a partition of vertices V into two set S and T ,where S contains nodes “grouped” with s, and T containsnodes “grouped” with t

I The capacity of the cut is the sum of edge capacities leavingS.

I Min-cutFind s− t cut with minimum capacity

Page 7: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Example

Page 8: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Special type of graph

A bipartite graph, G, is a graph whose vertices can be split intotwo subsets, U and V for which

1. every edge e connects a vertex u ∈ U with a vertex v ∈ V ,and

2. there are no edges between vertices in the same group

A

People

B

C

1

Tasks

2

3

Page 9: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Definition

A matching, M , in G is a set of edges in E such that no two edges havea common vertex. The size of the matching is the number of edges inM .

I Matching is maximal if adding any edge to M destroys thematching property

I Matching is maximum if it contains the largest possible number ofedges

I Matching is perfect if all vertices are adjacent to one edge in thematching

Example M is the set of red edges:

Page 10: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Definition

A matching, M , in G is a set of edges in E such that no two edges havea common vertex. The size of the matching is the number of edges inM .

I Matching is maximal if adding any edge to M destroys thematching property

I Matching is maximum if it contains the largest possible number ofedges

I Matching is perfect if all vertices are adjacent to one edge in thematching

Example M is the set of red edges:

A

B

C

1

2

3

Page 11: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Definition

A matching, M , in G is a set of edges in E such that no two edges havea common vertex. The size of the matching is the number of edges inM .

I Matching is maximal if adding any edge to M destroys thematching property

I Matching is maximum if it contains the largest possible number ofedges

I Matching is perfect if all vertices are adjacent to one edge in thematching

Example M is the set of red edges:

A

B

C

1

2

3

Page 12: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Definition

A matching, M , in G is a set of edges in E such that no two edges havea common vertex. The size of the matching is the number of edges inM .

I Matching is maximal if adding any edge to M destroys thematching property

I Matching is maximum if it contains the largest possible number ofedges

I Matching is perfect if all vertices are adjacent to one edge in thematching

Example M is the set of red edges:

A

B

C

1

2

3

Page 13: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Does a (perfect) matching exist?

Hall’s Marriage TheoremLet G = (U, V,E) be a bipartite graph with |U | = |V |. For a setof nodes X ⊂ U , denote by N(X) the set of nodes in V ⊂ G thatare adjacent to one of the nodes in X. A perfect matching exists ifand only if for every subset, X ⊂ U , |X| ≤ N(X).

A

B

C

1

2

3

I If X = {A,B}, thenN(X) = {1, 2, 3}

I If X = {A,C}, thenN(X) = {2}

Page 14: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

Does a (perfect) matching exist?

Hall’s Marriage TheoremLet G = (U, V,E) be a bipartite graph with |U | = |V |. For a setof nodes X ⊂ U , denote by N(X) the set of nodes in V ⊂ G thatare adjacent to one of the nodes in X. A perfect matching exists ifand only if for every subset, X ⊂ U , |X| ≤ N(X).

A

B

C

1

2

3

I If X = {A,B}, thenN(X) = {1, 2, 3}

I If X = {A,C}, thenN(X) = {2}

Page 15: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

How do we compute a matching (on a bipartite graph)

I Transform the matching problem into a max-flow problem

I Add infinite capacity to edges from U to V

I Add a source node s and a sink node t and edges with unit capacityfrom s to U and edges from V to t.

A

B

C

1

2

3

s t

1

1

1

1

1

1

Page 16: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

How do we compute a matching (on a bipartite graph)

I Transform the matching problem into a max-flow problem

I Add infinite capacity to edges from U to V

I Add a source node s and a sink node t and edges with unit capacityfrom s to U and edges from V to t.

A

B

C

1

2

3

s t

1

1

1

1

1

1

Page 17: Max-Flow, Min-Cut, and Bipartite Matchingmath.tufts.edu/faculty/ktaylor/courses/math87/Resources/Graphs3.pdfMax-Flow, Min-Cut, and Bipartite Matching Created Date: 3/16/2016 4:10:24

How do we compute a matching (on a bipartite graph)

Theorems

I If there exists a matching of size k in G, then the max-flow is ≥ k

I If the max-flow is of size k, then there is a matching of size k.

A

B

C

1

2

3

s t

1

1

1

1

1

1