The stable marriage problem with ties and restricted edges

In the stable marriage problem, a set of men and a set of women are given, each of whom has a strictly ordered preference list over the acceptable agents in the opposite class. A matching is called stable if it is not blocked by any pair of agents, who mutually prefer each other to their respective partner. Ties in the preferences allow for three different definitions for a stable matching: weak, strong and super-stability. Besides this, acceptable pairs in the instance can be restricted in their ability of blocking a matching or being part of it, which again generates three categories of restrictions on acceptable pairs. Forced pairs must be in a stable matching, forbidden pairs must not appear in it, and lastly, free pairs cannot block any matching. Our computational complexity study targets the existence of a stable solution for each of the three stability definitions, in the presence of each of the three types of restricted pairs. We solve all cases that were still open. As a byproduct, we also derive that the maximum size weakly stable matching problem is hard even in very dense graphs, which may be of independent interest.


Introduction
In the classical stable marriage problem (sm) [8], a bipartite graph is given, where one side symbolizes a set of men U , while the other side symbolizes a set of women W . Man u and woman w are connected by edge uw if they find one another mutually acceptable. In the most basic setting, each participant provides a strictly ordered preference list of the acceptable agents of the opposite gender. An edge uw blocks matching M if it is not in M , but each of u and w is either unmatched or prefers the other to their respective partner in M . A stable matching is a matching not blocked by any edge. From the seminal paper of Gale and Shapley [8], we know that the existence of such a stable solution is guaranteed and one can be found in linear time.
Several real-world applications [2] require a relaxation of the strict order to weak order, or, in other words, preference lists with ties, leading to the stable marriage problem with ties (smt) [10,12,18]. When ties occur, the definition of a blocking edge needs to be revisited. In the literature, three intuitive definitions are used, namely weakly, strongly and super-stable matchings [10]. According to weak stability, a matching is weakly blocked by an edge uw if agents u and w both strictly prefer one another to their partners in the matching. A strongly blocking edge is preferred strictly by one end vertex, whereas it is not strictly worse than the matching edge at the other end vertex. A super-blocking edge is at least as good as the matching edge for both end vertices in the super-stable case. Superstable matchings are strongly stable and strongly stable matchings are weakly stable by definition, because weakly blocking edges are strongly blocking, and strongly blocking edges are super-blocking at the same time.
Another classical direction of research is to distinguish some of the edges based on their ability to be part of or to block a matching. Table 1 provides a structured overview of the three sorts of restricted edges that have been defined in earlier papers [14,5,6,1,16,4]. The mechanism designer has the right to specify three sets of restricted edges: forced edges must be in the output matching, forbidden edges must not appear in it, and finally, free edges cannot block the matching, no matter the preference ordering.
uw must be in M uw can be in M uw must not be in M uw can block M forced unrestricted forbidden uw cannot block M forced free irrelevant Table 1. The three types of restricted edges are marked with bold letters. The columns tells edge uw's role regarding being in a matching, while the rows split cases based on uw's ability to block a matching.
In this paper, we combine weakly ordered lists and restricted edges, and determine the computational complexity of finding a stable matching in all cases not solved yet.

