Title: Maximum Bipartite Matching
1Maximum Bipartite Matching
- M-augmenting path A path that alternates between
edges in M and edges not in M and has endpoints
unsaturated by M. - Theorem 3.10 A matching M is a maximum matching
in G iff G has no M-augmenting path. - We can enlarge M if M-augmenting path exists.
X
Y
2The Idea
- Iteratively seek augmenting paths to enlarge the
current matching till no M-augmenting path can be
found.
3How to seek M-augmenting path?
X
Y
- Let U be the set of M-unsaturated vertices in X.
One endpoint of an M-augmenting path is in U. - If node x is in U and xy?E(G) for some
unsaturated node y, then an M-augmenting path is
found. - Let S?X be the set of vertices reached by
exploring M-alternating paths from U. If node x
is in S and xy?E(G) for some unsaturated node y,
then an M-augmenting path is found.
4How to seek M-augmenting path?
S
x
x
x
x
x
U
X
w
w
w
y
y
y
Y
T
5Algorithm 3.2.1
- 1. SU and T?.
- 2. If S has no unmarked vertex, stop and report
T?(X-S) as a minimum cover and M as a maximum
matching. - 3. Explore alternating path from an unmark x?S.
- 3.1. If there exists unsaturated y?N(x) such
that xy?M, then stop and report an M-augmenting
path from U to y. - 3.2. For each xy?E(G), include y in T and
include w in S, where yw?M. Mark x and Goto Step
2.
6Theorem 3.2.2
- Repeatedly applying Algorithm 3.2.1 to a
bipartite graph produces a matching and a vertex
cover of equal size
7How to show the current matching M has maximum
size?
- Theorem 3.1.16 If G is a bipartite graph, then
the maximum size of a matching in G equals to the
minimum size of a vertex cover in G - Find a vertex cover with the same size as the
current matching - If S has no unmarked vertex (no M-augmenting path
is found), stop and report T?(X-S) as a minimum
cover and M as a maximum matching.
8T?(X-S) is a vertex cover
S
X-S
X
Y
T
Y-T
9M TX-S
- Mlt TX-S
- T?(X-S) is a vertex cover
- M gt TX-S edges.
- Each y?T is M-saturated.
- Each vertex of X-S is M-saturated.
- No edge in M joins T to X-S.
S
X-S
X
Y
T
Y-T
10Maximum Weighted Bipartite Matching
- A farming company owns n farms and n processing
plants. The profit that results from sending the
output of farm i to plant j is wi,j. - The company wants to select edges forming a
matching to maximize total profit.
v1
v2
v3
u1
u2
u3
u1
u2
v3
v2
v1
u3
Edge weight Wi,j
w(M)65819
11Minimum Weighted Cover
- The government will pay ui if the company agrees
not to use farm i and vj if it agrees not to use
plant j. - The government must offer amounts such that
uivjgtwi,j for all i, j. Otherwise, the company
makes more by using edge xiyj than taking the
government payments for those vertices. - The government wants to minimize ?ui?vj.
v1
v2
v3
c(u)
4
5
7
u1
u2
u3
c(v)
0
2
1
Edge weight Wi,j
c(u,v)19
12Lemma 3.2.7 Duality of minimum c(u,v) and
maximum w(M)
- For a perfect matching M and weighted cover (u,v)
in a weighted bipartite graph G, - (1) c(u,v)gtw(M)
- (2) c(u,v) w(M) iff M consists of edges xiyj
such that uivjwi,j. - In (2), M and c(u,v) are optimal.
since uivjgtwi,j for all i, j.
4
5
7
c(u)
u1
u2
u3
v3
v2
v1
c(v)
0
2
1
w(M)65819
c(u,v)19
13Equality Subgraph
- Equality Subgraph The equality subgraph Gu,v for
a weighted cover (u,v) is the spanning subgraph
of Kn,n whose edges are the pairs xiyj such that
uivjwi,j. - In the cover, the excess for i,j is uivj-wi,j.
Kn,n
v1
v2
v3
c(u)
4
5
7
u1
u2
u3
u1
u2
u3
v3
v2
v1
c(v)
0
2
1
Edge weight Wi,j
14Algorithm 3.2.9
- Input A matrix of weights on the edges of Kn,n
with bipartition X,Y. - Output A maximum weighted matching.
- Idea Iteratively adjust the cover (u,v) until
the equality subgraph Gu,v has a perfect matching.
15Algorithm 3.2.9
- Initialization Let (u,v) be a cover, such that
uimaxj wi,j and vj0.
? u1 max 4, 1, 6, 2, 3 6, v1 0 u2
max 5, 0, 3, 7, 6 7, v2 0 u3 max 2,
3, 4, 5, 8 8, v3 0 u4 max 3, 4, 6, 3,
4 6, v4 0 u5 max 4, 6, 5, 8, 6 8,
v5 0
A matrix of weight
0 0 0 0 0
4 1 6 2 3 5 0 3 7 6 2 3 4 5 8 3 4 6
3 4 4 6 5 8 6
6 7 8 6 8
16Algorithm 3.2.9
0 0 0 0 0
4 1 6 2 3 5 0 3 7 6 2 3 4 5 8 3 4 6
3 4 4 6 5 8 6
60-4 60-1 60-6 60-2 60-3 70-5 70-0
70-3 70-7 70-6 80-2 80-3 80-4 80-5
80-8 60-3 60-4 60-6 60-3 60-4 80-4
80-6 80-5 80-8 80-6
excess matrix
6 7 8 6 8
R
2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0
3 2 4 2 3 0 2
X
R
Y
T T
T T
17Algorithm 3.2.9
- How to adjust the cover (u,v) such that the
equality subgraph Gu,v has a perfect matching? - Add any edge incident to a vertex in QR?T into
Gu,v does not work. - Decrease the excess for each edge not incident to
a vertex in QR?T. - No edge has a negative excess after adjusting the
cover (u,v).
18Algorithm 3.2.9
0 0 0 0 0
R
2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0
3 2 4 2 3 0 2
6 7 8 6 8
min
X
e
R
Y
T T
T T T
T T
e
0 0 11 11 01
min
0 0 0 0 0
1 1
0 3 0 4 2 0 5 4 0
0 5 4 5 4 0 1 0 0 3
1 2 0 3 0 1
5-1 6-1 8-1 5-1 7-1
6-1 7-1 8 6-1 8-1
1 4 0 4 2 1 6 4 0
0 6 5 5 4 0 2 1 0 3
1 5 1 3 0 1
TTT
19Algorithm 3.2.9
- 1. Find a maximum matching M in Gu,v. If M is
perfect matching, stop and report M as a maximum
weighted matching. - 2. Let Q be a vertex cover of size M in Gu,v.
Let RX?Q and TY?Q. Let eminuivj- wi,j
xi?X-R, yj?Y-T. - 3. Decreases ui by e for xi ?X-R, and increases
vj by e for yj ?T. - 4. Form the new equality graph and Goto Step 1.
20Theorem 3.2.11
- Algorithm 3.2.9 finds a maximum weight matching
and a minimum cost cover - Let (u,v) be the current cover and suppose that
the equality subgraph has no perfect matching.
Let (u,v) be the new lists of numbers assigned
to the vertices. - Show (u,v) is a cover by discuss 3 cases 1)
edge from X-R to T or from R to Y-T, 2) edges
from R to T, and 3) edge from X-R to Y-T.
21Theorem 3.2.11
- Case 1 uivj uivj for edges xiyj from X-R to
T or from R to Y-T. - ? (u,v) is a cover
0 0 0 0 0
0 0 01 01 0
2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0
3 2 4 2 3 0 2
6 7 8 6 8
6-1 7-1 8 6-1 8-1
1 4 0 4 2 1 6 4 0
0 6 5 5 4 0 2 1 0 3
1 5 1 3 0 1
R
R
T T
T T
22Theorem 3.2.11
- Case 2 uivj uivje for edges xiyj from R to
T. - ? (u,v) is a cover
-
0 0 0 0 0
0 0 01 01 0
2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0
3 2 4 2 3 0 2
6 7 8 6 8
6-1 7-1 8 6-1 8-1
1 4 0 4 2 1 6 4 0
0 6 5 5 4 0 2 1 0 3
1 5 1 3 0 1
R
R
T T
T T
23Theorem 3.2.11
- Case 3 uivj uivj-e for edges xiyj from X-R
to Y-T. - ? (u,v) is a cover
since eminuivj- wi,j xi?X-R, yj?Y-T.
0 0 0 0 0
0 0 01 01 0
2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0
3 2 4 2 3 0 2
6 7 8 6 8
6-1 7-1 8 6-1 8-1
1 4 0 4 2 1 6 4 0
0 6 5 5 4 0 2 1 0 3
1 5 1 3 0 1
R
R
T T
T T
24Theorem 3.2.11
- 3. It terminates only when the equality subgraph
has a perfect matching. ? equal value for the
current matching and cover. - 4. We need to show Algorithm 3.2.9 always
terminate. - 5. It suffices to show at each iteration the cost
of the cover is reduced at least e because the
cost starts at some value and is bounded below by
the weight of a perfect matching.
25Theorem 3.2.11
- M is not a perfect matching. ? QMltX. ?
RTltX-RR.
? TltX-R.
-e
X-R
R
X
Y
T
e