### The Matching (match making) problem (in bi-partite graphs)

• The match making problem:

• The match making problem:

 We have 2 sets of items (e.g., jobs and workers) We must find a match up that satisfies a given condition

• Example 1: assigning tasks to skilled workers

• 4 tasks are being assigned to 4 workers:

 Worker 1 is qualified to perform tasks A and B Worker 2 is qualified to perform tasks A, B, C and D Worker 3 is qualified to perform tasks A and B Worker 4 is qualified to perform task B

• Graphical representation:

• Question:

 Can all 4 workers be assigned to different tasks for which they are qualified ???

• Example 2: the marriage problem

• 4 men are getting married to 4 women:

 Man 1 knows women A and B Man 2 knows women A, B, C and D Man 3 knows women A and B Man 4 knows woman B

• Graphical representation:

• Question:

 Can all 4 men be married to different women for which they know the woman that he marries ???

• Bi-partite graphs and matching

• Definition: Bi-partite graph

• Bi-partite graph = a graph where the vertex set can be divide into 2 disjoint sets X and Y such that:

 For every edge e = (a, b):          a ∈ X b ∈ Y

• Example:

Notice that every edge starts in a node of one set and ends in a node of the other set

• Definition: Matching

• Matching = a pairing of some elements from set X to set Y where:

 Two different elements from set X are paired with different elements in set Y

Example:

• These are not matchings

Explanation:

 In the first example, the same element 1 ∈ X is paired with 2

• Necessary and sufficient condition: The "Marriage" Theorem

• Marriage Theorem:

• Given:

 n men x women     (note: x ≥ n)

• There is a matching of n men (to n women) if and only if:

 For every subset of m men (m ≤ n), these m men know at least m women

• Proof of the then part

• We will first prove that:

• There is a matching of n men (to n women) then:

 For every subset of m men (m ≤ n), the m men know ≥ m women

We will show this claim by showing that the contraposition statement is true.

I.e., we show that:

 If there is a subset of m men (m ≤ n), and these m men know < m women, then there is no matching of n men (to n women)

• Consider a subset A of m men (mn), and these m men know < m women (subset B):

Fact:

 Only women ∈ B can be used to pair with a man ∈ A Only one women ∈ B can be used to pair with one man ∈ A

• Since |B| < |A|, we conclude:

 At least one man ∈ A will not be able to be paired with any woman ∈ B.

Hence: there is no matching possible.

• Proof of the "if" part:

• We will next prove that:

• There is a matching of n men (to n women) if:

 For every subset of m men (m ≤ n), the m men know at least m women

Re-written:

• If every subset of m men (mn), these m men know at least m women, then:

 There is a matching of n men (to n women)

We show this by construction (it's actually an induction proof)

• Base case of the induction proof:

 We can find a matching for 1 (m = 1) man

Proof:

 Since every subset of 1 men the 1 men knows at least 1 women, we just match that man with any one of the woman that he knows....

• Suppose that we have found a matching for m men and m < n:

We will prove that:

 There is a matching for m+1 men

• Since m < n, there is at least one man (p) that is unmatched:

There are 2 possibilities:

1. p knows some qB

In this case, it is trivial to prove that there is a matching for m+1 men:

2. p only knows women qB

The reason that p cannot find a match is:

 The women that p can be matched with are all taken by men in the set A         (Because otherwise, p would find someone outside B to match with !!!)

We will now show how to construct a match for this difficulyt case.

• We construct a m+1 matching using:

 p and All the elements in the set A

as follows:

• Start with man p

• Given: for every subset of m = 1 man the 1 man (p) know at least 1 woman

Do this:

 Match p up with someone he knows.

• Note: we know that she is some element ∈ B

• Now, 2 men (p and q) that are matched up with the same woman:

Because we have:

 For every subset of m = 2 men the 2 men know at least 2 woman

There are 2 possibilities:

Case 1: the second woman B Case 2 the second woman B

• In the first case (when the other woman ∉ B) we have found a m+1 matching:

• In the second case we repeat the argument using 3 elements:

Because we are given that:

 For every subset of m = 3 men the 3 men know at least 3 woman

There are again 2 possibilities:

Case 1: the second woman B Case 2: the second woman B

• And so on...

• Eventually, we will reach m+1

Then we will have found a m+1 matching

I.e.,: m+1 men can be matched with a different woman that they know

• Therefore, we have shown that:

 If there is a matching of m men and m < n, we can always find a larger matching of m+1 men

Therefore:

 There is a matching of n men