Literature review
We first focus on the known results for the smt problem without restricted edges, and then switch to the sm problem with edge restrictions. Finally, we list all progress up to our paper in smt with restricted edges.
Ties. If all edges are unrestricted, a weakly stable matching always exists, because generating any linear extension to each preference list results in a classical sm instance, which admits a solution [8]. This solution remains stable in the original instance as well. On the other hand, strong and super-stable matchings are not guaranteed to exist. However, there are polynomial-time algorithms to output a strongly/super-stable matching or a proof for its nonexistence [10,19].
Restricted edges. Dias et al. [5] showed that the problem of finding a stable matching in a sm instance with forced and forbidden edges or reporting that none exists is solvable in O(m) time, where m is the number of edges in the instance. Approximation algorithms for instances not admitting any stable matching including all forced and avoiding all forbidden edges were studied in [4]. The existence of free edges can only enlarge the set of stable solutions, thus a stable matching with free edges always exists. However, in the presence of free edges, a maximum-cardinality stable matching is NP-hard to find [1]. Kwanashie [16,Sections 4 and 5] performed an exhaustive study on various stable matching problems with free edges. The term "stable with free edges" [3,7] is equivalent to "socially stable" [1,16].
Ties and restricted edges. Table 2 illustrates the known and our new results on problems that arise when ties and restricted edges are combined in an instance. Weakly stable matchings in the presence of forbidden edges were studied by Scott [24], where the author shows that deciding whether a matching exists avoiding the set of forbidden edges is NP-complete. A similar hardness result was derived by Manlove et al. [20] for the case of forced edges, even if the instance has a single forced edge. Forced and forbidden edges in super-stable matchings were studied by Fleiner et al. [6], who gave a polynomial-time algorithm to decide whether a stable solution exists. Strong stability in the presence of forced and forbidden edges is covered by Kunysz [15], who gave a polynomial-time algorithm for the weighted strongly stable matching problem with non-negative edge weights. Since strongly stable matchings are always of the same cardinality [17,12], a stable solution or a proof for its nonexistence can be found via setting the edge weights to 0 for forbidden edges, 2 for forced edges, and 1 for unrestricted edges.

Our contributions
In Section 3 we prove a stronger result than the hardness proof in [24] delivers: we show that finding a weakly stable matching in the presence of forbidden edges is NP-complete even if the instance has a single forbidden edge.
As a byproduct, we gain insight into the well-known maximum size weakly stable matching (without any edge restriction). This problem is known to be NP-complete [13,20], even if preference lists are of length at most three [11,21]. On the other hand, if the graph is complete, a complete weakly stable matching is guaranteed to exist. It turns out that this completeness is absolutely crucial to keep the problem tractable: as we show here, if the graph is a complete bipartite graph missing exactly one edge, then deciding whether a perfect weakly stable matching exists is NP-complete.
We turn to the problem of free edges under strong and super-stability in Section 4. We show that deciding whether a strongly/super-stable exists when free edges occur in the instance is NP-complete. This hardness is in sharp contrast to the polynomial-time algorithms for the weighted strongly/ super-stable matching problems. Afterwards, we show that deciding the existence of a strongly or super-stable matching in an instance with free edges is fixed-parameter tractable parameterized by the number of free edges.
Existence weak strong super forbidden NP-complete [24] always exists NP-complete NP-complete Table 2. Previous and our results summarized in a table. The contribution of this paper is marked by bold gray font. The instance has n vertices, m edges, |P | forbidden edges, and |Q| forced edges.

Preliminaries
The input of the stable marriage problem with ties consists of a bipartite graph G = (U ∪ W, E) and for each v ∈ U ∪ W , a weakly ordered preference list O v of the edges incident to v. We denote the number of vertices in G by n, while m stands for the number of edges. An edge connecting vertices u and w is denoted by uw. We say that the preference lists in an instance are derived from a master list if there is a weak order O of U ∪ W so that each O v where v ∈ U ∪ W can be obtained by deleting entries from O. The set of restricted edges consists of the set of forbidden edges P , the set of forced edges Q, and the set of free edges F . These three sets are disjoint.

Definition 1.
A matching M is weakly/strongly/super-stable with restricted edges P, Q, and F , if M ∩ P = ∅, Q ⊆ M , and the set of edges blocking M in a weakly/strongly/super sense is a subset of F .

Weak stability
In Theorem 1 we present a hardness proof for the weakly stable matching problem with a single forbidden edge, even if this edge is ranked last by both end vertices. The hardness of the maximum-cardinality weakly stable matching problem in dense graphs (Theorem 2) follows easily from this result.
Problem 1 smt-forbidden-1 Input: A complete bipartite graph G = (U ∪ W, E), a forbidden edge P = {uw} and preference lists with ties. Question: Does there exist a weakly stable matching M so that uw / ∈ M ? Theorem 1. smt-forbidden-1 is NP-complete, even if all ties are of length two, they appear only on one side of the bipartition and at the beginning of the complete preference lists, and the forbidden edge is ranked last by both its end vertices.
Proof. smt-forbidden-1 is clearly in NP, as any matching can be checked for stability in linear time.
We reduce from the perfect-smti problem defined below, which is known to be NP-complete even if all ties are of length two, and appear on one side of the bipartition and at the beginning of the preference lists, as shown by Manlove et al. [20]. Construction. To each instance I of perfect-smti, we construct an instance I ′ of smt-forbidden-1.
Let G = (U ∪W, E) be the underlying graph in instance I. When constructing G ′ for I ′ , we add two men u 1 and u 2 to U , and two women w 1 and w 2 to W . On vertex classes U ′ = U ∪ {u 1 , u 2 } and W ′ = W ∪ {w 1 , w 2 }, G ′ will be a complete bipartite graph. As the list below shows, we start with the original edge set E(G) in stage 0, and then add the remaining edges in four further stages. An example for the built graph is shown in Figure 1.

