• No results found

3.4

Correctness

Let us establish a few key properties of the algorithm, and verify certain claims made in the de- scription of the pseudocode.

Lemma 3.4.1 LetS denote the set of stalled men at the start of an arbitrary execution of phase 2 of the approximation algorithm. If the matching N′ constructed in this call is empty, then the corresponding maximum cardinality matchingN matches every man in S.

Proof SupposeN′is empty, and that a manm is unmatched by N . Let w be an arbitrary neighbour

ofm in G. Since m is not matched in N , m is even (i.e. m∈ E), and therefore w is odd (w ∈ O).

SinceN is maximal, w was matched to a man m′ inN , who therefore must also be even. But this

implies the pair(m′, w) could not have been removed from N , as it consists of an even man and an

odd woman. 2

Corollary 3.4.1 Phase 3 of the approximation algorithm finds a matching that matches every man

who was inS in the preceding execution of phase 2.

Proof By Lemma 3.4.1, when control of the algorithm reaches phase 3, every man inS is matched,

for control is passed to this point only ifN′is empty. 2

Lemma 3.4.2 establishes the key properties of the matchingsN and N′ constructed in phase 2 of

the approximation algorithm.

Lemma 3.4.2 Letm be a stalled man in the set S with current tie t at the start of an arbitrary execution of phase 2. Then, exactly one of the following is true ofm when that execution of phase 2 ends (i.e., the instant before either invoke statement in phase 2 is executed).

1. m was matched in N, som is now matched in M to a woman in t, and every woman in t is

matched inM .

2. m was matched in N but not in N,m’s current tie is still t, and there are at least two women int who are still unmatched in M .

3.4 Correctness 44

3. m was unmatched in N , m’s current tie is still t, and every woman in his current tie is now matched inM .

Proof (1) Supposem was matched in N′. Then,m was an even or unreachable vertex with respect

toM . Therefore, all neighbours of m in G are either odd or unreachable, and could not have been

deleted fromN , for only even women are removed from N . It follows that all of m’s neighbours

are inN′, and therefore they all receive proposals in this execution of phase 2, and are matched in

M .

(2) If insteadm is matched to a woman w in N but is unmatched in N′, thenm was removed from N because he is an odd vertex. We establish the claim by showing there is another even woman w′ 6= w who is adjacent to m and is unmatched in Nas well. To see this, consider the path of odd

length that makesm an odd vertex. This path cannot reach him via his partner in the matching, for

alternate edges in that path would have to be edges in the matching. Hence the first edge in the path would be in the matching (since the last edge is), contradicting the fact that the starting vertex in the path must be unmatched. Therefore this path must reach him from another neighbouring vertex

w′, which must be even. This woman is unmatched inN′, for she can only be matched to an odd man inN or unmatched in N .

(3) Finally, ifm is unmatched by N he is an even vertex. All women in his current tie are therefore

odd vertices, are matched inN because N is maximal, and could not have been removed from N .

Therefore, these women are all matched inN′ and all receive proposals in this execution of phase

2, and hence are matched inM .

Having considered every possibility of the outcome ofm’s participation in phase 2, the lemma is

established. 2

Lemma 3.4.3 On termination of the approximation algorithm, any man who remains unmatched

has been promoted, and has been rejected by every woman on his list even after becoming promoted.

Proof The execution of the algorithm can only halt in one of two places. The first place is at the

end of phase 1, on the condition that there are no stalled men. This implies that every unmatched man is promoted and has still been rejected by every woman on his list. The other point at which

3.4 Correctness 45 the algorithm may terminate is in phase 3. Now, control reaches phase 3 only if, in phase 2, it is discovered thatN′ is empty, implying thatN matches every man in S by Corollary 3.4.1. Notice

that when this happens nothing is done in phase 2 to modify the assignment of any agent, rather phase 2 simply passes control to phase 3, which matches every man inS. Hence, the unmatched

men are those who were unmatched after the final call to phase 1, and, as described above, they must have become exhausted while promoted. 2

Lemmas 3.4.4 and 3.4.5 establish the stability of the matching output by the approximation algo- rithm.

Lemma 3.4.4 Suppose a womanw becomes matched to a man m at some point in the execution of the approximation algorithm. Thenw only rejects m if she accepts a proposal from a man ranked at least as highly asm on w’s (original) preference list.

Proof Matched women can only change their partner in one place in the approximation algorithm,

and that is when receiving a proposal in phase 1 from a man they strictly prefer, possibly after promotions, to their current partner. This new suitor must be ranked at least as highly asw’s current

partner onw’s original preference list. 2

Lemma 3.4.5 The matching M returned at the end of the approximation algorithm is a stable matching.

Proof Suppose that(m, w) blocks M . The essence of the approximation algorithm from a man’s

point of view is a left-to-right sweep of his preference list in which, if necessary, he becomes promoted and again makes another left-to-right sweep of his preference list. Hence, form to prefer w, he must have proposed to her at least once, whether it be in phase 1 or phase 2 (he cannot have

proposed to her in phase 3, for otherwise they would be matched inM ). The fact that w has rejected m along with Lemma 3.4.4 implies that w does not prefer m to her current partner in M , and hence (m, w) does not block M . 2

Lemma 3.4.6 The approximation algorithm runs in O(n3/2m) time, where n is the sum of the numbers of the men and women andm is the sum of the lengths of the preference lists.