0% found this document useful (0 votes)
12 views13 pages

Matching

Nnjn of the day of the day of the day of the day of the day of the day of the day of the day of the

Uploaded by

Nadeem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views13 pages

Matching

Nnjn of the day of the day of the day of the day of the day of the day of the day of the day of the

Uploaded by

Nadeem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Matchings

Definition: Give an undirected graph G , a matching M is a subset of


the edges E ⊆ M such that each vertex v ∈ V is incident to at most one
edge from M .

Variants of Matching
• Graph can be bipartite or general
• Graph can be weighted or unweighted

Terms
• A matching M such that, for all edges e 6∈ M , M ∪ {e} is not a
matching, is called maximal.
• A maximum cardinality matching is called maximum.
• A matching of size |V |/2 is called perfect.
• The weight of a matching M is w(M ) = w(e) .
P
e∈M

• A maximum weight matching is the matching of maximum weight.


• All variants polynomial time, bipartite matching seems “easier”.
Matchings in Bipartite Graphs

• Can solve via max flow. Ford Fulkerson is O(m|f |) = O(nm) .


• Will develop from first principles to understand terminology and to see
improvements.

Definitions
• An alternating path with respect to a matching M is a path in which
edges alternate between those in M and those not in M .
• A matched vertex is one incident to an edge in M
• An free vertex is a vertex that is not matched
• An augmenting path is an alternating path that starts and ends with a
free vertex.
• A shortest augmenting path is an augmenting path of shortest length.
• Symmetric Difference of 2 sets: A ⊕ B = (A ∪ B) − (A ∩ B)
Augmenting Paths

Facts
• Let M be a matching and P be an augmenting path relative to M .
Then M ⊕ P is a matching and |M ⊕ P | = |M | + 1 .
• Let M be a matching and P1, P2, . . . Pk be k vertex-disjoing augmenting
path relative to M . Then M ⊕ (P1 ∪ P2 ∪ . . . ∪ Pk ) is a matching and
|M ⊕ (P1 ∪ P2 ∪ . . . ∪ Pk )| = |M | + k .

Hopkroft-Karp Algorithm
•M =∅
• Repeat Until P = ∅
– Let P = (P1 ∪ P2 ∪ . . . ∪ Pk ) be a maximal set of vertex disjoint shortest
augmenting paths with respect to M .
– M = M ⊕ (P1 ∪ P2 ∪ . . . ∪ Pk )
Facts

• You can find a maximal set of vertex-disjoint augmenting paths in O(m)


time via breadth-first search.
• Given 2 matchings M and M 0 , let G0 = (v, M ⊕ M 0) , then
– For all vertices, the degree of v in G0 is at most 2.
– G0 is a set of alternating paths and alternating cycles.
– If |M | < |M 0| , then G0 has at least |M 0| − |M | vertex disjoint
augmenting paths with respect to M
Main Lemma

Lemma Let ` be the length of a shortest augmenting path with respect to


M . Let P1, . . . , Pk be a maximal set of vertex disjiont shortest augmenting
paths. Let M 0 = M ⊕ (P1 ∪ . . . Pk ) . Let P be a shortest augmenting path
with respect to M 0 . Then |P | > ` .
Lemma

Lemma If the shortest augmeting path with respect to M has ` edges,


and M 0 is a maximum matching, then
|M 0| ≤ |M | + n/`
.


Theorem Hopkroft-Karp is an O( nm) time algorithm for bipartite
matching.
A bidding based approach to bipartite matching

• We will think of our bipartite graph as having bidders B and goods G.


• Let N (i) nodes incident to node i .
• We will maintain prices pj on the goods.
• If (i, j) is an edge in our matching, we will call i the owner of j .
• We will have a parameter δ < 1 , that we will set.

Auction Algorithms
1. For each j ∈ G , set pj ← 0 , ownerj ← null .
2. Initiliaze a queue Q to have all bidders B .
3. While Q 6= ∅
(a) i ← Q.Dequeue()
(b) j = argminj 0∈N (i)pj 0
(c) if pj ≤ 1
i. Q.enqueue(ownerj )
ii. ownerj ← i
iii. pj + = δ
4. Return the matching as pairs (ownerj , j)
Analysis

Definition Bidder i is δ -happy if either


• i is unmatched and ∀j 0 ∈ N (i) pj 0 ≥ 1
• i is matched to j and ∀j 0 ∈ N (i) pj ≤ pj 0 + δ

Facts:
• If j ∈ G is unmatched, then pj = 0
• Once j ∈ G is matched, it stays matched.

Lemma 1: All bidders are δ -happy

Lemma 2: If all bidders are δ -happy in a matching M , then for any


other matching M 0 , |M | ≥ |M 0| − nδ
More Analysis

Choose: δ = 1/(n + 1)
• Applying Lemma 2, we have that |M | ≥ |M 0| − n/(n + 1) which implies
that M is optimal.
• Running time.
– Each iteration either increases a pj by δ or deletes a node from the
Q permanently.
– Thus O(n/(δ) + n) = O(n2) iterations.
– Each iteration can be implemeted in amortized O((m/n) + log n) time,
for a total of O(nm + log n) time.


Choose: δ = 1/ n

• Applying Lemma 2, we have that |M | ≥ |M 0| − n/ n which implies that
√ √
M is within n of optimal. Therefore we can finish up with n
augmenting paths.

• Running time is O( nm) .
Assignment Problem

Minimum weighted perfect bipartite matching in a complete graph.

min c(v, w)x(v, w)


X

(v,w)∈E
s.t.
x(v, w) = 1 ∀w ∈ V
X

v∈V
x(v, w) = 1 ∀v ∈ V
X

w∈V
x(v, w) ≥ 0 ∀(v, w) ∈ E

Dual:
max π(v)
X

v∈V
s.t.
π(v) + π(w) ≤ c(v, w) ∀(v, w) ∈ E

Dual is a shortest path problem.


Stable Matching

• Given a set of men X and women W .


• Each man ranks the women, and each woman ranks the men.
• Let r(m, w) be the rank assigned from man m to woman w . Define
r(w, m) similarly.
• Given a matching M , a pair (m, w) is unstable if m and w each
prefer each other to their current matched partner.
• A stable matching is a matching with no unstable pairs.
Results on Stable Matching

Theorem For any set of preferences, a stable marriage exists and can be
found in O(n2) time.

Algorithm
• Proceed in Rounds
• In each round, any unmatched man proposes to his highest ranked
woman who has not yet rejected him.
• Woman accept any proposal if it is preferred to their current v matching
(and prefer anyone to being unmatched).
Properties of Algorithm

• Once a woman is matched, she stays matched.


• The partner of a woman only improves over time
• Once a woman rejects a man, she would always reject him in the future.
• A woman always accepts her first proposal.

Conclusion: Every woman is eventually matched.

Claims:
• The matching is stable.
• Each man is matched to the highest ranked woman he could match in
any stable marriage.
• Each woman is matched to the lowest ranked man she could match in
any stable marriage.

You might also like