E(G)
We keep the edges in E(G) and also preserve the vertices' rankings on them. These edges are solid black in Figure 1.
We first connect u 1 to all women in W , and w 1 to all men in U . Man u 1 (woman w 1 ) ranks the women from W (men from U ) in an arbitrary order. Each u ∈ U (w ∈ W ) ranks w 1 (u 1 ) after all their edges in E(G). These edges are loosely dashed green in Figure 1.
Now we add for each pair (u, w) ∈ U × W with uw / ∈ E(G) the edge uw, where u (w) ranks w (u) even after w 1 (u 1 ). These edges are densely dashed blue in Figure 1.
Man u 2 is connected to all women from W ∪{w 1 }, and ranks all these women in an arbitrary order. The women from W ∪ {w 1 } rank u 2 worse than any already added edge. Similarly, w 2 is connected to all men from M ∪{u 1 }, and ranks all these men in an arbitrary order. The men from M ∪ {u 1 } rank w 2 worse than any already added edge. These edges are dotted red in Figure 1 Finally, we add the edges u 1 w 1 and u 2 w 2 , which are ranked last by both of their end vertices. Edge u 2 w 2 is the only forbidden edge and it is the violet zigzag edge in Figure 1, while u 2 w 2 is wavy gray. Claim: I admits a perfect stable matching if and only if I ′ admits a stable matching not containing u 2 w 2 .
(⇒) Let M be a perfect stable matching in I. We construct M ′ as M ∪ {u 1 w 2 } ∪ {u 2 w 1 }. Clearly, M ′ is a matching not containing the forbidden edge u 2 w 2 , so it only remains to show that M ′ is stable. We do this by case distinction on a possible blocking edge.

E(G)
Since M does not admit a blocking edge in I, no edge from the original All vertices in U ∪ W rank these edges lower than their edges in M ′ .

(U × W ) \ E(G)
Edges in this set cannot block M ′ because they are ranked worse than edges in M ′ by both of their end vertices.
Vertices in U ∪ W prefer their edge in M ′ to all edges in this set. Since they are in M ′ , u 1 w 2 and u 2 w 1 also cannot block M ′ . 4. u 1 w 1 and u 2 w 2 These two edges are strictly worse than u 1 w 2 ∈ M ′ and u 2 w 1 ∈ M ′ at all four end vertices.
(⇐) Let M ′ be a stable matching in I ′ and u 2 w 2 / ∈ M ′ . Since G ′ is a complete bipartite graph with the same number of vertices on both sides, M ′ is a perfect matching. In particular, u 2 and w 2 are matched by M ′ , say to w and u, respectively. Since M ′ does not contain the forbidden edge u 2 w 2 , we have that u = u 2 and w = w 2 . Then we have w = w 1 and u = u 1 , as uw blocks M ′ otherwise.
If M ′ contains an edge uw / ∈ E(G) with u ∈ U and w ∈ W , then this implies that uw 1 is a blocking edge. Thus, M := M ′ \ {u 1 w 2 , u 2 w 1 } ⊆ E(G), i.e. it is a perfect matching in G. This M is also stable, as any blocking edge in G immediately implies a blocking edge for M ′ , which contradicts our assumption on M ′ being a stable matching.
As a byproduct, we get that max-smti-dense, the problem of deciding whether an almost complete bipartite graph admits a perfect weakly stable matching, is also NP-complete. Proof. max-smti-dense is in NP, as a matching can be checked for stability in linear time.
We reduce from smt-forbidden-1. By Theorem 1, this problem is even NPcomplete if the forbidden edge uw is at the end of the preference lists of u and w. For each such instance I of smt-forbidden-1, we construct an instance I ′ of max-smti-dense by deleting the forbidden edge uw.
Claim: The instance I admits a stable matching if and only if I ′ admits a perfect stable matching.
(⇒) Let M be a stable matching for I. As smt-forbidden-1 gets a complete bipartite graph as an input, M is a perfect matching. Since M does not contain the edge uw, it is also a matching in I ′ . Moreover, M is stable there, because the transformation only removed a possible blocking edge and added none of these.
(⇐) Let M ′ be a perfect stable matching in I ′ . Since uw is at the end of the preference lists of u and w, and M ′ is perfect, uw cannot block M ′ . Thus, M ′ is stable in I.
Having shown a hardness result for the existence of a weakly stable matching even in very restricted instances with a single forbidden edge in Theorem 1, we now turn our attention to strongly and super-stable matchings.

