1 Introduction
Matching is a fundamental problem in computer science with numerous applications. The housing allocation problem [10, 22, 1] is an instance of matching problem with onesided preferences. In this problem, we need to allocate a set of houses among a set of agents and monetary compensations are not allowed. Each agent ranks in order of preference a subset of (the acceptable houses for ). The variant in which there is an initial endowment of houses to agents is known as the housing market problem [19, 18, 17]. For both the housing market and the housing allocation problem, we need to construct a matching of agents to houses such that it is optimal with respect to some criterion. One criterion usually considered is Pareto Optimality [1, 3, 19]. A matching is Pareto optimal if there is no other matching such that no agent strictly prefer to , and at least one agent strictly prefer to . For example, a matching is not Pareto optimal if a group of agents could improve by exchanging the houses that they are assigned to in .
Possible applications of the housing allocation problem and the housing market problem include: assigning virtual machines to servers in cloud computers, allocating graduates to trainee positions, professors to offices, and students to roommates. Yuan [21] also describes a largescale application of housing allocation in the allocation of families to governmentsubsidized housing in China. Also, the paper [13] describes applications of algorithms for the stable marriage problem for mapping clients to server clusters in a content delivery network in Akamai. When only one side preference is considered, housing allocation algorithms can be applied.
For the housing allocation problem, there is a simple greedy algorithm, known as the serial dictatorship mechanism [1] to compute a Pareto optimal matching. The serial dictatorship mechanism works as follows. Arbitrate a total ordering on all the agents. Let all agents pick their top choice of the remaining houses one by one following the total order. This algorithm is sequential and takes computation steps. Also, it does not necessarily give a maximum cardinality Pareto optimal matching. The paper [3] studies the problem of finding a maximum cardinality Pareto optimal matching for the housing allocation problem in the sequential setting. Their algorithm first computes a maximum cardinality matching of the bipartite graph formed by agents and houses and then improves the matching to be Pareto optimal. Their algorithm runs in sequential time, where is the number of agents plus the number of houses, and is the number of edges of the agenthouse bipartite graph. They also show that any improvement to the complexity of their algorithm would imply an improved algorithm for finding a maximum matching in a bipartite graph.
For the housing market problem, Shapley and Scarf [19] prove that there exists at least one matching in the core of any housing market and present the wellknown top trading cycle (TTC) mechanism, which they attribute to David Gale. This mechanism works by repeatedly finding the top preference cycles and exchanging houses along those cycles. It takes sequential steps. Ma [12] shows that the TTC mechanism is the only individually rational, Paretoefficient, and strategyproof mechanism. Roth and Postlewaite [18] show that there is exactly one core for each housing market instance. Note that the matching obtained by the TTC mechanism is not only a Pareto optimal maching, but also the unique core.
The parallel complexity of both these problems has not been studied in the literature. The housing allocation problem is a variant of the stable marriage problem with only one sided preferences. The decision version of the stable marriage problem, i.e, given a pair of man and woman, to decide whether they are matched in the manoptimal stable matching, is CCcomplete [14]. The CC class [14] is the set of problems logspace reducible to the comparator circuit value problem. Currently, there are no efficient parallel algorithms for this class of problems. It is conjectured that CC is incomparable with NC [6, 14], the class of problems computable in polylog parallel time. In this work, we show that finding the core of a housing market is CChard, which can be taken as evidence that this problem is not parallelizable. Although finding the core is hard, we show that given a matching, it can be verified in NC whether it is the core. On the other hand, finding a Pareto optimal matching is easier than finding the core. We show that finding a maximum cardinality Pareto optimal matching can be done in RNC^{2} and quasiNC^{2}, where RNC^{2} represents the problems which have uniform circuits of polynomial size and depth and quasiNC^{2} represents the problems which have uniform circuits of quasipolynomial size , and depth.
In this paper, we also study the housing market problem in the distributed setting. Specifically, we give a symmetric distributed algorithm for the TTC mechanism. By symmetric, we mean that each agent performs the same role.
In summary, this paper makes the following contributions:

We prove that computing the core of a housing market is CChard, by giving a logspace reduction from the lexicographically first maximal matching problem, which is a CCcomplete problem, to the housing market problem.

We show that computing a maximum cadinality Pareto optimal matching for the housing allocation problem is in RNC^{2} and quasiNC^{2}.

