max-flow, min-cut, and bipartite...
TRANSCRIPT
Max-Flow, Min-Cut, and Bipartite Matching
March 16, 2016
Max-flow/Min-cut
Max-flowFind flow that maximizes net flow out of the source.
Min-cutFind s− t cut with minimum capacity
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)
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
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
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
Example
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
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:
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
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
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
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}
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}
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
∞
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
∞
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
∞