35 Marriage Broker 347
follows the chain of requests backwards toward the man H and exchanges
the previous partnerships along exactly this way.
(ii) One finds out that the wave of requests reaches only women who already
have partners. In this case one deletes the man H from the set of men.
Subsequently one can adopt this picture of a wave of requests, spreading
from H toward all persons, alternately going through a friendly relationship
and an already taken assignment. Once a new partnership is discovered, this
wave breaks abruptly, and the couples are rearranged on the path of requests
from this new partnership to H.
Hint: This wave can be processed simultaneously or in any sequence, but
the most vivid picture is the parallel uniformly spreading wave (in Computer
Science we talk about breadth-first search regarding L). Here no person is
asked who has already been questioned once, so that the wave only expands
to persons who have not yet been considered.
35.3 The Construction of a Maximum Matching
One starts with any pair from the set L. Let this pair be HD and put M =
{HD}. (If the set L is empty, there are, of course, no couples to form and
there is nothing to do.) Note that in the set M below each person appears
not more than once.
Now we can assume that a set of couples M = {H
1
D
1
,H
2
D
2
,...,H
r
D
r
}
has been constructed. If all men occur in M one is finished, because bigamy is
illegal. The interesting situation is when a man H is without a female partner,
thus he does not occur in M. How can we assign to him a female partner D?
(a) Obviously one has to ask every person D about person H who has
sympathies for D (i.e., HD is included in the set L), whether she still has
no partner. If there exists such a person D without a partner, then one just
adds HD to the set M and applies the algorithm again to another partnerless
person. We have performed this by starting from the pair BP by adding pairs
CR and ES in Fig. 35.3.ThesetM = {BP,CR,ES} is given by the red
edges. Case (a) is not true any more and we cannot enlarge M in this way,
although there are still partnerless persons left.
(b) What has to be done if there is no partnerless person D matching
the partnerless person H in L? Then there is a partner H
assigned to each
person D, who is found friendly by H. Now one tries to take away woman D
from man H
in favor of man H, which means one tries to replace H
D by
HD, consequently H
becomes partnerless.
Now one tries to take away the partner H
from one of the women D
(but not the woman D), who is friendly to H
,makingH
partnerless and
requiring another partner, etc. Only such women D
, D
, D
, etc., are being
considered who have not yet been included. Based on H a sequence of alter-
nating friendship relations HD and already allocated H
D relations from the