We give a symmetric distributed TTC algorithm for computing the core of a housing market, which runs in rounds and require messages.
The paper is organized as follows. Section 2 gives preliminaries for the housing allocation and the housing market problem. Section 3 studies the parallel complexity of the housing market problem. Section 4 presents a parallel algorithm for computing a maximum cardinality Pareto optimal matching for the housing allocation. Section 5 presents a distributed algorithm for computing the core of a housing market. Finally, section 6 present the conclusions and future work.
2 Preliminaries
The housing allocation problem deals with assigning indivisible houses
to agents who have preferences over these houses. In general, a housing allocation instance consists of
(1) a set of agents ,
(2) a set of indivisible houses },
(3) a preference profile , where defines a strict preference of
agent on a subset of houses.
We restrict our attention to strict preference profiles where each agent defines a strict total order over a subset of houses. Let denote the subset of acceptable houses for agent . The goal of the housing allocation problem is to find a Pareto optimal matching of agents to houses. For a matching and an agent , let denotes the house matched to agent . We use to denote that agent prefers house to house . For two matchings and , denotes that agent prefer to .
The definitions of Pareto Domination and Pareto Optimality [19] are given as below.
(Pareto Domination). Suppose are matchings. Then Pareto dominates if and only if
(1) for all ,
(2) for some .
We use to denote that matching Pareto dominates matching .
(Pareto Optimality). Suppose is a matching. Then is Pareto optimal if and only if it is not Pareto dominated by any other matching .
The housing market problem is a variant of the housing allocation problem, where there is an initial endowment of houses to agents and we have the same number of agents and houses. Let be a matching denoting the initial endowment of houses to agents. Let denote an instance of a housing market. In the housing market problem, in addition to Pareto optimality, we also want a matching to be individually rational [2] defined as follows.
(Individually Rational). Suppose is a matching of agents to houses in a housing market. Then is individually rational if for all .
Individual rationality means an agent is willing to give up its initially assigned house only when it can get a better house. To define the core of a housing market, let us first define the concept of coalition. Informally, given a matching , a coalition w.r.t is a set of agents such that, by only switching houses within themselves, each agent in can get a house at least as good as its house in and at least one agent gets a strictly better house.
(Coalition). Given a housing market and a matching , a set of agents form a coalition w.r.t if there exists a matching such that
(1)
(2)
(3) Condition (1) says that to get matching from , the agents in only switch houses within themselves. Condition (2) means that in matching each agent in is matched to a house at least as good as the house it gets matched to in . Condition (3) means that at least one agent is matched to a better house in matching . The core [19] of a housing market is defined as follows.
(Housing Market Core). The core of a housing market problem is a set of matchings such that matching if and only if there does not exist any coalition w.r.t .
Essentially, a matching is in the core of a housing market if there does not exist a set of agents such that they can match to better houses by breaking away from other agents and exchanging houses within themselves. An individually rational and Pareto optimal matching is not necessarily a core matching, whereas a core matching must be individually rational and Pareto optimal. An example to illustrate the difference between a core matching and an individually rational Pareto optimal matching is given in Fig. 1.
It is easy to see that both and are individually rational and Pareto optimal matchings. is the core matching but is not. In , agents and can form a coalition within themselves and swap houses. Suppose and break away from other agents and switch houses with each other. Then, gets house , which is the same as the house it gets in , and gets house , which is strictly better than the house it gets in . Thus, is not the core. On the other hand, in , there does not exist two agents such that at least one will be strictly better off by forming a coalition and swapping houses among themselves.
The following result is wellknown. [[18]] There is exactly one unique matching in the core of a housing market instance.
Since the core of a housing market has one unique matching, we use the core to mean this unique matching henceforth. The TTC algorithm given by Shapley and Scarf [19] computes the unique core of a housing market. This algorithm works in stages. At each stage, it has the following steps:
Step 1. Construct the top choice directed graph on the set of agents as follows. Add an arc from agent to agent if holds the current top house of .
Step 2. Since each node has exactly one outgoing edge in , there must be at least one cycle, which could be a selfloop. All cycles are node disjoint. Find all the cycles in the top trading graph and implement the trade indicated by the cycles, i.e, each agent which is in any cycle gets its current top house.
Step 3. Remove all agents which get their current top houses and remove all houses which are assigned to some agent from the preference list of remaining agents.
The above steps are repeated until each agent is assigned a house. At each stage, at least one agent is assigned a final house. Thus, this algorithm takes stages in the worse case and needs computational steps.
3 Parallel Algorithms for Housing allocation and Housing Market
In this section, we study the parallel complexity of the housing allocation and housing market problem. The parallel computation model we use here is the CREW PRAM model [11]. First, we show that computing a Pareto optimal matching in a housing allocation is CC by reducing this problem to the lexicographically first maximal matching problem (LFMM), which is a CCcomplete problem [14]. In the LFMM problem, we are given a graph where denotes a total ordering on the edges. If , we say that precedes . The total order allows us to regard a matching as a sequence of edges in ascending order, i.e, . Given two matchings and , we say if lexicographically precedes . The relation defines a total order over all maximal matchings. The minimum element, , of this order is call the lexfirst maximal matching of . We need to decide whether a given edge is in the lexfirst maximal matching of the graph. Then, we show that computing the unique core of a housing market is CChard, by giving a logspace reduction from the LFMM problem to the housing market problem. We say a problem is CChard if every problem in CC reduces to it.
Computing a Pareto optimal matching for a housing allocation is in CC.
Proof.
We reduce the problem of computing a Pareto optimal matching to the LFMM problem. Given a housing allocation instance , we construct an agenthouse bipartite graph where denotes a total ordering of edges. There is an edge from an agent to a house if is acceptable to . For each agent , let denote its rank function, i.e, denote the rank of house at agent ’s preference list. We assign an arbitrary unique ordering to all the agents, i.e, a onetoone function , where . For each edge , we associate the tuple with it. We define the total order on edges as the lexicographical ordering of the tuples associated with them. Clearly, defines a total ordering on all edges. We claim that the lexfirst maximal matching of this graph corresponds to a Pareto optimal matching. Suppose not, then there exists another maximal matching which dominates . There must exist an agent such that prefers to . We have that , which means that , contradicting the fact that is the lexfirst maximal matching. ∎
There is a time parallel algorithm which uses processors to compute a Pareto optimal matching, where is is the number of acceptable agenthouse pairs.
Proof.
Follows from the fact that there is a time parallel algorithm for the LFMM problem [14]. ∎
There is a round distributed algorithm in the congest clique model for computing a Pareto optimal matching, where is is the number of agents and houses.
Proof.
The paper [4] gives a distributed algorithm for the weighted stable marriage problem. The LFMM problem is simply a subcase of the weighted stable marriage problem. Thus, the same algorithm can be applied here. ∎
In the housing market problem, an individual rational and Pareto optimal matching must be a perfect matching of houses to agents. Thus, the reduction given in Theorem 3 cannot be applied. Instead, the problem of computing a individual rational and Pareto optimal matching can be reduced to the problem of lexfirst perfect matching. Unfortunately, the complexity of this problem is unknown.
In a housing market , the weighted agenthouse bipartite graph is defined as follows. There is an edge between agent and house if either or prefers to . The weight of the edge is defined as the the rank of in ’s preference list. To compute an individual rational and Pareto optimal matching for a housing market, we first observe the following lemma from [7].
[[7]] A minimum weight perfect matching of the weighted agenthouse bipartite graph is an individual rational and Pareto optimal matching.
Proof.
Let be a minimum perfecting matching of the agenthouse bipartite graph. Suppose is not Pareto optimal. Then there must be another perfect matching such that Pareto dominates . By the definition of Pareto domination, we can easily argue that has smaller weight than , contradiction. ∎
Combining with the results from [9] and [16], we have the following result. [[7, 9, 16]] There is a RNC^{2} algorithm and a quasiNC^{2} algorithm for computing a individually rational and Pareto optimal matching of a housing market, which require and parallel processors, respectively.
Proof.
Now we show that computing the core of a housing market is CChard. Computing the core of a housing market is CChard.
Proof.
We reduce the LFMM problem to the housing market problem. Let be an instance of a LFMM problem, where represents the total ordering on the edges. Let denote the lexfirst maximal matching of . We construct an instance for the housing market problem as follows. For each node , we create an agent and a house . So, we have . Each agent is initially assigned house . The preference list for each agent is constructed based on the total ordering of edges in . Note that to compute the core of a housing market, the preference list of an agent below its initial assigned house is irrelevant, since the core must be individually rational. So for each agent, we only need to specify the part of the preference list above its initial assigned house. For each pair of agents and , if edge exists in graph , then agent prefers the house of agent to its own house . Otherwise, agent prefers its own house to . In other words, for each edge , agent prefers house of agent to its own house . The preference list of an agent is defined based on the order of edges incident to vertex , i.e, agent prefers the house of agent to the house of agent if . Since all edges are totally ordered, the preference list for each agent is strict. Fig. 2 shows an example of reduction above. Clearly, the above reduction can be done in logarithmic space.
We claim that an edge is in if and only if agent and switch houses with each other in the core of the housing market instance. We say that an edge is minimum in its neighborhood if it is smaller than all its neighboring edges. Recall that the greedy algorithm for LFMM works as follows. Add each edge which is minimum in its neighborhood in the current graph into and remove all incident edges of the two endpoints of each such edge. Repeat the above procedure until the graph is empty. Since the greedy algorithm computes the unique lexfirst maximal matching of a LFMM instance and the TTC algorithm computes the unique core of a housing market, it suffices to show that the TTC algorithm on the housing market instance simulates the greedy algorithm on .
Let denote the reduced graph at the beginning of stage of the greedy algorithm. . Let denote the set of edges in added into by the greedy algorithm at stage , i.e, the set of edges which are minimum in their neighborhoods in . Let denote the set of edges in at the end of stage . Let denote the top choice graph formed by remaining agents at stage of the TTC algorithm. We now show by induction on stages that an edge is added into at stage of the greedy algorithm iff the corresponding agents and switches houses at stage of the TTC algorithm.
Base case: stage 0. Consider an edge . In the housing market, two agents and correspond to this edge. Since is the minimum in its neighborhood, agent and agent are the top choice of each other. Thus, they form a top trading cycle of length 2 in and switch houses with each other in the TTC algorithm. Therefore, all edges in correspond to the top trading cycles in .
Induction case: assume the claim holds for stage . Consider stage of both algorithms. At the end of stage , in the greedy algorithm, all edges incident to edges in are removed from the graph. In the TTC algorithm, all houses involved in the top trading cycles are removed from the preference list of remaining agents. We claim for each edge , the two corresponding agents and in the housing market form a top trading cycle of length 2 in . Suppose not. Let be an edge such that agent and agent do not form a top trading cycle in . We must have that either house is not the top choice of agent or house is not the top choice of agent or both. Without loss of generality, assume house is not the top choice of agent . We have two cases.
Case 1: house is not available for agent . Then, agent participates in a certain top trading cycle before stage . By induction assumption, this means that there exists one edge incident to vertex which is added into at a stage before , contradicting the fact that edge exists in .
Case 2: house is available for agent but is not the current top choice for . Then, there exists another agent such that agent prefers the house of to the house of agent . The existence of agent indicates that it is not involved in any top trading cycle before stage . By induction assumption, there does not exist any edge in which is incident to vertex . Thus, we have . The fact that agent prefers the house of agent to the house of indicates that which contradicts the fact that is minimum in its neighborhood.
∎
Even though we do not know any NC algorithm for either computing an individual rational and Pareto optimal matching or computing the core of a housing market, given a matching, we can verify whether it is an individual rational and Pareto optimal matching and whether it is the core in NC. Given a matching of houses to agents in a housing market , the following two tasks can be performed in NC.
1) Verifying whether is individual rational and Pareto optimal. 2) Verifying whether is the unique core.
Proof.
1). Given a matching , to check whether it is individual rational, we just need to check whether we have for each agent . Observe that if is individually rational, it must be a perfect matching. Then, to verify whether it is Pareto optimal, we construct a directed graph as follows. There is an arc from agent to if agent prefers to . We claim that is Pareto optimal iff is cyclefree.
(). Suppose is not cyclefree. Then there exists a directed cycle in . Since each arc in represents the fact that agent prefers the house of agent in matching . Switching houses following the cycle gives better houses for all agents in the cycle, which gives a new matching and , contradiction to the fact that is Pareto optimal.
(). Suppose that is not Pareto optimal. Then there exists another matching such that . The difference between and is a set of disjoint cycles. Since each agent in is matched to a house at least as good in , each such cycle must be a directed cycle in .
Checking whether is cyclefree can be done in NC by first computing the transitive closure of and for each vertex , checking whether there exists a vertex such that and . Thus, verifying whether a given matching is individual rational and Pareto optimal can be done in NC.
2). Given a matching , to verify whether it is the core, we construct a different directed graph as follows. represents the set of agents. There are two types of arcs: solid arcs and dashed arcs. There is a solid arc from agent to agent if , i.e, agent is assigned the house owned by agent . Hence, the solid arcs represent how agents switch houses to get matching from the initial matching . Thus, all solid arcs form a set of disjoint directed cycles. There is a dashed arc from agent to agent if .
We claim that is the core iff there is no directed cycle which contains dashed arcs in . We show that any directed cycle with at least one dashed arc represents a coalition, w.r.t . Let be such a cycle in . If we switch houses following the cycle , i.e, for each arc in , agent matches to house . For each solid arc , we have by the definition of solid arc. Thus, each agent with a solid outgoing arc matches to the same house as in . For each dashed arc , we have , thus each agent with a dashed outgoing arc matches to a house strictly better than its house in . Thus, each directed cycle with at least one dashed edge represents a coalition of agents, w.r.t . Since a matching is in the core iff there is no coalition with respect to and each directed cycle with dashed arcs represent a coalition, we get our desired claim.
To check whether there exists a directed cycle with at least one dashed arc in , we first compute the transitive closure of . For each dashed arc , check in parallel whether . Thus verifying whether a matching is the core can be done in NC. ∎
3.1 A Parallel Algorithm for Maximum Pareto Optimal Matching
In the housing allocation problem, a Pareto optimal matching does not necessarily have maximum cardinality, i.e, with maximum number of agents matched to a house. To find a maximum cardinality Pareto optimal matching, we adapt the sequential algorithm in [3] to be a parallel algorithm. The sequential algorithm in [3] has three steps. To ensure that the final matching has maximum cardinality, step 1 computes a maximum cardinality matching. After step 1, all unmatched agents are removed from consideration. At step 2, the algorithm improves the matching obtained from step 1 to be tradeinfree. A matching is tradeinfree if there is no (agent,house) pair such that is matched in , is unmatched in , and prefers to . That is, step 2 ensures that no matched agents prefers an unmatched house to its current matched house. After step 2, all unmatched houses are removed from consideration, since no matched agents prefer any of those houses to their matched houses. The final step is to improve the matching obtained from step 2 to be Pareto optimal, which is achieved by directly applying the TTC mechanism on all matched agents.
Our parallel algorithm, shown in Fig. 4 has only two steps. At step 1, we compute the maximum cardinality matching, which can be reduced to compute a minimum weight perfect matching of a new graph. Let be the maximum cardinality matching obtained at step 1. Let be the set of matched agents. After step 1, all the unmatched agents are removed from consideration. At step 2, we improve the matching obtained from step 1 to be Pareto optimal. In contrast to [3], we do not first make our matching tradeinfree and then Coalitionfree. Instead, we directly compute a Pareto optimal matching by computing a minimum weight perfect matching of a graph constructed as follows. We create a set of virtual agents to ensure the number of agents is equal to the number of houses. Add an edge with weight 0 between each virtual agent and each house. For each real agent and each house , add an edge between and if is ’s partner at the end of step 1 or prefers to its partner. The weight of edge is equal to the rank of in ’s preference list.
Let be the graph constructed at Step 2. The following lemma shows the correctness of algorithm 5. The matching output by algorithm 5 is a maximum cardinality Pareto optimal matching for a housing allocation.
Proof.
Let be the minimum weight perfect matching of . Let be the matching output by algorithm 5, which is the induced submatching of on the set of matched agents after step 1. Step 1 ensures that is a maximum cardinality matching. It remains to show that is Pareto optimal. Suppose for contradiction that is not Pareto optimal. Then there exists some other matching on real agents such that . By definition of Pareto optimality, each agent in should be matched to a house at least as good as the house in and at least one agent is matched to a strictly better house in . Since is a maximum cardinality matching, must also be a maximum cardinality matching which matches the same set of agents as . Since the weight of an edge is defined as the rank of at ’s preference list, we have . Since each virtual agent has incident edges of weight 0 in , there exists another perfect matching formed by edges in and some edges incident to virtual agents such that the total weight is smaller than , contradicting the fact that is the minimum perfect matching of . ∎
Now, we can state our main result for the housing allocation problem. There is a RNC^{2} and quasiNC^{2} algorithm for finding a maximum cardinality Pareto optimal matching for the housing allocation problem.
4 Distributed Algorithms for Housing markets
In this section, we present a symmetric distributed algorithm to implement the TTC mechanism in a distributed setting. We assume a distributed message passing model with processes, , which form a completely connected topology. The system is synchronous, which means that there is an upper bound on the time for a message to reach its destination. We require that at each round, a node can only send a same message of size to any other node in the network. Since the graph is fully connected, this model is also known as the congest clique model in the literature. Actually, our proposed distributed algorithm fits in a more restricted model called the broadcast congest clique model [8], since at round each node only sends the same message to all other nodes in the network. This model is in contrast to the unicast congest clique model [8] which allows each node to send different messages to different nodes in each round.
To implement the top trading cycle algorithm in a fully distributed way, we need efficient distributed algorithms for finding the top trading cycle. Observe that the graph formed by the top choice of each agent is a functional graph since each node has only one outgoing edge. Hence there is only one unique cycle in each connected component of this graph. We present two distributed algorithms for finding all the top trading cycles in a functional graph.
4.1 A Las Vegas Algorithm for Finding Cycles in Functional Graphs
In this section, we give a Las Vegas algorithm, shown in Fig. 5, for finding all the disjoint cycles in a functional graph. The primary gradient of the algorithm is a pointer jumping technique. A similar technique is used in [15, 20] to solve the list ranking problem.
In this algorithm, each node has a variable active, which is initially true. A node terminates the code when active becomes false. Each node uses the variable to record its current successor node, which initially is its outgoing neighbor. Our algorithm will build a tree. The variable denotes the current children of a node, which is essentially all the nodes that have been its successor. The variable denotes whether a node is in the cycle or not. The algorithm is composed of iterations and each node keeps executing an iteration until active becomes false. Each iteration includes two steps: a Coinflip step and a Explore step. In the Coinflip step, each active node flips a coin. If a node flips head and its successor node flips tail, it becomes inactive. This step is used to reduce the active nodes by a constant fraction. In the Explore step, each active node traverses along the path formed by the successor pointer of all nodes and tries to update its successor pointer to be next active node in the path. It also adds all inactive node encountered into its children set. When such a active node is found, it checks whether such a node is actually itself, if that is the case, a cycle is detected. After a node determines that it is in the cycle (we will show that there is a unique such node), it broadcasts a cycle message along the tree formed by the child relationship (Notify step). We will prove that the set of nodes in the tree rooted at such a node and formed by the child relation is exactly the set of cycle nodes. For the purpose of analysis, we assume the functional graph we consider only has one component, which also means it only has one cycle. Our algorithm works for functional graph with multiple components, since the executions on different components are independent.
We now show that at the end of algorithm 1 each node correctly knows whether it is in the cycle or not. Let denote the value of for . First, we can easily get the following lemma from the code.
At the end of algorithm 1, there is exactly one node which has for each disjoint cycle in the functional graph.
Proof.
For node , if at some point, then there exists a directed path from node to node . Let us consider a single connected component of the functional graph. For any noncycle node, its cannot be itself since it does have a directed path to itself. Hence, it is sufficient to consider only cycle nodes. We first show there is at least one node with . We claim that there is at least one active cycle node remaining after the Coinflip step of each iteration. To become inactive, a node has to flip head and its successor has to flip tail. This implies that two consecutive active nodes cannot become inactive simultaneously. Hence, at the end of the algorithm at least one cycle node with . Also, it is obvious that at most one cycle node can have at the end of the algorithm. Therefore, there is exactly one node which has for each disjoint cycle in the functional graph. ∎
Let be the node with at the end of the algorithm. Let be the tree rooted at node and constructed from the child relation at the end of the algorithm. Let denote the set of nodes in tree . Let denote the set of nodes in the cycle.
Proof.
We prove and . Suppose node runs for iterations. Let denote the set of active cycle nodes at round , . To prove , we show by induction that each node in is in tree for all .
Base case, . . Node is the root of .
Induction case: Suppose each node in is in . We need to show that each node in is in . It is sufficient to show that the nodes in which become inactive at round are in . Since all active cycle nodes at each round still form a cycle, divides into multiple directed paths. For any path of form , only the two end nodes and are in . From the code we know that node continues to find active nodes along at round , and it stops until it reaches node . Thus, all nodes in path between and become the children of node . So, all nodes in path are in . Hence, all nodes in are in . Therefore, we have is in for any . Since is exactly the set of cycles nodes, we have all cycles nodes are in . Thus, .
To prove , we show that the any non cycle node is not in tree . For any non cycle node , suppose . Then must be a descendant of root node . From the algorithm we know that the children relation is formed by next relation in the original graph. Thus, there must be a directed path from node to node in the original graph. This means must be in the unique cycle, a contradiction. ∎
Algorithm 1 computes all the cycles of a functional graph . It has round complexity of and message complexity of , w.h.p, where is the length of the longest cycle in .
Proof.
Since the message only traverses through tree , from Lemma 4.1, we know that each cycle node receives the message and each non cycle node does not receive the message.
Since the number of active nodes in any cycle reduces by a constant fraction in expectation at each iteration and each iteration takes constant number of rounds, by Chernoff bound, algorithm 1 takes rounds w.h.p. Each round of the algorithm takes at most messages, which results in messages in total. ∎
4.2 A Deterministic Algorithm for Finding Cycles in Functional Graphs
In this section, we present a deterministic algorithm for finding all the disjoint cycles in a functional graph, shown in Fig. 6. This algorithm is similar to the las vegas algorithm in the previous section, with only one key difference. We replace the Coinflip step in algorithm 1 to the Coloring step. Observe that in algorithm 1 the primary purpose of the Coinflip step is to reduce the number of active nodes by a constant factor while ensuring that any two consecutive active cycle nodes cannot become inactive at the same time. Graph coloring techniques can also serve this purpose. Hence, we simply replace the coinflip step in algorithm 1 to be a Coloring step, which is an invocation of the 6coloring algorithm due to [5]. After the Coloring step, each node compares its color with the color of its successor. If a node has a smaller color than its successor, it becomes inactive. Then all remaining active nodes perform the Explore step as in algorithm 1.
We can observe that after the coloring step at each iteration, the node with the largest color remains active in each disjoint cycle. By similar argument, we can show that Lemma 4.1 and Lemma 4.1 still hold.
Algorithm 2 computes all the disjoint cycles in a functional graph and takes rounds and messages.
Proof.
Since no more than 5 consecutive active nodes become inactive at each iteration by the property of 6coloring, the Explore Step still takes constant rounds. The coloring step introduces an additional factor. Thus, algorithm 2 terminates in rounds and takes messages. ∎
4.3 Distributed Top Trading Cycle Algorithm
We now present a distributed version of the top trading cycle algorithm. As in the sequential setting, we assume that each node knows which nodes are holding the houses in its preference list. Indeed, every node can broadcast its house to all. This only requires one round and messages.
The distributed algorithm is shown in Fig. 7. The basic idea is using the cycle finding algorithms presented above to simulate each stage of the top trading cycle algorithm. During a stage, all nodes first build the top choice functional graph, i.e, update their variable to be the node which holds their current top choice. Then, all nodes execute algorithm 1 or 2 to find out whether they are in a cycle or not. After that, a cycle node gets assigned its current top choice and broadcasts a message which contains the assigned house to all nodes. When node receives messages from other nodes, it deletes the houses contained in the messages from the preference list, i.e, from . When executing algorithm 1 or 2, nodes might terminate at different rounds. Thus, we need to coordinate the execution of each stage. In order to achieve this, we use a convergecast step using the tree built in the execution of algorithm 1 or 2. When a node completes broadcasting its message to all, it sends a message to its parent in the tree if it is a leaf node in the tree. For nonleaf nodes, they send an message to their parents only when they receive messages from all children. For the root node, when it receives from all its children, which means all nodes have updated their preference list, it broadcasts a message to all to notify all nodes to start the next stage of the algorithm.
Since each stage of algorithm 3 simulates each iteration of the TTC mechanism. The correctness of algorithm 3 follows from the correctness of TTC. We now look at the round and message complexity. Algorithm 3 computes the core of a housing market in rounds and takes messages.
Proof.
We just analyze the complexity of adopting the Las Vagas algorithm as a subroutine. The complexity of the deterministic algorithm just has an additional factor. Let denote the length of the cycle at stage of algorithm 3. At stage , both finding the cycle and convergecast along the tree need rounds, w.h.p. Finding the cycle takes messages and convergecast takes messages. Thus, each stage takes randomized rounds and messages. Therefore, since , algorithm 3 takes rounds and messages in the worst case. ∎
5 Conclusion
We conclude with two open problems. We have shown that computing a Pareto optimal matching for a housing allocation is in CC, which yields a linear time and linear work parallel algorithm. Computing an individual Pareto optimal matching for a housing market seems harder. It is interesting to know the relationship between this problem and the CC class. It is unlikely to be CCcomplete, since this would imply a RNC^{2} and a quasiNC^{2} algorithm for the CC class. We also show that computing the core of a housing market is CChard by giving a logspace reduction from the LFMM problem. It is interesting to know whether this problem is CCcomplete. Or can we show that it is Pcomplete?
References
 [1] Atila Abdulkadiroğlu and Tayfun Sönmez. Random serial dictatorship and the core from random endowments in house allocation problems. Econometrica, 66(3):689–701, 1998.
 [2] Atila Abdulkadiroğlu and Tayfun Sönmez. House allocation with existing tenants. Journal of Economic Theory, 88(2):233–260, 1999.
 [3] David J Abraham, Katarína Cechlárová, David F Manlove, and Kurt Mehlhorn. Pareto optimality in house allocation problems. In International Symposium on Algorithms and Computation, pages 3–15. Springer, 2004.
 [4] Nir Amira, Ran Giladi, and Zvi Lotker. Distributed weighted stable marriage problem. In International Colloquium on Structural Information and Communication Complexity, pages 29–40. Springer, 2010.
 [5] Richard Cole and Uzi Vishkin. Deterministic coin tossing with applications to optimal parallel list ranking. Information and Control, 70(1):32–53, 1986.
 [6] Stephen A Cook, Yuval Filmus, and Dai Tri Man Le. The complexity of the comparator circuit value problem. ACM Transactions on Computation Theory (TOCT), 6(4):15, 2014.
 [7] Manlove David. Algorithmics of matching under preferences, volume 2. World Scientific, 2013.
 [8] Andrew Drucker, Fabian Kuhn, and Rotem Oshman. On the power of the congested clique model. In Proceedings of the 2014 ACM symposium on Principles of distributed computing, pages 367–376. ACM, 2014.

