The two problems of stable matching and cuts in graphs were introduced in the seminal papers of Gale and Shapley (1962) [GS62] and Ford and Fulkerson (1956) [FF56], respectively. Over the decades, remarkably deep and elegant theories have emerged around both these problems which include highly sophisticated efficient algorithms, not only for the basic problems but also several generalizations and variants, that have found numerous applications [Knu97, GI89, Man13, Sch86].
In this paper, we study a natural generalization of stable matching to the maximum weight stable matching problem and we obtain an efficient combinatorial algorithm for it; we remark that the linear programming formulation of stable matching can be used to show that the weighted version is in P, see Section1.3. Our algorithm is obtained by reducing this problem to the problem of finding a maximum weight ideal cut in a DAG. We give the first polynomial time algorithm for the latter problem; this algorithm is also combinatorial. The combinatorial nature of our algorithms not only means that they are efficient but also that they enable us to obtain additional structural and algorithmic results:
We show that the set, , of maximum weight stable matchings forms a sublattice of the stable matching lattice .
We give an efficient algorithm for finding boy-optimal and girl-optimal matchings in .
We generalize the notion of rotation, a central structural notion in the context of the stable matching problem, to meta-rotation. Analogous to the way rotations help traverse the lattice , meta-rotations help traverse the sublattice .
The maximum weight stable matching problem has several applications, e.g., the egalitarian stable matching problem defined in section 1.3. Another application is: given a set of desirable boy-girl pairs and a set of undesirable pairs, find a stable matching that simultaneously maximizes the number of pairs in and minimizes the number of pairs in . This reduces to our problem by assigning each pair in a weight of 1 and each pair in a weight of .
Our results are based on deep properties of rotations and the manner in which closed sets in the rotation poset yield stable matchings in the lattice .
1.1 Problem definitions
Let denote an instance of the stable matching problem over sets and of boys and girls, respectively. Let be a weight function . Then defines an instance of the maximum weight stable matching problem; it asks for a stable matching of instance , say , that maximizes the objective function
In the maximum weight ideal cut problem we are given a directed acyclic graph with a source and a sink such that for each , there is a path from to and a path from to . We are also given a weight for each edge . An ideal cut is a partition of the vertices into sets and such that and and there is no edge with and . We remark that such a set is also called a closed set. The weight of the ideal cut is defined to be sum of weights of all edges crossing the cut i.e., . The problem is to find an ideal cut of maximum weight.
1.2 Overview of results and technical ideas
We start by giving an LP formulation for the problem of finding a maximum weight ideal cut in an edge-weighted DAG, ; we note that the weights can be positive as well as negative. We go on to showing that this LP always has integral optimal solutions, hence showing that the problem is in P (Proposition 1). We next study the polytope obtained from the constraints of this LP (Theorem 1). We first show that the set of vertices of this polytope is precisely the set of maximum weight ideal cuts in the DAG . For this reason, we call this the ideal cut polyhedron. Next we characterize the edges of this polyhedron: we show that two cuts and are adjacent in the polyhedron iff or .
We then study the dual of this LP. We interpret it as solving a special kind of - flow problem in in which the flow on each edge has to be a least the capacity of the edge and the objective is to minimize the flow from to . We show how to solve this flow problem combinatorially in polynomial time (Proposition 2). Next, we define the notion of a residual graph for our flow problem. After finding an optimal flow, the srongly connected components in the residual graph are shrunk to give an unweighted DAG . We show that ideal cuts in correspond to maximum weight ideal cuts in (Theorem 2).
We also show that the set of maximum weight ideal cuts in forms a lattice under the operations of set union and intersection (Theorem 2).
Finally, we move on to our main problem of finding a maximum weight stable matching. We start by showing that the set of such matchings forms a sublattice of the lattice of all stable matchings (Theorem 5).
We then give what can be regarded as the main result of our paper: a reduction from this problem to the problem of finding a maximum weight ideal cut in an edge-weighted DAG (Section 5.1). This reduction goes deep into properties of rotations and the rotation poset . Closed sets of are in one-to-one correspondence with the stable matchings in the lattice . In particular, if matching corresponds to closed set , then starting from the boy-optimal matching in lattice we will reach matching by applying the set of rotations in .
Let be the set of rotations used in . We add new vertices and to ; dominates all remaining vertices and is dominated by all remaining vertices. This yields the DAG . The next task is to assign appropriate weights to the edges of ; this is done by using properties of rotations. Finally, let be a maximum weight ideal cut in weighted DAG , and let be the matching arrived at by starting from the boy-optimal matching in lattice and applying the set of rotations in . Then let us say that corresponds to . We show that in fact this is a one-to-one correspondence between maximum weight ideal cuts in and maximum weight stable matchings for the given instance (Theorem 4).
Recall the definition of (unweighted) DAG given above which was obtained from the edge-weighted DAG . As stated above, ideal cuts in the correspond to maximum weight ideal cuts in , and hence to maximum weight stable matchings, . A vertex in corresponds to a set of vertices in , and these sets form a partition of the set of rotations . We call these sets meta-rotations. As stated above, meta-rotations help traverse the sublattice in the same way that rotations help traverse the lattice (Theorem 6).
1.3 Related results
The works of Vande Vate [Vat89] and Rothblum [Rot92] give a linear program of polynomial size whose vertices, also called basic feasible solutions, are precisely the set of stable matchings of the given instance. Therefore, the maximum weight stable matching problem can clearly be solved in polynomial time. As stated above, the main point of our paper is to obtain a combinatorial polynomial time algorithm for this problem.
In 1987, Irving et. al. [IPG87] gave a combinatorial polynomial time algorithm for the following problem which arose in the context of obtaining an egalitarian stable matching which, unlike the matching produced by the Gale-Shapley procedure, favors neither boys nor girls. Each boy provides a preference weight for each girl and similarly, each girl provides a preference weight for each boy . By ordering these weights, we get the preference orders for each boy and each girl. The problem is to find a matching that is stable under these preference orderings, say , such that it maximizes (or minimizes) . Clearly, this is a special case of our problem.
It is a well known that finding a minimum weight ideal cut reduces in a straightforward manner to the minimum - cut problem. However, to the best of our knowledge, a polynomial time algorithm for maximum weight ideal cut was not known before. In particular, the reduction mentioned above does not give it, since the maximum - cut problem is NP-hard.
Our results on the ideal cut polyhedron are motivated by results reported in [GV95]. The latter paper showed that the polyhedron obtained from the dual of the maximum - flow LP does not capture all minimum - cuts as vertices. They also characterized edges of this polyhedron (it is similar to the one we obtained for ideal cuts). Then they went on to giving a different polyhedron whose vertices are in one-to-one correspondence with all minimum - cuts.
Our procedure of going from the edge-weighted DAG to the unweighted DAG (Theorem 2) follows from the work of Picquard and Queyranne [PQ80]. Their procedure yields a DAG after performing max - flow, computing the residual graph and shrinking strongly connected components. As shown in [PQ80], ideal cuts in this DAG correspond to min - cuts in the original graph.
2.1 The stable matching problem
The stable matching problem takes as input a set of boys and a set of girls ; each person has a complete preference ranking over the set of opposite sex.
A matching is a one-to-one correspondence between and . For each pair , is called the partner of in (or -partner) and vice versa. For a matching , a pair is said to be blocking if is below and is below , i.e., they prefer each other to their partners. A matching is stable if there is no blocking pair in .
2.2 The lattice of stable matchings
Let and be two stable matchings. We say that dominates , denoted by , if every boy weakly prefers his partner in to . It is well known that the dominance partial order over the set of stable matchings forms a distributive lattice [GI89], with meet and join defined as follows. The meet of and , , is defined to be the matching that results when each boy chooses his more preferred partner from and ; it is easy to show that this matching is also stable. The join of and , , is defined to be the matching that results when each boy chooses his less preferred partner from and ; this matching is also stable. These operations distribute, i.e., given three stable matchings ,
In this paper, we will denote this lattice by . It is easy to see that must contain a matching, , that dominates all others and a matching that is dominated by all others. is called the boy-optimal matching, since in it, each boy is matched to his most favorite girl among all stable matchings. This is also the girl-pessimal matching. Similarly, is the boy-pessimal and girl-optimal matching.
2.3 Rotations help traverse the lattice
A crucial ingredient needed to understand the structure of stable matchings is the notion of a rotation, which was defined by Irving [Irv85] and studied in detail in [Irv86]. A rotation takes matched pairs in a fixed order, say and “cyclically” changes the mates of these agents, as defined below, to arrive at another stable matching. Furthermore, it represents a minimal set of pairings with this property, i.e, if a cyclic change is applied on any subset of these pairs, with any ordering, then the resulting matching has a blocking pair and is not stable. After rotation, the boys’ mates weakly worsen and the girls’ mates weakly improve. Thus one can go from to by applying a suitable sequence of rotations (specified by the rotation poset defined below). Indeed, this is precisely the purpose of rotations.
Let be a stable matching. For a boy let denote the first girl on ’s list such that strictly prefers to her -partner. Let denote the partner in of girl . A rotation exposed in is an ordered list of pairs such that for each , , is , where is taken modulo . In this paper, we assume that the subscript is taken modulo whenever we mention a rotation. Notice that a rotation is cyclic and the sequence of pairs can be rotated. is defined to be a matching in which each boy not in a pair of stays matched to the same girl and each boy in is matched to . It can be proven that is also a stable matching. The transformation from to is called the elimination of from .
Let be a rotation. We say that moves from to , and it moves from to , for .
2.4 The rotation poset
A rotation is said to precede (or dominate) another rotation , denoted by , if is eliminated in every sequence of eliminations from to a stable matching in which is exposed. Thus, the set of rotations forms a partial order via this precedence relationship. The partial order on rotations is called rotation poset and denoted by .
Lemma 1 ([Gi89], Lemma 3.2.1).
For any boy and girl , there is at most one rotation that moves to or from . Moreover, if moves to and moves from then .
A closed subset is a subset of the poset such that if an element is in the subset then all of its predecessors are also included. There is a one-to-one relationship between the stable matchings and the closed subsets of . Given a closed subset , the correponding matching is found by eliminating the rotations starting from according to the topological ordering of the elements in the subset. We say that generates .
Lemma 2 ([Gi89], Lemma 3.3.2).
contains at most rotations and can be computed in polynomial time.
3 Maximum Weight Ideal Cuts: IP, LP and Polyhedron
In this section, we show how to find a maximum weight ideal cut using linear programming. We also prove some characteristics of the solution set and define a polyhedron whose vertices are precisely the ideal cuts.
3.1 A linear program for maximum weight ideal cut
Consider the following integer program which has a variable for each vertex of DAG :
An optimal solution to (1) is a maximum weight ideal cut in .
Let The set of constraints
guarantees that there are no edges coming into . Hence, forms an ideal cut. For each edge ,
Thus, (1) finds an ideal cut that maximizes the sum of weights of crossing edges as desired. ∎
Now consider the following LP relaxation of (1):
Note that the above constraints imply for each since there is a directed path from to and a directed path from to . We show how to round a solution of (2) to an integral solution with the same objective function value. Later on we show that any basic feasible solution of (2) is integral anyway.
Let be a (fractional) optimal solution of (2) and be an integral solution such that
has the same objective value as .
Assume that is not integral, since otherwise the statement is trivially true. We will say that is the potential of . Now there must exist such that . Denote by the set of all vertices having potential . Let be the set of edges going into :
and be the set of edges going out of :
Consider adding to the potentials of all vertices in an amount where is small enough so that no constraint is violated. Specifically, the potential of after modification is . The change in objective function along edges in is
The change in objective function along edges in is
The total change is
If , we can always pick a sign for so as to obtain a strictly better solution. Therefore, .
Let be the smallest -value that is greater than . implies that we can increase the potentials of all vertices in to and obtain the same objective value. The theorem follows by induction on the number of possible -values. ∎
A maximum weight ideal cut can be found in polynomial time.
3.2 The ideal cut polytope
Consider the polyhedron formed by the constraints on in (2):
Let be the number of vertices in . A vertex of is a feasible solution having at least linearly independent active constraints (constraints that are satisfied at equality). Let be the set of those constraints. Notice that in any feasible solution, and must be active. Let be a graph such that and
We call an active graph.
consists of two trees and such that and .
We prove that contains no cycle and no path. Since each edge of corresponds to a constraint in , has at least edges. The lemma will then follow.
Claim. contains no cycle.
Assume contains cycle . Since edges in the cycle correspond to active constraints, for each edge in the cycle. Therefore, , which implies . It follows that the set of inequalities are not independent.
Claim. contains no path.
Assume contains a path . Since edges in the path correspond to active constraints, for each edge in the path. Therefore, , which is a contradiction.
An edge in polytope is defined by the intersection of linearly independent inequalities. Two vertices, also called basic feasible solutions, of the polytope are neighbors if and only if they share an edge, i.e., the sets of inequalities that define them differ in only one inequality. Two cuts are said to be neighbors if two basic feasible solutions corresponding to them are neighbors.
All vertices of polyhedron are integral, and the set of vertices is precisely the set of ideal cuts. Moreover, vertices of corresponding to cuts and are neighbors if and only if or .
By Lemma 5, consists of two non-intersecting trees and . So for all and for all . Therefore, is integral.
Now consider an ideal cut defined by . We can find a tree connecting all vertices in , and a tree connecting all vertices in . Consider the following set of inequalities:
constraints corresponding to edges in tree ,
constraints corresponding to edges in tree ,
Clearly, the set contains linearly independent inequalities, and the basic feasible solution obtained by those inequalities is exactly the ideal cut .
Next, we prove the second statement. If the cuts defined by and are neighbors, the sets of inequalities defining them differ in only one inequality. Let and be active graphs for and respectively. By Lemma 5, consists of two trees , and consists of two trees . Moreover, and . Since the sets of inequalities defining and differ in only one inequality, results from by removing an edge and adding an edge . Consider the graph obtained by removing from . Without loss of generality, assume that . Therefore, there exists such that vertices in are not reachable from in . By the proof of Lemma 5, contains no cycle. Hence, can either connect to a vertex in or a vertex in . If connects to a vertex in , , which contradicts the fact that and are neighbors. If connects to a vertex in , we have .
On the other direction, assume that without loss of generality. We will give a set of active inequalities defining and a set of active inequalities defining such that they differ in only one inequality. Let . Let be spanning trees of and respectively. Let be a vertex in . By assumption on , there exists a path from to containing . Since and are ideal cuts, there exist an edge from to and an edge from to . Consider the set of inequalities for edges in . These inequalities define . Similarly, the inequalities for edges in define . The two sets of inequalities differ by only one inequality as desired. ∎
Theorem 1 justifies calling the polytope defined in this section the ideal cut polytope.
4 Maximum Weight Ideal Cuts: Combinatorial Algorithm
4.1 The set of maximum weight ideal cuts forms a lattice
We first prove the following fact.
If and are two subsets defining maximum weight ideal cuts in then and also define maximum weight ideal cuts.
Let be the set of edges going from to :
Let be the set of edges going from to :
Let be the set of edges going from to :
Let be the set of edges going from to :
Let be the set of edges going from to :
Note that there are no edges going between and .
Therefore, the weight of the ideal cut defined by is
The size of the ideal cut defined by is
Since both cuts are maximum weight ideal cuts,
We will show that and . Assume that and . Then the weight of the cut defined by is
Similarly, if and ,
Therefore, , and
Lemma 6 gives:
The set of maximum weight ideal cuts forms a lattice under the operations of union and intersection.
4.2 A flow problem in which capacities are lower bounds on edge-flows
Let be the dual variable corresponding to edge . The dual linear program is:
We show that (4) can be interpreted as a flow problem. To be precise, represents the flow value on edge . The first set of inequalities guarantees flow conservation at each vertex. The second set of inequalities says that there is a lower bound on the amount of flow on . Note that as well as can be negative.
The problem is to find a minimum circulation in the graph obtained by adding an infinite capacity edge from to to . Equivalently, without the introduction of , the problem can be seen as finding a minimum flow from to in .
We give a combinatorial algorithm to solve the above flow problem. The high level idea is to first find a feasible flow, i.e, a flow satisfying all inequalities. We then push flow back as much as possible from to , while maintaining flow feasibility.
It is easy to see that the routine in Figure 1 gives us a feasible flow. At the end of the routine, the value of flow from to is at most where .
To push flow back from to , we construct the following residual graph for a feasible flow . Since is feasible, . For each such that , we create a residual edge from to with capacity . Notice that the capacity on is exactly the amount we can push back on without violating the lowerbound constraint. Finally, all edges in still have infinite capacity.
Let be a feasible flow in . In other words, satisfies flow conservation and capacity constraints. Let be a flow constructed as follows:
is a feasible solution to (4).
Flow conservation is satisfied trivially. It suffices to show that no lower bound constraint is violated. Consider 2 cases:
if is an edge in , the capacity of is . Therefore, .
if is not an edge in , .
is an optimal solution of (4) if and only if there is no path from to in .
Suppose that there exists a path from to in . Sending flow along the path gives a feasible flow by Lemma 7. Moreover, the objective function has a smaller value. Therefore, is not an optimal solution of (4).
If there is no path from to , let be the set of vertices that are reachable from by a path in :
Consider such that and . Since is not an edge in and is feasible, .
Let be the primal solution such that for all and otherwise. With respect to , if and only if and if and only if . Therefore, and satisfy complementarity. Hence, is an optimal solution of (4). ∎
By Lemma 7 and Lemma 8, a natural algorithm, given a feasible flow , is the following: Iteratively find a path from to in . If there exists such a path, send maximal flow back on this path without violating feasibility, update and repeat. Otherwise, is an optimal flow by Lemma 8.
Notice that the above routine is very similar to the Ford–Fulkerson algorithm for finding maximum - flow. A more straight forward way is to compute a maximum flow in for a feasible flow as shown in Figure 2.
By Lemma 8, it suffices to show that there is no path from to in if and only if is a maximum flow from to in .
If there exists a path from to in , then there exists such that is a flow of from to smaller value than . Therefore, is a flow from to in of greater value than , which is a contradiction.
If is not a maximum flow, there exists such that is a feasible flow from to in of greater value. Therefore, there exists a path from to in . ∎
4.3 Generating all maximum weight ideal cuts
The process is similar to finding the Picard-Queyranne structure, whose ideal cuts are in one-to-one correspondence with the minimum - cuts in a graph. Given an optimal flow solution , we shrink the strongly connected components of . The resulting graph is a DAG . Now, ideal cuts in are in one-to-one correspondence with maximum weight cuts in the original graph. Hence we get:
There is a combinatorial polynomial time algorithm for constructing a DAG such that an ideal cut in bijectively corresponds to a maximum weight ideal cut in .
5 Maximum Weight Stable Matching Problem
5.1 The reduction
Given an instance of maximum weight stable matching problem, we show how to obtain an instance of maximum weight ideal cut problem such that there is a bijection between the set of solutions to and those to .
For this purpose, we show how to construct a DAG with an edge-weight function . We start with the rotation poset that generates all stable matchings for . This can be obtained in polynomial time by Lemma 2. Next, we construct an edge-weighted DAG as follows:
Keep all vertices and edges in the natural DAG representation of . Let be the vertex that corresponds to .
Add a source and an edge from to every such that is not dominated by any other rotation.
Add a sink and an edge from every to , such that does not dominate any other rotation.
Next, consider all pairs that appears in the stable matchings of the given instance. Ignore a pair if it appears in all stable matchings. With each of the remaining pairs , we associate a directed path in as follows:
Case 1, : There exists a rotation that moves away from . Choose to be an arbitrary path in from to .
Case 2, : There exists a rotation that moves to . Choose to be an arbitrary path in from to .
Case 3, : There exist a rotation moving to and a rotation moving from . By Lemma 1, dominates , and therefore there is at least one path in from to . Choose to be an arbitrary such path.
Finally, we assign weights to the edges of as follows. Initialize all edge weights to 0. Then, for each pair , we add to the weights of all edges in . We also say that
Clearly, an ideal cut in corresponds to a closed subset in . To be precise, for a non-empty vertex set such that and there are no incoming edges to ,
is clearly a closed subset in . We prove a simple yet crucial lemma:
cuts if and only if the matching generated by contains .
We will use the following key observation: for any pair of vertices in a DAG such that there exist paths from to , an ideal cut separates and if and only if it cuts each of these paths exactly one. We consider 3 cases:
Case 1, : There exists a unique rotation that moves away from . cuts if and only if does not contain . This happens if and only if the matching generated by contains .
Case 2, : There exists a unique rotation that moves to . cuts if and only if contains . This happens if and only if the matching generated by contains .
Case 3, : There exist a unique rotation moving to and a unique rotation moving from . cuts if and only if contains and does not contain . This happens if and only if the matching generated by contains .
The maximum weight stable matchings in are in one-to-one correspondence with the maximum weight ideal cuts in .
We show that the weight of an ideal cut generated my is equal to the weight of the matching generated by . By Lemma 9,
The theorem follows. ∎
5.2 The sublattice, and using meta-rotations to traversing it
If and are maximum stable matchings in then so are and .
The set of maximum weight stable matchings forms a sublattice of the lattice .
We next give the notion of a meta-rotation. These help traverse the sublattice in the same way that rotations help traverse the lattice . Let be the set of all rotations used in the rotation poset . Let be the graph obtained from by adding vertices and and assigning weights to edges, as described in Section 5.1. Let be the DAG constructed in Theorem 3; ideal cuts in correspond to a maximum weight ideal cuts in . A vertex, , in corresponds to a set of vertices in . Hence we may view as a subset of the rotations in ; clearly, the subsets represented by the set of all vertices in form a partition of .
By analogy with the rotation poset , let us represent by and call it the meta-rotation poset. Each vertex in (and ) is a subset of and is called a meta-rotation. Let be the element in containing , and be the element in containing . For any closed subset, , of , let be the set of all rotations contained in the meta-rotations of . Eliminating these rotations starting from , according to the topological ordering of the rotations given in , we arrive at a maximum weight stable matching, say . In this manner, the meta-rotations help us traverse the sublattice. Combining with Proposition 2 and Theorem 4, we get:
There is a combinatorial polynomial time algorithm for finding a maximum weight stable matching. The meta-rotation poset can also be constructed in polynomial time. Each closed subset of containing and not containing generates a maximum weight stable matching.
The running time of the algorithm described above is dominated by the time required to find a max-flow in the graph obtained from which has vertices.
5.3 Further applications of the structure
5.3.1 Finding boy-optimal and girl-optimal matchings in
Notice that for two closed subsets and , the matching generated by dominates the matching generated by if . Hence we have:
The closed subset containing only the meta-rotation generates the boy-optimal stable matching and the one containing all meta-rotations other than generates the girl-optimal stable matching in the sublattice .
5.3.2 Bi-objective stable matching
In the bi-objective stable matching problem we are given sets and , of boys and girls and, for each boy and each girl, a complete preference ordering over all agents of the opposite sex. However, unlike the maximum weight stable matching problem, we are given two weight functions . The problem is to find a stable matching that maximizes