Strong and super-stability
As already mentioned in Section 1.1, strongly and super-stable matchings can be found in polynomial time if forced and forbidden edges both occur in the instance [6,15]. Thus we consider the case of free edges, and in Theorem 3 and Proposition 1 we show hardness for the strong and super-stable matching problems in instances with free edges. The same construction suits both cases. Then, in Proposition 2 we remark that both problems are fixed-parameter tractable with |F | as the parameter.

Problem 4 ssmti-free
Input: A bipartite graph G = (U ∪W, E), a set F ⊆ E of free edges, and preference lists with ties. Question: Does there exist a matching M so that uw ∈ F for all uw ∈ E that blocks M in the strongly/super-stable sense?
In ssmti-free, we define two problem variants simultaneously, because all our upcoming proofs are identical for both of these problems. For the superstable marriage problem with ties and free edges, all super-blocking edges must be in F , while for the strongly stable marriage problem with ties and free edges, it is sufficient if a subset of these, the strongly blocking edges, are in F . Theorem 3. ssmti-free is NP-complete even in graphs with maximum degree four, and if preference lists of women are derived from a master list.
Proof. ssmti-free is clearly in NP because the set of edges blocking a matching can be determined in linear time.
Problem 5 1-in-3 positive 3-sat Input: A 3-SAT formula, in which no literal is negated and every variable occurs in at most three clauses. Question: Does there exist a satisfying truth assignment that sets exactly one literal in each clause to be true?
Construction. To each instance I of 1-in-3 positive 3-sat, we construct an instance I ′ of ssmti-free.
Let x 1 , . . . , x n be the variables and C 1 , . . . , C m be the clauses of the 1-in-3 positive 3-sat instance I. For each clause C i , we add a clause gadget consisting of three vertices a i , b i , and c i , where b i is connected to a i and c i , as shown in Figure 2. While vertices a i and b i do not have any further edge, c i will be incident to three interconnecting edges leading to variable gadgets. Vertex b i is ranked first by a i and last by c i , and these two vertices are placed in a tie by b i .
For each variable x i , occurring in the three clauses C i1 , C i2 , and C i3 , we add a variable gadget with nine vertices y j i , z j i , and w j i for j ∈ [3], as indicated in Figure 3. Each vertex z j i is connected only to y j i by a free edge, and these are the only free edges in our construction. For each (ℓ, j) ∈ [3] 2 , we add an edge w ℓ i y j i , which is ranked second (after z j i ) by y j i . The vertex w ℓ i ranks this edge at position one if ℓ = j and else at position two. Finally, we connect the vertex w ℓ i to the vertex c i ℓ by an interconnecting edge, ranked at position one by c i ℓ and position three by w ℓ i . The resulting instance is bipartite: U = {z j i , w j i , b i } is the set of men and W = {y j i , c i , a i } is the set of women. One easily sees that the maximum degree in our reduction is four.
Note that the preference lists of the women in the ssmti-free instance are derived from a master list. The master list for the women W = {y j i , c i , a i } is the Claim: I is a YES-instance if and only if I ′ admits a strongly/super-stable matching.
(⇒) Let T be a satisfying truth assignment such that for each clause, exactly one literal is true. For each true variable x i in this assignment, let M contain the edges w ℓ i c i ℓ and y ℓ i z ℓ i for each ℓ ∈ [3]. For all other variables, let M contain w ℓ i y ℓ i for each ℓ ∈ [3]. For each clause C i , add the edge a i b i to M . Following these rules, we have constructed a matching. It remains to check that M is super-stable (and thus also strongly stable). Since a i is matched to its only neighbor, it cannot be part of a blocking edge. Since each c i is matched along an interconnecting edge, which is better than b i , no blocking edge involves b i . A blocking interconnecting edge c i w ℓ j implies that w ℓ j is not matched to any y ℓ j , however this is only true if c i w ℓ j ∈ M . A blocking edge w ℓ i y j i does not appear. Either w ℓ i is matched to its unique first choice y ℓ i and therefore not part of a blocking edge, or y j i is matched to its unique first choice z j i , and thus, y j i is not part of a blocking edge.
(⇐) Let M be a strongly stable matching (note that any super-stable matching is also strongly-stable). Then M contains the edge a i b i , and c i is matched to a vertex w ℓ j for all i ∈ [m], as else c i b i or a i b i block M . If w ℓ j c i ∈ M , then y a j z a j ∈ M for all a ∈ [3], as else w ℓ j y a j would be a blocking edge. This, however, implies that w a j c ja ∈ M for all a ∈ [3], as else w a j c ja would be a blocking edge. Thus, for each variable x i , the matching M contains either all edges w ℓ i c i ℓ for ℓ ∈ [3] or none of these edges. Thus, the variables x i such that M contains w ℓ i c i ℓ for ℓ ∈ [3] induce a truth assignment such that for each clause, exactly one literal is true. This proof aimed at the hardness of the restricted case, in which the underlying graph has a low maximum degree. For the sake of completeness, we add another variant, which is defined in a complete bipartite graph. Proposition 1. ssmti-free is NP-complete, even in complete bipartite graphs, where each tie has length at most three.
Proof. We reduce from ssmti-free. Given a ssmti-free instance on graph G, we add all non-present edges between men and women as free edges, ranked worse than any edge from E(G). We call the resulting graph H.
Clearly, a strongly/super-stable matching in G is also strongly/super-stable in H, as we only added free edges.
Vice versa, let M be a strongly/super-stable matching in H. Let M ′ := M ∩ E(G) arise from M by deleting all edges not in E(G). Then M ′ clearly is a matching in G, so it remains to show that M ′ is strongly/super-stable.
Assume that there is a blocking edge uw in, G, in the strongly/super-stable sense. Since uw is not blocking in H, at least one of u and w has to be matched in H, but not in G. However, this vertex prefers uw also to its partner in H, and thus, uw is also blocking in H, which is a contradiction.
Note that ssmti-free becomes polynomial-time solvable if only a constant number of edges is free in the same way as max-ssmi, the problem of finding a maximum-cardinality stable matching with strict lists and free edges [1].
Proposition 2. SSMTI-Free can be solved in O(2 k nm) time in the strongly stable case, and in O(2 k m) time in the super-stable case, where k := |F | is the number of free edges.
Proof. For each subset Q ⊆ F of free edges, we construct an instance of ssmtiforced as follows. Mark all edges in Q as forced, and delete all other free edges.
If any of the ssmti-forced instances admits a stable matching, then this is clearly a stable matching in the ssmti-free instance, as only free edges were deleted. Vice versa, any solution M for the ssmti-free instance containing exactly the set of forced edges Q (i.e. Q = M ∩F ) immediately implies a solution for the ssmti-forced instance with forced edges Q.
Clearly, there are 2 k subsets of F . Since any instance of ssmti-forced can be solved in O(nm) time in the strongly stable case [6] and in O(m) time in the super-stable case [15], the running time follows.

Conclusion
Studying the stable marriage problem with ties combined with restricted edges, we have shown three NP-completeness results. Our computational hardness results naturally lead to the question whether imposing master lists on both sides makes the problems easier to solve. Moreover, it is open whether smtforbidden-1 remains hard in bounded-degree graphs. In addition, one may try to identify relevant parameters for our problems and then decide whether they are fixed-parameter tractable or admit a polynomial-sized kernel with respect to these parameters.