[9]
Stephen Fenner, Rohit Gurjar, and Thomas Thierauf.
Bipartite perfect matching is in quasinc.
In
Proceedings of the fortyeighth annual ACM symposium on Theory of Computing
, pages 754–763. ACM, 2016.  [10] Aanund Hylland and Richard Zeckhauser. The efficient allocation of individuals to positions. Journal of Political economy, 87(2):293–314, 1979.
 [11] Richard M Karp. A survey of parallel algorithms for sharedmemory machines. 1988.

[12]
Jinpeng Ma.
Strategyproofness and the strict core in a market with
indivisibilities.
International Journal of Game Theory
, 23(1):75–83, 1994.  [13] Bruce M Maggs and Ramesh K Sitaraman. Algorithmic nuggets in content delivery. ACM SIGCOMM Computer Communication Review, 45(3):52–66, 2015.
 [14] Ernst W Mayr and Ashok Subramanian. The complexity of circuit value and network stability. Journal of Computer and System Sciences, 44(2):302–323, 1992.
 [15] Gary L Miller and John H Reif. Parallel tree contraction and its application. Technical report, HARVARD UNIV CAMBRIDGE MA AIKEN COMPUTATION LAB, 1985.
 [16] Ketan Mulmuley, Umesh V Vazirani, and Vijay V Vazirani. Matching is as easy as matrix inversion. In Proceedings of the nineteenth annual ACM symposium on Theory of computing, pages 345–354. ACM, 1987.
 [17] Alvin E Roth. Incentive compatibility in a market with indivisible goods. Economics letters, 9(2):127–132, 1982.
 [18] Alvin E Roth and Andrew Postlewaite. Weak versus strong domination in a market with indivisible goods. Journal of Mathematical Economics, 4(2):131–137, 1977.
 [19] Lloyd Shapley and Herbert Scarf. On cores and indivisibility. Journal of mathematical economics, 1(1):23–37, 1974.
 [20] Uzi Vishkin. Randomized speedups in parallel computation. In Proceedings of the sixteenth annual ACM symposium on Theory of computing, pages 230–239. ACM, 1984.
 [21] Yufei Yuan. Residence exchange wanted: a stable residence exchange problem. European Journal of Operational Research, 90(3):536–546, 1996.
 [22] Lin Zhou. On a conjecture by gale about onesided matching problems. Journal of Economic Theory, 52(1):123–135, 1990.