• No results found

Finding a rank-maximal matching

7.4 Rank-maximal matchings

7.4.1 Finding a rank-maximal matching

For the special case where every house has unitary capacity, i.e. the House Allocation problem with Ties (HAT), Irving et al. [29] give an O(min(z∗√n, n + z∗)m) (direct) combinatorial algorithm for solving the analogous problem, where z∗ ≤ z is the maximal rank of an edge used in a rank-maximal matching. We will show how to extend this algorithm to the CHAT case.

Let G be the underlying graph of I. Let Ei denote the set of edges having rank i for

any i (1 ≤ i ≤ z). Then, the edge set of G may be expressed as E = E1∪ E2∪ ... ∪ Ez.

Our algorithm works in phases. In each phase i (1 ≤ i < z), it constructs a rank-maximal matching Mi+1 of the subgraph Gi+1= (A ∪ H, E1∪ E2∪ ... ∪ Ei∪ Ei+1) so that when it

terminates at the end of phase z − 1, a rank-maximal matching Mz of the subgraph Gz

is a rank-maximal matching for I. Our algorithm begins at the outset by constructing a maximum matching M1 in G1 = (A ∪ H, E1). Note that M1 is a rank-maximal matching

of G1 since it is a maximum matching of E1 edges. For each phase i where i ≥ 1, our

algorithm then constructs a modified subgraph G0i+1 of Gi+1, which reduces the problem

of finding a rank-maximal matching in Gi+1 to the problem of computing a maximum

Algorithm 14 Algorithm Rank-Max

1: Start with G01= G1 and let M1be a maximum matching in G01.

2: for i = 1 to z − 1 do

3: Obtain an EOU labelling of G0i.

4: Delete all edges in G0i connecting two odd vertices, or connecting an odd vertex with an unreachable vertex (this step does not delete any edge of Mi).

5: Delete from Ej, for all j > i, all edges incident to an odd or unreachable vertex in G0i.

6: Build subgraph G0i+1 by adding the edges in Ei+1 to G0i.

7: Find a maximum matching Mi+1 in G0i+1 by augmenting Mi.

8: return Mz as a rank-maximal matching.

those edges from Ei+1 that can potentially belong to a rank-maximal matching of I.

To help us identify those edges that can potentially belong to a rank-maximal matching of I, we make use of the Edmonds-Gallai Decomposition as extended to the capacitated bipartite graph in Chapter 4. Recall that Lemma 4.3.4 shows that fundamental properties of the Edmonds-Gallai Decomposition, as introduced by Lemma 1.2.1 in Section 1.2, also hold in the capacitated bipartite graph case. Hence, we can reuse Lemma 4.3.4 here for each subgraph Gi of G, which is essentially a CHAT instance. A pseudocode description

of the algorithm is given in Algorithm 14.

7.4.2 Proof of correctness

Recall that Algorithm Rank-Max constructs a maximum matching Mi for each subgraph

G0i. In order to show the correctness of our algorithm, we require the following technical results.

Lemma 7.4.1. Suppose that every rank-maximal matching of Gi is a maximum matching

of G0i. Then every rank-maximal matching of Gi+1 is contained in G0i+1.

Lemma 7.4.2. For every phase i and j where j > i, the number of edges of rank at most i is the same in Mi and Mj.

Note that the proofs of the lemmas have been omitted since they may be established by straightforward extension of the corresponding results for HAT (i.e. Lemmas 2.2 and 2.3 of [29] respectively). What Lemmas 7.4.1 and 7.4.2 show are the following:

(i) suppose that the hypothesis of Lemma 7.4.1 is true. Then, any edge deleted during phase i of the algorithm does not belong to any rank-maximal matching of Gi+1 so

(ii) the algorithm maintains the same number of edges of rank i in each matching Mj

for all i < j.

The above results lead us to the following correctness result for our algorithm, for which we again omit the proof since it is a straightforward extension of the corresponding result for HAT (i.e. Theorem 2.4 of [29]).

Theorem 7.4.1. For every 1 ≤ k ≤ z, the following statements hold: (i) Every rank-maximal matching in Gk is a maximum matching in G0k;

(ii) Every maximum matching Mk in G0k is a rank-maximal matching in Gk.

7.4.3 Time complexity analysis

The following theorem gives us the time complexity of our algorithm.

Theorem 7.4.2. Given a CHAT instance I, a rank-maximal matching can be computed in O(min(z∗√C, C + z∗)m) time, where z∗ is the maximal rank of an edge in an optimal solution and C is the total capacity of the houses in I.

Proof. Consider phase i of the algorithm. It is straightforward to see that each subgraph Gi can be constructed in O(m) time. We use Gabow’s algorithm [15] to compute a

maximum matching Mi in Gi in O(

Cm) time. Now, Gabow’s algorithm uses successive augmentation steps to find a maximum matching for each Gi. It must be the case that

the number of augmentation steps cannot exceed |Mi| − |Mi−1| + 1, since each step either

increases the cardinality of the matching by at least 1, or establishes that no further steps are needed. Hence, the time complexity for Gabow’s algorithm is also bounded by O((|Mi| − |Mi−1| + 1)m), giving an overall bound of O(min(

C, |Mi| − |Mi−1| + 1)m).

After finding the maximum matching Mi, it follows that we can obtain an EOU la-

belling by using a similar approach to that described in Section 4.3.2 for CHAT. We first use a pre-processing step to label each unassigned agent and each undersubscribed house as even. Clearly, this step takes O(n) time. Next, restricted breadth-first search may be used on Gi to search for alternating paths with respect to Mi, building up odd or even

labels for every vertex encountered. This step labels all odd and even (assigned) agents, and all odd and even (full) houses and takes O(m) time. Any remaining unlabelled vertices must be unreachable and we can directly label these vertices in Gi in O(n) time. Thus,

the total time complexity of EOU labelling of Gi is O(n + m). The EOU labelling of Gi

is then used to delete certain edges from Ej where j > i which takes O(m) time.

Hence, the time complexity for each phase is O((min(√C, |Mi| − |Mi−1| + 1)m). By

summing, we see that the overall running time is O(min(z√C, C + z)m).

Now, we show how to replace z by z∗. At the beginning of each phase i, we first check if Mi is already a maximum matching in G0 which consists of all edges (of all ranks) that

have not been deleted at the start of phase i. This takes O(m) time. If Mi is a maximum

matching in G0, then we stop. Otherwise, we continue as described above. This ensures that only z∗ phases are executed.