CSE 202: Design and Analysis of Algorithms: Instructor: Kamalika Chaudhuri
CSE 202: Design and Analysis of Algorithms: Instructor: Kamalika Chaudhuri
CSE 202: Design and Analysis of Algorithms: Instructor: Kamalika Chaudhuri
Analysis of Algorithms
!
Lecture 12
!
Instructor: Kamalika Chaudhuri
Application: Maximum Cardinality Bipartite
Matching
A matching M is a set of edges (u, v) such that no two edges share a common vertex
Given a bipartite graph G = (L, R), find a matching in G of maximum cardinality
Arthur Angela
Bill Beth
Perfect matching: a matching of size n,
Charles Connie where n=#vertices in L=#vertices in R
David Doris
Can be solved using our maxflow algorithm (we will see how)
David Doris L 1 R
L R Set up a flow problem in graph H:
Source s: connected to all nodes in L
Perfect matching: a matching of size n, Sink t: connected to all nodes in R
where n=#vertices in L=#vertices in R Each edge has unit capacity
David Doris 1
L R L R
David Doris 1
L R L R
David Doris 1
L R L R
2. Suppose H has a max flow of size s. Then H has an integral max flow f of size s.
Let Y = (u, v) be the edges s.t. u in L, v in R, and f(e) = 1. Then, no u or v can be adjacent
to >1 nodes in Y (otherwise, capacity constraints violated). Thus Y is a matching
Cardinality(Y) = Flow through cut (L,R) = size(f)
Bipartite Matching
Graph G: Graph H:
1
Arthur Angela
1 1
1
Bill Beth 1 1
1
s 1 1 t
Charles Connie 1 1 1 1
David Doris 1
L R L R
Algorithm:
Bipartite Matching
Graph G: Graph H:
1
Arthur Angela
1 1
1
Bill Beth 1 1
1
s 1 1 t
Charles Connie 1 1 1 1
David Doris 1
L R L R
Graph G: Graph H:
1
Arthur Angela
1 1
1
Bill Beth 1 1
1
s 1 1 t
Charles Connie 1 1 1 1
David Doris 1
L R L R
• Exhaustive Search
• Greedy Algorithms: Build a solution incrementally piece
by piece