Matching Algorithm
Matching Algorithm
In the maximum weighted matching problem a nonnegative weight wi,j is assigned to each edge xiyj of Kn,n and we seek a perfect matching M to maximize the total weight w(M ) = eM w(e). With these weights, a (weighted) cover is a choice of labels u1, . . . , un and v1, . . . , vn, such that ui + vj wi,j for all i, j. The cost c(u, v) of a cover (u, v) is ui + vj . The minimum weighted cover problem is that of nding a cover of minimum cost. Duality Lemma For a perfect matching M and a weighted cover (u, v) in a bipartite graph G, c(u, v) w(M ). Also, c(u, v) = w(M ) iff M consists of edges xiyj such that ui + vj = wi,j . In this case, M and (u, v) are both optimal.
The algorithm
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 ui + vj = wi,j . In the cover, the excess for i, j is ui + vj wi,j . Hungarian Algorithm Input. A matrix (wi,j ) of weights on the edges of Kn.n with partite sets X and Y . Idea. Iteratively adjusting a cover (u, v) until the equality subgraph Gu,v has a perfect matching. Initialization. Let ui = max{wi,j : j = 1, . . . , n} and vj = 0.
stop and report M as a maximum weight matching and (u, v) as a minimum cost cover
ELSE
let Q be a vertex cover of size |M | in Gu,v . R := X Q T := Y Q := min{ui + vj wi,j : xi X \ R, yj Y \ T } Update u and v: ui := ui if xi X \ R vj := vj + if yj T Iterate
1 6 1 3 4
2 7 3 6 1
3 8 4 2 3
4 7 4 8 5
5 2 5 7 4
Excess Matrix
0 0 0 0 0
Equality Subgraph
5 8 5 8 5
4 3 2 1 0
2 1 0 1 6 4 2 1 1 0 5 2 6 0 1
Theorem The Hungarian Algorithm nds a maximum weight matching and a minimum cost cover.
1 4 2 0 1 T T T
=1
3 4
4 7 4 7 4
0 0 1 1 1
The Duality Lemma states that if w(M ) = c(u, v) for some cover (u, v), then M is maximum weight.
R
3 2 2 1 0
1 0 0 1 6 R 3 1 1 1 0 4 1 6 0 1
0 3 2 0 1 T T T
We found a maximum weight matching (transversal). The fact that it is maximum is certied by the indicated cover, which has the same cost:
T T T
=1 3 7 3 6 3
1 0 1 2 2
3 1 1 1 0
2 0 0 2 7 3 0 0 1 0 4 0 5 0 1
3 7 3 6 3
1 0 1 2 2
1 2 3 4 5
6 7 8 7 2 1 3 4 4 5 3 6 2 8 7
4 1 3 5 4
0 2 1 0 1
w(M ) = 5 + 7 + 4 + 8 + 4 = 28 = = 1 + 0 + 1 + 2 + 2+ 3 + 7 + 3 + 6 + 3 = c(u, v)
DONE!!
Why does the algorithm terminate? M is a matching in the new Gu,v as well. So either (i) max matching gets larger or (ii) # of vertices reached from U by M -alternating paths grows. (U is the set of unsaturated vertices of M in X.)
7
Corollaries
Corollary. (Berge,1958) For a subset S V (G) let d(S) = o(G S) |S|. Then 2 (G) = min{n d(S) : S V (G)}. Proof. () Easy. () Apply Tuttes Theorem to G Kd. Corollary. (Petersen, 1891) Every 3-regular graph with no cut-edge has a perfect matching. Proof. Check Tuttes condition. Let S V (G). Double-count the number of edges between an S and the odd components of G S. Observe that between any odd component and S there are at least three edges.
E(G) / E(G)
Obtain contradiction by constructing a perfect matching M of G using perfect matchings M1 and M2 of G+xz and G + yw, respectively.
9
10
Factors
A factor of a graph is a spanning subgraph. A k-factor is a spanning k-regular subgraph.
Every regular bipartite graph has a 1-factor. Not every regular graph has a 1-factor. But... Theorem. (Petersen, 1891) Every 2k-regular graph has a 2-factor. Proof. Use Eulerian cycle of G to create an auxiliary k-regular bipartite graph H, such that a perfect matching in H corresponds to a 2-factor in G.
11