1 Introduction

Given 2n agents, each having preferences with regard to how suitable the other agents are as potential partners, the Stable Roommates problem is to decide whether there exists a matching, i.e., a set of disjoint pairs of the agents, without inducing a blocking pair. A blocking pair consists of two agents that are not matched to each other but prefer to be with each other rather than with their assigned partners. A matching without blocking pairs is called a stable matching.

Stable Roommates was introduced by Gale and Shapley [26] in the 1960’s and has been studied extensively since then [32,33,34,35, 48, 49]. While it is quite straightforward to see that stable matchings may not always exist, it is not trivial to see whether an existing stable matching can be found in polynomial time, even when the input preference orders are complete and do not contain ties (i.e., each agent can be a potential partner to each other agent, and no two agents are considered to be equally suitable as a partner). For the case without ties, Irving [32] and Gusfield and Irving [30] provided \(O(n^2)\)-time algorithms to decide the existence of a stable matching and to find one if it exists—for complete preferences and for incomplete preferences, respectively. Deciding whether a given instance admits a stable matching is NP-complete [48] when the given preferences are complete but may contain ties.

Solving Stable Roommates has many applications, such as matching students with each other to accomplish a homework project or users in a P2P file sharing network, assigning co-workers to two-person offices, partitioning players in two-player games, or finding receiver-donor pairs for organ transplants [36, 38, 39, 50, 51]. In such situations, the students, the people, or the players, who we jointly refer to as agents, typically have certain structurally restricted preferences concerning which other agents might be their best partners. For instance, when assigning roommates, each agent may have an ideal room temperature and may prefer to be with another agent with the same penchant. Such preferences are called narcissistic. Moreover, if we order the agents according to their ideal room temperatures, then it is natural to assume that each agent z prefers to be with an agent x rather than with another agent y if z’s ideal temperature is closer to x’s than to y’s. These kind of preferences are called single-peaked [5, 17, 31]. Single-peakedness is used to model agents’ preferences where there is a criterion, e.g., room temperature, that can be used to obtain a linear order of the agents such that each agent’s preferences over all agents along this order are strictly increasing until they reach the peak—their ideal partner—and then strictly decreasing. Single-peakedness is a popular concept with prominent applications in voting contexts. If the input preferences are complete and contain no ties, then testing whether they are single-peaked can be done in linear time [2, 4, 18, 22].

Another possible restriction on the preferences is the single-crossing property, which was originally proposed to model individuals’ preferences on income taxation [43, 47]. To illustrate this, assume that the agents are increasingly ordered from left to right according to their income level. Then, one may observe that the agents’ roommates preferences towards two arbitrary agents, say x and y, are such that the agents on the left prefer x to y while the agents on the right prefer y to x. This kind of preferences is not necessarily single-peaked as people do not always prefer to have a roommate of similar income level. If the input preferences are complete and contain no ties, then testing whether they are single-crossing can be done in polynomial time [8, 18, 19]. We refer to Bredereck et al. [9] and Elkind et al. [21] for numerous references on single-peakedness and single-crossingness.

Related work. Bartholdi III and Trick [4] studied Stable Roommates with narcissistic and single-peaked preferences. They showed that for the case with linear orders (i.e., complete and without ties) a Stable Roommates instance with 2n agents always admits a unique stable matching, and they claimed an O(n)-time algorithm to find this matching [4, Section 3]. However, we will show in Example 4 that there are instances for which their algorithm runs in \(O(n^2)\) time. In terms of preference structures in the stable matching setting, using a connection to narcissistic single-crossing preference profiles (see Sect. 2.3 for the corresponding definition) and semi-standard Young tableaux [55], Chen and Finnendahl [13] counted the number of narcissistic preference profiles that are also either single-peaked or single-crossing.

Paper structure and our contributions. We study the computational complexity of Stable Roommates for structured preferences when incompleteness and ties are allowed. In particular, we explore how the specific preference structures help in guaranteeing the existence of stable matchings and in designing efficient algorithms for finding a stable matching, even when the input preferences may be incomplete or contain ties.

Table 1 Complexity of Stable Roommates for restricted domains: narcissistic, single-peaked, and single-crossing preferences. “nar” means “narcissistic”, “sp” means “single-peaked”, “sc” means “single-crossing”, “always” means that there is always a stable matching, and “unique” means that there is a unique stable matching. Entries marked with \(^\diamondsuit \) are from Irving [32]. Entries marked with \(^\spadesuit \) are from Gusfield and Irving [30]. Entries marked with \(^\triangle \) are from Ronn [48]. Entries marked with \(^\heartsuit \) are from Bartholdi III and Trick [4]. Entries marked boldfaced with a reference to the corresponding theorem [T. x] or proposition [P. x] are new results shown in this paper. Note that our hardness results for single-crossing preferences hold for the more restricted “tie-sensitive single-crossing ” variant

In Sect. 2, we discuss natural generalizations of the well-known single-peaked and single-crossing preferences (that were originally introduced for linear orders) for incomplete preferences with ties. In Sect. 3, we show that for complete preference orders, structurally restricted preferences such as being narcissistic and single-crossing or being narcissistic and single-peaked guarantee the existence of stable matchings. Moreover, we demonstrate that the known algorithm of Bartholdi III and Trick [4] can be extended to always find a stable matching in two new cases: The algorithm works

  1. (1)

    when the preferences are complete, narcissistic, single-crossing, and may contain ties as well as

  2. (2)

    when the preferences are complete, narcissistic, single-peaked, and may contain ties.

In Sect. 4 we study the case where the preferences are incomplete and may contain ties, and prove that Stable Roommates becomes NP-complete, even when the preferences are narcissistic, single-peaked, and (tie-sensitive) single-crossing. Our results, together with those from related work, are surveyed in Table 1. We conclude in Sect. 5 with some open questions.

2 Fundamental concepts and basic observations

In this section, we introduce fundamental concepts and notions, arising from stable matchings and structured preferences, and we make some crucial observations regarding relations between the different structured preferences.

2.1 Preferences, acceptable sets, and acceptability graphs

Let \(V=\{1,2,\ldots , 2n\}\) be a set of 2n agents. A (preference) profile \(\mathcal {P}=(\succ _i)_{i\in V}\) is a collection of the preference orders of the agents from V. Here, the preference order \(\succeq _i\) of each agent \(i\in V\) is a weak order on a subset \(V(\succeq _i)\subseteq V\) of agents that i finds acceptable as a partner. The set \(V(\succeq _i)\) is called the acceptable set of i. Recall that a weak order \(\succeq \) on a set X is a transitive (i.e., \(x\succeq y\) and \(y\succeq z\) imply \(x\succeq z\)) and complete (i.e., \(x\succeq y\) or \(y\succeq x\) for all \(x,y\in X\)) binary relation on X (see [6, Chapter 4] or [7, Chapter 1.2.2]). For instance, the following binary relation \(\succeq \) with

$$\begin{aligned} \succeq = \{(1,1),(2,2),(3,3),(1,2), (2,1), (1,3), (2,3)\} \end{aligned}$$
(1)

is a weak order on \(\{1,2,3\}\). Note that the completeness of weak orders implies reflexivity. For each agent i and each two acceptable agents \(x,y\in V(\succeq _i)\) of i, the expression “\(x \succeq _i y\)” means that agent i weakly prefers x over y (i.e., i finds that x is at least as good as y). We use \(\succ _i\) to denote the asymmetric part of \(\succeq _i\) (i.e., \(x\succeq _i y\) and \(\lnot (y\succeq _i x)\), meaning that i strictly prefers x to y) and \(\sim _i\) to denote the symmetric part of \(\succ _i\) (i.e., \(x\succeq _i y\) and \(y \succeq _i x\), meaning that i values x and y equally).

Since a preference order \(\succeq \) can be decomposed into an asymmetric part \(\succ \) and a symmetric part \(\sim \), in the following when we illustrate a preference order, we only describe the \(\succ \) part and the “relevant” \(\sim \) part. For instance, the preference order \(\succeq \) as described in (1) will be depicted as follows:

$$\begin{aligned} \succeq = 1 \sim 2 \succ 3. \end{aligned}$$

Observe that we omitted the relations \(1\sim 1\), \(2\sim 2\), and \(3\sim 3\) for the sake of readability.

We assume that the acceptability relation between each two agents is symmetric, i.e., for each two distinct agents i and j it holds that “i finds j acceptable if and only if j finds i acceptable”, as otherwise i and j will never be partners of each other. Formally, this means that \(i\in V(\succeq _j)\) if and only if \(j \in V(\succeq _i)\). Moreover, since an agent that is not acceptable to any other agent will never obtain a partner, we also assume that for each agent i there is at least another agent \(j\ne i\) with \(i\in V(\succeq _j)\).

We note that although in Stable Roommates an agent cannot be matched to itself, it may still make sense to include an agent x in its own acceptable set, i.e., \(x \in V(\succeq _x)\), for instance when the preferences of x are based on how close or similar agents are to the ideal partner of x and a partner which is “identical” to x itself is an ideal partner of x. This has no implication at this point, because no agent can be matched to itself and “identical clones” do not exist. Allowing this, however, drastically simplifies definitions of restricted preferences in Sect. 2.3, in particular when narcissistic preferences are involved. We call an agent x a most acceptable agent of another agent y if for all \(z \in V(\succeq _y)\setminus \{x,y\}\) it holds that \(x \succeq _y z\), where \(\succeq _y\) denotes the preference order of y. Note that an agent can have more than one most acceptable agent.

Let \(X \subseteq V\) and \(Y \subseteq V\) be two disjoint sets of agents and \(\succeq \) be a binary relation over \(V\times V\). To simplify notation, by \(X\succeq Y\), we mean that for each two agents x and y with \(x\in X\) and \(y \in Y\) it holds that \(x\succeq y\). Analogously, by \(X \succ Y\) and \(X \sim Y\) we mean that for each two agents x and y with \(x\in X\) and \(y \in Y\) it holds that \(x\succ y\) and \(x \sim y\), respectively. For each binary relation symbol \(\star \in \{\succeq , \succ , \sim \}\), we use \(X \star y\) and \(y\star X\) as shortcut for \(X \star \{y\}\) and \(\{y\} \star X\), respectively.

To visualize which agent is considered as acceptable by an agent we introduce the notion of acceptability graphs. An acceptability graph G for a set V of agents is an undirected graph without loops, where an edge signifies that two distinct agents find each other acceptable. We use V to also denote the vertex set of G. Formally, for each agent \(i\in V\), there is a vertex i corresponding to agent i. There is an edge \(\{i,j\}\) in G if \(i \in V(\succeq _j) \setminus \{j\}\) and \(j \in V(\succeq _i)\setminus \{i\}\). As already discussed, we assume without loss of generality that G does not contain isolated vertices as otherwise the corresponding agents will never be able to obtain a partner. We illustrate two prominent special cases of acceptability graphs in Fig. 1.

Fig. 1
figure 1

Acceptability graphs of two special cases of Stable Roommates

2.2 Blocking pairs and stable matchings

Given a preference profile \(\mathcal {P}\) for a set V of agents, a matching \(M\subseteq E(G)\) is a subset of disjoint pairs \(\{x,y\}\) of agents with \(x\ne y\) (or edges in E(G)), where E(G) is the set of edges in the corresponding acceptability graph G. Slightly abusing notation, given an agent \(x\in V\), if there exists an agent \(y\in V\) with \(\{x,y\}\in M\), then we let M(x) \(\,{:}{=}\,y\) and say that x and y are partners of each other (under M); otherwise we let \(M(x)\,{:}{=}\,\bot \). We say that a pair \(\{x,y\}\) is unmatched (under M) if \(\{x,y\}\notin M\). A matching M is perfect if every agent is assigned a partner by M. An unmatched pair \(\{x,y\}\in E(G)\setminus M\) is blocking M if the pair “prefers” to be matched with each other rather than staying in their current state, i.e., it holds that

$$\begin{aligned} ( M(x)=\bot \vee y\succ _x M(x) ) \wedge ( M(y)=\bot \vee x \succ _y M(y))\text {.} \end{aligned}$$

A matching M is stable if no unmatched pair is blocking M. When the preferences may contain ties, our stability concept is sometimes referred to as weak stability in the literature to distinguish from two other stability concepts, called strong stability and super stability [30]. When the preferences do not contain ties, all these three stability concepts are equivalent. In this work, we only focus on weak stability. For the sake of brevity, we thus simply use stability to refer to weak stability.

Example 1

Consider the following profile:

$$\begin{aligned} \begin{array}{rccccccc} \text {agent } 1 :&{} 1 &{} \succ &{} 2 &{} \succ &{} 3 &{} \succ &{} 4,\\ \text {agent } 2 :&{} 2 &{} \succ &{} 3 &{} \succ &{} 1 &{} \succ &{} 4,\\ \text {agent } 3 :&{} 3 &{} \succ &{} 2 &{} \sim &{} 4 &{} \succ &{} 1,\\ \text {agent } 4 :&{} 4 &{} \succ &{} 3 &{} \succ &{} 2 &{} \succ &{} 1.\\ \end{array} \end{aligned}$$

It admits exactly two stable matchings: \(M_1=\{\{1,2\}, \{3,4\}\}\), and \(M_2=\{\{1,4\}\), \(\{2,3\}\}\); both are perfect. However, if agent 3 changes its preference order to \(3\succ 1 \succ 2 \succ 4\), then the resulting profile does not admit any stable matching: One can check that for each matching, any agent i, \(1\le i \le 3\), that is matched to agent 4 will form a blocking pair together with the agent that is at the third position of the preference order of i.

We investigate the computational complexity of the following stable matching problem.

      Stable Roommates

      Input: A preference profile \(\mathcal {P}\) for a set \(V=\{1,2,\ldots , 2n\}\) of 2n agents.

      Question: Does \(\mathcal {P}\) admit a stable matching?

2.3 Properties of a preference profiles

A preference profile \(\mathcal {P}\) may have one ore more of the following three simple properties:

Definition 1

(Completeness preferences with ties) A profile \(\mathcal {P}\) is complete if for each agent \(i\in V\) it holds that \(V(\succeq _i) \cup \{i\} = V\); otherwise it is incomplete. Profile \(\mathcal {P}\) is said to have a tie if there is an agent \(i \in V\) and there are two distinct agents \(x,y \in V(\succeq _i)\) with \(x \sim _i y\).

Note that complete preferences without ties are exactly linear orders on V.

Definition 2

(Narcissism) A profile \(\mathcal {P}\) is narcissistic if each agent i strictly prefers itself to every other acceptable agent, i.e., for each \(j\in V(\succeq _i)\setminus \{i\}\) it holds that \(i \succ _i j\).

The profile given in Example 1 is complete and narcissistic, and contains one tie.

We note that having complete preferences means that any two distinct agents can be matched with each other. Thus, a stable matching must be perfect. As for the narcissistic property alone, there is no restriction on or guarantee for the existence of a stable matching. We will, however, see that requiring some restricted preferences, such as single-peaked or single-crossing preferences as formally defined below, to be also narcissistic makes a difference (see for instance Example 2).

As already discussed in Sect. 1, the single-peaked and the single-crossing properties were originally introduced and studied mainly for linear preference orders (i.e., preferences without ties). For preferences with ties, a natural generalization is to think of a possible linear extension of the preferences for which the single-peaked or single-crossing property holds. We consider this variant in our paper.

Definition 3

(Single-peakedness) Let \(\rhd \) be a linear order on the agent set V. An agent i with preference order \(\succeq _i\) is single-peaked with respect to \(\rhd \) if for each three distinct agents xyz it holds that

$$\begin{aligned} x\rhd y \rhd z \text { and } x\succ _i y \text { implies } y \succeq _i z\text {.} \end{aligned}$$

Accordingly, profile \(\mathcal {P}\) is single-peaked if there exists a linear order \(\rhd \) on V such that each agent from \(\mathcal {P}\) is single-peaked with respect to \(\rhd \). We refer to \(\rhd \) as a single-peaked order of the profile.

Example 2

The profile given in Example 1 is narcissistic and single-peaked with respect to the linear order \(1\rhd 2 \rhd 3 \rhd 4\). See Fig. 2a for an illustration. In fact, as we will see in Sect. 3, a narcissistic and single-peaked preference profile always admits a stable matching.

Recall that if agent 3 changes its preference order to \(3\succ 1 \succ 2 \succ 4\), then the resulting profile does not admit any stable matching and, indeed, it is also not single-peaked anymore.

Just as for the single-peakedness property, the single-crossingness property also requires a natural linear order of the agents, the so-called single-crossing order. However, unlike the single-peakedness property which assumes that the preferences of an agent i over two agents are compared by their “distance” to the peak along the single-peaked order, the single-crossingness property assumes that the agents’ preferences over each two distinct agents change (cross) at most once.

In fact, for preferences with ties, two natural single-crossing notions are of interest. To describe them, we introduce two notions that can be used to partition a subset of agents according to their preferences over two distinct agents. Given a preference profile \(\mathcal {P}=(\succ _i)_{i \in V}\), for each two distinct agents x and y, let

$$\begin{aligned} B_{\mathcal {P}}(x,y)\,{:}{=}\,\{i \in V \mid \succeq _i \in \mathcal {P}\wedge x\succ _i y\} \end{aligned}$$

denote the subset of agents i that strictly prefer x to y (i.e., x is better than y), and let

$$\begin{aligned} T_{\mathcal {P}}(x,y) \,{:}{=}\,\{i \in V \mid \succeq _i \in \mathcal {P}\wedge x \sim _i y\} \end{aligned}$$

denote the subset of agents i that find x and y to be of equal value (i.e., x and y are tied with each). Here, symbol B means “better than” while symbol T means “tied with”.

Definition 4

(Single-crossingness) Let \(\rhd \) be a linear order on the agent set V. A preference profile \(\mathcal {P}=(\succeq _i)_{i\in V}\) is single-crossing with respect to the linear order \(\rhd \) if there exists a preference profile \(\mathcal {P}'=(\succeq '_i)_{i\in V}\) without ties such that the following two conditions hold.

  1. (i)

    For each agent \(i\in V\), the order \(\succeq '_i\) is a linear extension of \(\succeq _i\), i.e., the order \(\succeq '_i\) is a linear order on the acceptable set \(V(\succeq _i)\) with \(\succ _i \subseteq \succ '_i\).

  2. (ii)

    For each two distinct agents \(x,y\in V\) it holds that \(T_{\mathcal {P}'}(x,y)=\emptyset \) such that either \(B_{\mathcal {P}'}(x,y)\rhd B_{\mathcal {P}'}(y,x)\) or \(B_{\mathcal {P}'}(y,x)\rhd B_{\mathcal {P}'}(x,y)\).

Accordingly, profile \(\mathcal {P}\) is single-crossing if there exists a linear order \(\rhd \) on the agent set V such that \(\mathcal {P}\) is single-crossing with respect to \(\rhd \).

Example 3

The profile from Example 1 is single-crossing with respect to the linear order \(1 \rhd 2 \rhd 3 \rhd 4\). See Fig. 2b for an illustration.

Fig. 2
figure 2

Illustration of the profile from Example 1 which has complete preferences, contain ties, and are narcissistic, single-peaked, and (tie-sensitive) single-crossing

We also consider a more restricted concept of single-crossingness which requires that the agents that have ties towards a pair are “ordered in the middle”.

Definition 5

(Tie-sensitive single-crossingness) Again, let \(\rhd \) be a linear order on the agent set V. A profile \(\mathcal {P}\) on V is tie-sensitive single-crossing with respect to the order \(\rhd \) if for each two distinct agents x and y it holds that

$$\begin{aligned} \text {either } B_{\mathcal {P}}(x,y) \rhd T_{\mathcal {P}}(x,y) \rhd B_{\mathcal {P}}(y,x) \text { or } B_{\mathcal {P}}(y,x) \rhd T_{\mathcal {P}}(x,y) \rhd B_{\mathcal {P}}(x,y). \end{aligned}$$

See Fig. 3 for an illustration of the different types of restricted preferences for the case where the input preference orders are complete and contain no ties.

Fig. 3
figure 3

Visualization of preference profiles with different structural properties

2.4 Basic observations for the structural properties of preferences

Incomplete preferences with ties, i.e., weak orders, as used in this work are incomparable to partial orders because partial orders are antisymmetric. However, the asymmetric part of a weak order is indeed a partial order. There are many slightly different concepts of single-peakedness and single-crossingness for partial orders [20, 25, 37]. It is known that detecting single-peakedness or single-crossingness is NP-hard for partial orders under most of the concepts studied in the literature [2, 4, 8, 18, 19, 22]. For partial orders, our two single-crossing concepts are incomparable. In particular, there are incomplete preferences with ties which are single-crossing but not tie-sensitive single-crossing, and the converse also holds. For complete preferences with ties which is a restricted case of partial orders, Elkind et al. [20] showed that tie-sensitive single-crossing preference profiles are a strict subset of single-crossing preference profiles. In the following, we extend these results by considering the case when the preferences can be incomplete.

Proposition 1

  1. (1)

    For preferences without ties, tie-sensitive single-crossing ness is equivalent to single-crossingness.

  2. (2)

    For preferences with ties, single-crossingness does not always imply tie-sensitive single-crossing ness.

  3. (3)

    For preferences with ties, tie-sensitive single-crossing ness implies single-crossingness.

Proof

Statement (1) follows from the observation that when a profile does not have any ties, the definitions of single-crossingness (Definition 4) and tie-sensitive single-crossingness Definition 5 coincide. The preference profile given in Fig. 3b is single-crossing but not tie-sensitive single-crossing , which shows Statement (2).

It remains to show Statement (3). Let \(\mathcal {P}=(\succeq _i)_{i\in V}\) be a profile which is tie-sensitive single-crossing with respect to some linear order \(\rhd \) on V. We resolve the ties in the preferences given in \(\mathcal {P}\) according to an arbitrary but fixed order on V and show that this extended profile fulfills the conditions given in the definition for tie-sensitive single-crossingness (see Definition 5). To this end, let \(\blacktriangleright \) be an arbitrary but fixed linear order on V and let \(\mathcal {P}'=(\succeq '_i)_{i\in V}\) be a copy of the profile \(\mathcal {P}\) with \(\succeq '_i=\succeq _i\), \(i\in V\). For each agent \(i\in V\) and for each pair \(\{x,y\}\subseteq V(\succeq _i)\) of agents acceptable to i such that \(x\sim _i y\), let \(x \succ '_i y\) (i.e., delete (xy) from \(\succeq '_i\)) if and only if \(x \blacktriangleright y\). In this way, for each agent i and for each two distinct agents \(x,y \in V(\succeq _i)\) acceptable to i, we have that

$$\begin{aligned} x \succ '_i y \text { implies } x \succeq _i y, \end{aligned}$$
(2)

since the preference order \(\succeq _i\) is a weak order on \(V(\succeq _i)\).

First of all, we claim that \(\mathcal {P}'\) fulfills the first condition given in Definition 4. For the sake of contradiction, suppose that there is an agent i such that \(\succeq '_i\) is not a linear extension of \(\succeq _i\). Observe that by our construction, \(\succeq '_i\) is a complete binary relation on \(V(\succeq _i)\). Moreover, for each two acceptable agents \(x, y \in V(\succeq _i)\) it holds that \(x\succ _i y\) implies that \(x \succ '_i y\). Hence, the assumption that \(\succeq '_i\) is not a linear extension of \(\succeq _i\) means that \(\succ '_i\) is not transitive, i.e., there are three acceptable agents \(x,y,z\in V(\succeq _i)\) with

$$\begin{aligned} x\succ '_i y\text {, } y\succ '_i z\text {, and }z\succ '_i x. \end{aligned}$$
(3)

By Property (2), we infer that \(x\succeq _i y\), \(y \succeq _i z\), and \(z \succeq _i x\). By the transitivity of \(\succeq _i\), these three relations imply that \(x\sim _i y\), \(y \sim _i z\), and \(z \sim _i x\).

This means that the pairwise relative orders of xyz in \(\succeq '_i\) are resolved according to the order \(\blacktriangleright \), i.e., \(x\blacktriangleright y\), \(y\blacktriangleright z\), and \(z\blacktriangleright x\)—a contradiction to \(\blacktriangleright \) being transitive.

It remains to show that \(\mathcal {P}'=(\succeq '_i)_{i\in V}\) is single-crossing with respect to \(\rhd \). Suppose towards a contradiction that \(\mathcal {P}'\) is not single-crossing with respect to \(\rhd \), and suppose that there are three agents ijk in the order \(i\rhd j \rhd k\) and there are two acceptable agents \(x,y\in V(\succeq '_i)\cap V(\succeq '_j) \cap V(\succeq '_k)\) such that

$$\begin{aligned} x\succ '_i y, y\succ '_j x\text {, and }x \succ '_k y. \end{aligned}$$
(4)

By Property (2), we infer that

$$\begin{aligned} x\succeq _i y{, } y\succeq _j x, \text { and } x \succeq _k y. \end{aligned}$$
(5)

We distinguish between two cases for \(x \succeq _j y\), in each case aiming at reaching a contradiction.

If \(x\sim _j y\), then by (4) it follows that \(y \blacktriangleright x\) and that \(\lnot (y\sim _i x)\) and \(\lnot (y \sim _k x)\). Thus, by (5), it follows that \(x \succ _i y\) and \(x\succ _k y\)—a contradiction to \(\rhd \) being a tie-sensitive single-crossing order for \(\mathcal {P}\).

If \(y \succ _j x\), then since \(\rhd \) is a tie-sensitive single-crossing order for \(\mathcal {P}\), by (5) it follows that \(\lnot (x\succ _i y)\) or \(\lnot (x \succ _k y)\). This implies that \(x\sim _i y\) or \(x \sim _k y\). If \(x \sim _i y\), then \(y \succ _k x\)—a contradiction to (5). If \(x \sim _k y\), then \(y \succ _i x\)—again a contradiction to (5).\(\square \)

For incomplete preferences with ties, Lackner [37] showed that detecting single-peakedness is NP-complete. For complete preferences with ties, while Elkind et al. [20] showed that detecting single-crossingness is NP-complete, Fitzsimmons [24] and Elkind et al. [20] provided polynomial-time algorithms for detecting single-peakedness and ties-sensitive single-crossingness, respectively. All these known hardness results seem to hold only when the preferences have ties. However, we observe that the hardness reduction for Corollary 6 of Elkind et al. [20] indeed can be adapted to show NP-hardness for deciding whether an incomplete preference profile without ties is single-peaked (resp. single-crossing). The crucial differences are that they allow ties and that the agents and the alternatives are different while we do not allow ties and our agent set is the same as the set of alternatives. For the sake of completeness, we show this adapted reduction.

Proposition 2

Deciding whether a preference profile with incomplete preferences and without ties is single-crossing (or equivalently tie-sensitive single-crossing) or single-peaked is NP-complete.

Proof

The three decision problems are clearly contained in NP as given a linear order \(\rhd \) on the agent set one can verify in polynomial-time whether the given preference profile is single-crossing, tie-sensitive single-crossing, or single-peaked with respect to the order \(\rhd \); note that the preferences do not contain ties.

To show NP-hardness, as Elkind et al. [20], we reduce from the NP-hard Betweenness problem [46]:

      Betweenness

      Input: Given a universe \(U= \{u_1,\ldots ,u_n\}\) and a set \(T=\{t_1,\ldots ,t_m\}\) of ordered triples over U.

      Question: Is there a betweenness order \(\blacktriangleright \), that is, a total linear order over U such that for each triple (xyz) from T it holds that either \(x \blacktriangleright y \blacktriangleright z\) or \(z \blacktriangleright y \blacktriangleright x\)?

The reduction for the single-peaked case is quite simple while the reduction for the single-crossing case is similar to the one used by Elkind et al. [20, Corollary 6].

The single-peakedness case. Given an instance \(I=(U,T)\) of Betweenness, where \(U=\{u_1,\ldots ,u_n\}\) and \(T=\{t_1,\ldots ,t_m\}\), we construct a preference profile \(\mathcal {P}=(\succ _x)_{x\in V}\) for an agent set V, whose preferences contain no ties but may be incomplete; without loss of generality we assume that the elements in each ordered triple \((x,y,z)\in T\) are pairwise distinct.

The agent set V has two types of agents, which sum up to \(n+2m\) agents. First, for each element \(u_i\) add to V an element agent with the same name. Second, for each triple \(t_j=(x,y,z)\) from T (with \(x,y,z \in U\)) add to V two agents \(a_j\) and \(a'_j\). We will construct the preference orders of \(a_j\) and \(a'_j\) to ensure that the second element y in triple \(t_j\) is ordered between the other two elements x and y in a betweeness order.

The preference orders of the agents are constructed as follows:

  • Each element agent \(u_i \in U\) only finds those agents acceptable that “contain” \(u_i\), and has a linear order on these acceptable agents that are consistent with the following order

    $$\begin{aligned} L\,{:}{=}\,a_1 \succ \cdots \succ a_m \succ a'_1 \succ \cdots \succ a'_m. \end{aligned}$$

    Formally, the preference order of agent \(u_i\) is

    $$\begin{aligned} \succ _{u_i}:[A(u_i)] \succ [A'(u_i)], \end{aligned}$$

    where \(A(u_i)=\{a_j\mid u_i \in t_j\}\) (resp. \(A'(u_i)=\{a'_j\mid u_i \in t_j\}\)) and \([A(u_i)] \succ [A'(u_i)]\) is a linear order on \(A(u_i) \cup A'(u_i)\) that respects L.

  • For each triple \(t_j=(x,y,z) \in T\), the preference orders of \(a_j\) and \(a'_j\) are

    $$\begin{aligned} \succ _{a_j}:y \succ x \succ z \text { and } \succ _{a'_j}:y \succ z \succ x. \end{aligned}$$

We show that \(\mathcal {P}\) is single-peaked if and only if the given instance is a yes-instance. On the one hand, every betweenness order \(\blacktriangleright \) for \(I=(U,T)\) can be extended to a single-peaked order for \(\mathcal {P}\) by appending to \(\blacktriangleright \) the order L. On the other hand, note that the preference orders of the agents of the second type require a single-peaked order to place element y in between x and z. Thus, a single-peaked order \(\rhd \) for \(\mathcal {P}\) restricted to U is also a betweenness order for (UT).

The single-crossingness and tie-sensitive single-crossingness case. Since for preferences without ties, single-crossingness is equivalent to tie-sensitive single-crossingness  (see Proposition 1(1)) we only focus on the single-crossingness case. Given an instance \(I=(U,T)\) of Betweenness, where \(U=\{u_1,\ldots ,u_n\}\) and \(T=\{t_1,\ldots ,t_m\}\), we construct a preference profile \(\mathcal {P}=(\succ _x)_{x\in V}\) for an agent set V, whose preferences contain no ties but may be incomplete; without loss of generality we assume that the elements in each ordered triple \((x,y,z)\in T\) are pairwise distinct.

The agent set V has two types of agents, which sum up to \(n+3m\) agents. First, for each element \(u_i\) add to V an element agent with the same name. Second, for each triple \(t_j=(x,y,z)\) from T (with \(x,y,z \in U\)) add to V three agents \(a_j,b_j, c_j\). Again, we will construct the preference orders of \(a_j, b_j\), and \(c_j\) to ensure that the second element y is ordered between the other two elements x and z. Before we describe how to construct the preference orders, let us describe the acceptable set of each agent: For each triple \(t_j=(x,y,z)\) from T (with \(x,y,z \in U\)) let

$$\begin{aligned} V(\succ _{a_j})=V(\succ _{b_j})=V(\succ _{c_j})\,{:}{=}\,\{x,y,z\}. \end{aligned}$$

Symmetrically, for each element agent \(u\in U\), let \(V(u) \,{:}{=}\,\{a_j,b_j,c_j \mid u \in t_j\}\). For ease of notation, for each triple \(t_j\in T\), let \(T_j \,{:}{=}\,\{a_j,b_j,c_j\}\).

The preference orders of the agents are constructed as follows:

  • For each triple \(t_j =(x,y,z)\) from T, the preference orders of agents \(a_j\), \(b_j\), and \(c_j\) are the same linear order on \(\{x,y,z\}\), which is ascending on the indices of xyz in U.

  • For each element agent \(u\in U\), construct the preference order \(\succ _u\) of u such that for each two triples \(t_j\) and \(t_{j'}\) with \(j < j'\) that contain the element u it holds that

    $$\begin{aligned} \succ _u:T_j \succ T_{j'}. \end{aligned}$$

    The specific order on the triple agents in \(T_j\) (resp. \(T_{j'}\)) depends on the position of u in the triple \(t_j\). To this end, let

    $$\begin{aligned} L_j^x&\,{:}{=}\,a_j \succ b_j \succ c_j,\\ L_j^y&\,{:}{=}\,b_j \succ a_j \succ c_j,\\ L_j^z&\,{:}{=}\,c_j \succ b_j \succ a_j. \end{aligned}$$

    To make the preference order of u a linear order, for each triple \(t_j\in T\) with \(t_j=(x,y,z)\) that contains the element u, let \(\succ _u\) obey the order \(L_j^{k}\) if and only if \(u=k\).

We show that \(\mathcal {P}\) is single-crossing if and only if the given instance is a yes-instance. On the one hand, a single-crossing order \(\rhd \) for the constructed profile restricted to U is a betweenness order for (UT): For every triple \(t_j=(x,y,z)\) from T the preference orders of x, y, and z restricted to \(T_j\) imply that either \(x \rhd y \rhd z\) or \(z \rhd y \rhd x\). On the other hand, a betweenness order \(\blacktriangleright \) for (US) can be extended to a single-crossing order for the constructed profile by appending the order \(\blacktriangleright a_1 \blacktriangleright b_1 \blacktriangleright c_1 \blacktriangleright \cdots \blacktriangleright a_m \blacktriangleright b_m \blacktriangleright c_m\) to its end. \(\square \)

Saporiti and Tohmé [52] showed that for complete preferences without ties, narcissistic and single-crossing preferences are also single-peaked. We strengthen this result by showing that the relation also holds when ties are allowed. Further, we note that although Barberà and Moreno [3] also considered complete preferences with ties, their single-crossingness for the case with ties only resembles our tie-sensitive single-crossing definition, which is a strict subset of the single-crossingness defined in Definition 4 (also see Proposition 1(2)–(3)).

Proposition 3

If a complete, even with ties, and narcissistic preference profile \(\mathcal {P}\) admits a single-crossing order \(\rhd \), then this order \(\rhd \) is also a single-peaked order.

Proof

Suppose for the sake of contradiction that \(\rhd \) with \(a_1\rhd a_2 \rhd \dots \rhd a_{2n}\) is not single-peaked. This means that there exists an agent \(a_i\) that is not single-peaked with respect to \(\rhd \), and there are three agents \(a_j,a_k,a_\ell \) with \(a_j \rhd a_k \rhd a_{\ell }\) such that \(a_j\succ _{a_i} a_k\) and \(a_\ell \succ _{a_i} a_k\). Together with the property of being narcissistic, the following holds:

$$\begin{aligned} \text {agent } a_i:&a_i \succ _{a_i} a_{j} \succ _{a_i} a_{k} \text { and } a_i \succ _{a_i} a_{\ell } \succ _{a_i} a_{k},&\quad \text {agent } a_j:&a_j \succ _{a_j} a_k,\\ \text {agent } a_k:&a_k \succ _{a_k} a_j \text { and } a_k \succ _{a_k} a_{\ell },&\quad \text {agent } a_\ell :&a_\ell \succ _{a_\ell } a_k\text {.} \end{aligned}$$

On the one hand, the agents’ preferences over the pair \(\{a_j, a_k\}\) implies that \(i < k\). On the other hand, the pair \(\{a_k, a_\ell \}\) implies that \(i > k\)—a contradiction. \(\square \)

The profile shown in Fig. 2 is narcissistic and single-crossing with respect to the order \(1\rhd 2 \rhd 3 \rhd 4\) and it is also single-peaked with respect to the same order \(\rhd \).

There is no direct relation between single-peakedness and single-crossingness, even if the profile is complete and do not contain ties [9].

Proposition 4

Even for complete preference profiles without ties, single-peakedness does not imply single-crossingness. Neither does single-crossingness imply single-peakedness.

Proof

The statements are indicated in [9, Figure 1]. For the sake of completeness, however, we show the statements through the following two concrete profiles.

Consider the following profile with four agents 1, 2, 3, 4:

$$\begin{aligned} \text {Profile~}\mathcal {P}_1:&\text {agent}~1:1 \succ 2 \succ 3 \succ 4,\qquad \text {agent}~2:2 \succ 1 \succ 3 \succ 4, \\&\text {agent}~3:1 \succ 2 \succ 4 \succ 3, \qquad \text {agent}~4:2 \succ 1 \succ 4 \succ 3. \end{aligned}$$

One can verify that profile \(\mathcal {P}_1\) has complete preferences without ties, and is single-peaked with respect to the linear order \(3 \rhd 1 \rhd 2 \rhd 4\). However, it is not single-crossing because agents 1, 2, 3, and 4 form a forbidden configuration of single-crossingness [8].

Consider the following profile with four agents 1, 2, 3, 4:

$$\begin{aligned} \text {Profile~}\mathcal {P}_2:&\text {agent}~1:1 \succ 2 \succ 3 \succ 4,\qquad \text {agent}~2:1 \succ 2 \succ 3 \succ 4, \\&\text {agent}~3:1 \succ 4 \succ 3 \succ 2, \qquad \text {agent}~4:1 \succ 4 \succ 3 \succ 2. \end{aligned}$$

Since there are only two different preference orders, profile \(\mathcal {P}_2\) is obviously single-crossing, for instance, with respect to the linear order \(1\rhd 2\rhd 3\rhd 4\). However, it is not single-peaked since agent 1 and agent 3 form a forbidden configuration of single-peakedness [2]. \(\square \)

3 Complete preferences

In this section, we analyze the computational complexity of Stable Roommates for the case when the input preference profiles have complete and structured preferences. In particular, we show that the NP-hard Stable Roommates problem with ties allowed becomes polynomial-time solvable when the preferences are narcissistic and either single-crossing or single-peaked.

For the case of complete, narcissistic, and single-peaked preferences without ties, Bartholdi III and Trick [4] showed that there is always a unique stable matching and provided an algorithm to find it. Their algorithm is based on the following two facts (referred to as Propositions 5 and 6) that are related to the concept of most acceptable agents. We show that the facts transfer to the case with ties.

Proposition 5

If the given preference profile \(\mathcal {P}\) is complete (even with ties), narcissistic, and single-peaked, then there are two distinct agents ij that are each other’s most acceptable agents.

Proof

The statement for complete, narcissistic, and single-peaked preferences without ties was shown by Bartholdi III and Trick [4]. It turns out that this also holds for the case when ties are allowed. Let V be the set of all 2n agents and consider a single-peaked order \(\rhd \) of the agents V with \(x_1\rhd x_2\rhd \dots \rhd x_n\). For each agent \(x\in V\), let \(M_x\) be the set of all most acceptable agents of x. Towards a contradiction, suppose that each two distinct agents x and y have \(x\notin M_y\) or \(y\notin M_x\). By the narcissistic property and single-peakedness, each \(M_x\cup \{x\}\) forms an interval in \(\rhd \). This implies that the first agent \(x_1\) and the last agent \(x_n\) in the order \(\rhd \) have \(x_2\in M_{x_1}\) and \(x_{n-1} \in M_{x_n}\). By our assumption (\(x\notin M_y\) or \(y\notin M_x\)), however, \(x_2 \in M_{x_1}\) implies that for each \(i\in \{2,\dots , n\}\) the following holds: \(x_{i-1}\notin M_{x}\)—a contradiction to \(x_{n-1}\in M_{x_n}\). \(\square \)

By the stability definition, we obtain the following for complete preferences.

Proposition 6

Let \(\mathcal {P}\) be a preference profile with complete preferences and let M be a stable matching for \(\mathcal {P}\). Let \(\mathcal {P}'\) be a preference profile resulting from \(\mathcal {P}\) by adding two agents xy who consider each other as most acceptable (and their preferences over other agents and the preferences of other agents over xy are arbitrary but fixed, respectively). Then, matching \(M\cup \{\{x, y\}\}\) is stable for \(\mathcal {P}'\).

Proof

Suppose for the sake of contradiction that \(M\cup \{\{x, y\}\}\) is not stable for \(\mathcal {P}'\). This means that \(\mathcal {P}'\) has a blocking pair \(\{u,w\}\notin M\). Obviously, \(|\{u,w\}\cap \{x,y\}| = 1\) as otherwise \(\{u,w\}\) would also be a blocking pair for \(\mathcal {P}\). Assume without loss of generality that \(u = x\). Then, by the definition of blocking pairs, it must hold that \(w \succ _x y\)—a contradiction to y being one of the most acceptable agents of x. \(\square \)

figure i

Utilizing restricted versions of Propositions 5 and 6, Bartholdi III and Trick [4] derived a greedy algorithm to construct a unique stable matching when the preferences are linear orders (i.e., complete and without ties) and are narcissistic and single-peaked (see Algorithm 1). For 2n agents they claimed that their algorithm runs in O(n) time by observing that, after adding a pair to the solution matching, at most two other agents need to update their most acceptable agent. However, since updating the most acceptable agent may take O(n) time, it is not clear how to implement their algorithm to achieve O(n) running time. Indeed, by generalizing their example Bartholdi III and Trick [4, Section 3] to the case with 2n agents, we show the following: Assuming, as input, an integer vector for each agent is given, which lists the agents in order of its preferences, their algorithm may take \(O(n^2)\) time, even if the single-peaked order is known.

Example 4

We consider a complete, narcissistic, single-peaked, and single-crossing preference profile \(\mathcal {P}_n\) without ties, for 2n agents. The preference orders will be pasted together from the following “preference pieces” \(X_i\) and \(Y_i\) with \(i \in [n]\):

$$\begin{aligned} X_i&\,{:}{=}\,i+1 \succ i+2 \succ \cdots \succ 2n-i, \text { and }\\ Y_i&\,{:}{=}\,i \succ 2n+1-i. \end{aligned}$$

Note that for every \(i\in [n]\), the piece \(X_i\) covers contiguous interval of \(2n-2i\) alternatives. Together with the pieces \(Y_1\), \(Y_2\), \(\ldots \), \(Y_{i-1}\), all but two alternatives are covered: i and \(2n+1-i\) are the only alternatives that are not covered.

Now, let us define the preference orders of the agents in the profile. For each \(i\in [n]\) the two agents i and \(2n+1-i\) have “almost” opposite preferences:

where \(\overleftarrow{X_i}\) and \(\overleftarrow{Y_j}\) (\(j\in [i-1]\)) denote the reverse preference orders of \({X_i}\) and \({Y_j}\), respectively.

Observe that, for \(i = 1\), the preference pieces \(Y_{i-1}\succ Y_{i-2} \succ \ldots \succ Y_1\) and \(\overleftarrow{Y_{i-1}}\succ \overleftarrow{Y_{i-2}} \succ \ldots \succ \overleftarrow{Y_1}\) are empty. Thus, the first agent and the last agent have reverse preference orders \(1\succ 2 \succ \cdots \succ 2n\) and \(2n\succ 2n-1 \succ \cdots \succ 1\), respectively.

For \(n=3\), the corresponding preference profile \(\mathcal {P}_3\) looks as follows:

Single-peakedness and single-crossingness. Profile \(\mathcal {P}_n\) is single-peaked and single-crossing with respect to the canonical order \(1\rhd 2 \rhd \ldots \rhd 2n\). To see why it is single-crossing with respect to this order, we observe the following, which covers all possible pairs of agents:

  • For each agent \(i \in [n-1]\) and each agent \(j \in [2n-i]\setminus [i]\), all agents from [i] prefer i to j while all agents from \([2n]\setminus [i]\) prefer j to i.

  • For each agent \(k \in [2n]\setminus [n+1]\) and each agent \(j\in [k-1]\setminus [2n+1-k]\), all agents from \([k-1]\) prefer j to k while all agents from \([2n]\setminus [k-1]\) prefer k to j.

  • For each agent \(z \in [n]\), all agents from [n] prefer z to \(2n+1-z\) while all agents from \([2n]\setminus [n]\) prefer \(2n+1-z\) to z.

This profile contains a unique stable matching M with

$$\begin{aligned} M = \{\{i,2n+1-i\} \mid i \in [n]\}. \end{aligned}$$

Running time of Bartholdi III and Tricks’ algorithm (see Algorithm 1). First, observe that due to the preference orders of agents 1 and 2n, the canonical order \(\rhd \) as described above is the unique single-peaked order (up to reversal). Hence, let us assume that the preference orders of \(\mathcal {P}_n\) and the order \(\rhd \) are given as input. Applying the algorithm of Bartholdi III and Trick [4] (see Algorithm 1), in the first round, each agent \(i\in [n]\) regards its “successor agent” \(i+1\) (along \(\rhd \)) as the most acceptable agent while each agent \(k\in [2n]\setminus [n]\) regards its “predecessor agent” \(k-1\) (along \(\rhd \)) as the most acceptable agent. Thus, in this round, agents n and \(n+1\) are the only agents that regard each other as most acceptable. We find them in O(n) time and add \(\{n,n+1\}\) to M.

In the second round, agents \(i\,{:}{=}\,n-1\) and \(j\,{:}{=}\,n+2\) have to update their most acceptable agents since their currently most acceptable ones are matched with each other. But the updating time of each agent depends on the number of pairs that are already in the solution M no matter what \(\rhd \) looks like since in general the “successor” or “predecessor” of i or j might already have been matched in some previous round. For agents \(n-1\) and \(n+2\), we need to traverse to the third agent in their preference orders to find one which are unmatched. In this case, \(n-1\) and \(n+2\) find each other most acceptable after \(\{n,n+1\}\) is added to M.

For our profile, in round z, starting from \(z=2\), we need to update the most acceptable agents of agents \(n-z+1\) and \(n+z\) since the pair \(\{n-z+2, n+z-1\}\) is added to M in round \(z-1\). To update, we need to go through the preference orders of \(n-z+1\) and \(n+z\) until we find a next most acceptable and not-yet-matched agent. This takes O(z) time because both agents \(n-z+1\) and \(n+z\) have not updated their most acceptable agents but prefer all matched agents to their next most acceptable and not-yet-matched one. Summarizing, we need \(O(n+2+4+\ldots +2n)=O(n^2)\) time to construct a unique stable matching, if we assume that the input contains the preference orders of all agents (implemented as integer vectors) and a single-peaked order of the agents.

For the case with ties, we will show that Algorithm 1 also works for narcissistic, single-peaked profiles. In particular, there is always a stable matching, albeit perhaps not unique.

Proposition 7

A complete, narcissistic, single-peaked, and (tie-sensitive) single-crossing preference profile with ties may admit more than one stable matching.

Proof

To show the statement, let us consider the following profile:

$$\begin{aligned} \begin{array}{rccccccc} \text {agent}~1 :&{} 1 &{} \succ &{} 2 &{} \sim &{} 3 &{} \sim &{} 4,\\ \text {agent}~2 :&{} 2 &{} \succ &{} 1 &{} \sim &{} 3 &{} \sim &{} 4,\\ \text {agent}~3 :&{} 3 &{} \succ &{} 1 &{} \sim &{} 2 &{} \sim &{} 4,\\ \text {agent}~4 :&{} 4 &{} \succ &{} 1 &{} \sim &{} 2 &{} \sim &{} 3.\\ \end{array} \end{aligned}$$

Since each agent regards every other agent as equally good, any perfect matching is a stable matching. Since the profile is complete and has four agents, there are \(\left( {\begin{array}{c}4\\ 2\end{array}}\right) /2=3\) perfect matchings which are all stable. It is also straight-forward to verify that the profile is narcissistic, single-peaked, and (tie-sensitive) single-crossing with respect to the order \(1\rhd 2 \rhd 3 \rhd 4\). \(\square \)

Next, we show that the idea behind Bartholdi III and Trick’s algorithm (see Algorithm 1) also works for the case with ties.

Theorem 1

If a preference profile with 2n agents is complete, possibly with ties, narcissistic and single-peaked, then it always admits a stable matching, which can be found in \(O(n^2)\) time.

Proof

To show that such a profile \(\mathcal {P}\) always admits a stable matching, we show that on input \(\mathcal {P}\) Algorithm 1 always returns a matching of \(\mathcal {P}\) which is stable. Indeed, the latter follows directly from Propositions 5 and 6 and the narcissistic and single-peaked property is preserved after deleting any agent.

As for the running time, there are n rounds to build up M, and in each round we find two distinct agents x and y whose most acceptable agent sets \(M_x\) and \(M_y\) (in the updated profile) include x respectively y:

$$\begin{aligned} x\in M_y \text { and } y\in M_x. \end{aligned}$$
(6)

Note that Proposition 5 implies that two such agents exist. One way to search for two such agents is to go through all pairs \(\{x,y\}\) and check whether Condition (6) holds. This leads to an algorithm with running time \(O(n^3)\). To obtain an \(O(n^2)\)-time algorithm, however, we observe that we only need to check an agent pair \(\{x,y\}\) upon Condition (6) when the most acceptable agents of one of x and y, say x, are all matched (in previous rounds) such that y is the next less preferred agent by x. This guarantees that we have to check each pair of agents at most twice, once for x and once for y. In total, we can find a stable matching in \(O(n^2)\) time.

We describe this idea in Algorithm 2 (see ComputeStableMatching()), which uses only simple data structures such as integer matrices and vectors.

As input, we assume that for each agent x there is an integer vector \(L_x\) that lists the agents in order of the preferences of x, with ties resolved in an arbitrary way. Moreover, we assume to have an \(n \times n\) integer rank matrix R where R[xy] contains the rank of agent x in the preference list of agent y. Herein, the rank of agent y in agent x’s preference list is defined as the number of agents that are strictly preferred to y by x. For example, if the preference list of agent 1 is \(1 \succ 2 \succ 3 \sim 4 \succ 5 \sim 6 \succ 7\), then we may have \(L_1=[1,2,3,4,5,6,7]\) and have \(R[1,1] = 0\), \(R[1,2]=1\), \(R[1,3]=2\), \(R[1,4]=2\), \(R[1,5]=4\), \(R[1,6]=4\), and \(R[1,7]=6\).

figure j

Before we show the correctness of Algorithm 2, we first claim the following. Each call of InsertMostPreferred(z)

  1. (a)

    assumes \(D[z]=0\),

  2. (b)

    finds all unmatched agents \(y'\) which are tied with agent \(L_z[p_z]\) and sets \(A[z,y']=1\) (Lines (17)–(23)), and

  3. (c)

    pushes a possible matching event \(\{z,y'\}\) to Q if, additionally, \(y'\) also finds z most acceptable (Lines (20)–(21)).

For the first calls of InsertMostPreferred(z) in Line (5), the above invariant is straight-forward to verify: The matrix A and the vector D are initialized with all-zero entries, and \(p[z]\) points to a position in the preference list \(L_z\) of z such that InsertMostPreferred(z) goes through the preference list \(L_z\) of z, using pointer \(p[z]\), and finds all most acceptable agents of z, updating the row A[z], until \(p[z]\) points to a position which contains an agent that is strictly less preferred.

For each following execution of InsertMostPreferred(z), observe that the procedure is only called when \(D[z]=0\) and when \(B[z]=0\). Since B[z] is increased whenever some entry A[zx] is set from zero to one and decreased whenever some entry A[zx] is set from one to zero, this implies that \(A[z,x]=0\) holds for each agent \(x\in V\) when the procedure is called. Moreover, at the beginning of the execution of InsertMostPreferred(z) (except the first call), integer \(p_z\) points to the position of the first agent in the list \(L_z\) that is strictly less preferred than all agents that were previously inserted into A. Now, whenever called, InsertMostPreferred(z) uses \(p[z]\) to continue iterating through the preference list \(L_z\). Only unmatched agents \(L_z[p[z]]\) (see Line (17)) that are most-preferred by z are inserted into the matrix A by setting \(A[z,y']=1\) until either the end of the the preference list \(L_z\) is reached (i.e., \(p[z]=n+1\)), or at least one agent was inserted (i.e., \(B[z]>0\)) such that \(p_z\) points to the position of an agent that is strictly less preferred to the just inserted agent (stored as \(y'\)).

Now, to show the correctness of Algorithm 2, we need to show

  1. (i)

    whenever Algorithm 2 adds a pair \(\{x,y\}\) to M, then x and y indeed are each other’s most acceptable agents (under the profile where all pairs previously added to M are deleted), and

  2. (ii)

    there is always a possible pair in the queue Q where both agents are still unmatched.

To verify (i), clearly, the first pair that is added to M satisfies (i). Assume that \(\{x_i,y_i\}\) is the \(i^{\text {th}}\) pair added to M such that all \(i-1\) previous pairs \(q_1,\ldots , q_{i-1}\) added to M satisfy (i). Suppose, for the sake of contradiction, that \(y_i\) is not one of the most acceptable agents of \(x_i\), after all agents in the pairs \(q_1,\ldots ,q_{i-1}\) are deleted from the profile. Let y be a not-yet-matched agent that is strictly preferred to \(y_i\) by \(x_i\). Now, consider the call InsertMostPreferred when \(\{x_i,y_i\}\) is pushed to Q. By (b) and since \(p_z\) is none-decreasing, it follows that \(\{x_i,y\}\) is added to Q in a previous round. This means that \(\{x_i,y\}\) must be considered before \(\{x_i,y_i\}\) in the queue Q and will thus be added to M, a contradiction.

As for (ii), observe that whenever the algorithm pops a pair from Q, the queue Q contains every pair of agents that currently consider each other most acceptable (see (b) and (c)). The queue Q may contain further pairs of agents where one or both agents are already deleted; these pairs, however, will be detected (Line (8)) and ignored by the algorithm. Thus, the existence follows analogously to the one for Algorithm 1. Finally, we analyze the running time. First of all, every agent x is deleted (by calling SmartDelete(x)) at most once. Each call of SmartDelete(x) takes O(n) steps (some constant number of operations, adjusting one row and one column in A, each of size n), plus some calls of InsertMostPreferred. Second, InsertMostPreferred takes amortized O(n) running time for each agent z since it iterates through the preference list of z only once. Third, after the initialization, every entry A[xy] is set from zero to one at most once (see Line (19)), which happens only when A[xy] was zero. It is reset to zero at most once, which happens only when SmartDelete(x) or SmartDelete(y) is called and when A[xy] was one (see Lines (27) and (29)). Since \(\{x,y\}\) is only pushed to Q in InsertMostPreferred(x) or InsertMostPreferred(y) when \(A[x,y]=A[y,x]=1\) and \(D[x]=D[y]=0\) (see (a) in the above reasoning and Lines (17), (19), and (20)), it follows that \(\{x,y\}\) can be pushed to the queues Q at most once. Since there are \(O(n^2)\) pairs that can be added to Q and since SmartDelete is only called whenever a pair is added to M, ComputeStableMatching indeed takes \(O(n^2)\) time. \(\square \)

Now, we move on to (tie-sensitive) single-crossingness.

Proposition 8

If a preference profile with 2n agents is complete, with ties, narcissistic and single-crossing, then it always admits a stable matching, which can be found in \(O(n^2)\) time.

Proof

By Theorem 3 and Proposition 1(1), the stated profiles are single-peaked. By Theorem 1, we obtain the desired statement. \(\square \)

4 Incomplete preferences

In this section, we consider the case when the input may contain incomplete preferences, meaning that the underlying acceptability graph may not be a complete graph. One reason for the occurrence of incomplete preferences could be that two agents may consider each other unacceptable and do not want to be matched together, or they are not “allowed” to be matched to each other. If in this case no two agents are considered of equal value by any agent (i.e., the preferences do not have ties), then Stable Roommates still remains polynomial-time solvable [30]. However, once ties are involved, Stable Roommates becomes NP-complete [48] even for complete preferences.

First of all, we observe that once ties are allowed, neither single-peakedness nor single-crossingness, combined with narcissism, can guarantee that there are always two agents that are each other’s most acceptable agent (see Proposition 9(3)). However, having two such agents is crucial for the existence of a stable matching so that it can be found by the algorithm by Bartholdi III and Trick [4] (see Algorithm 1). Moreover, for incomplete preferences, even without ties, narcissistic and single-crossing preferences do not imply single-peakedness anymore.

Proposition 9

For incomplete preferences without ties, the following holds.

  1. (1)

    Narcissistic and single-crossing preferences are not necessarily single-peaked.

  2. (2)

    Narcissistic and single-peaked (resp. single-crossing) preferences do not guarantee the uniqueness of stable matchings.

  3. (3)

    Narcissistic and single-peaked (resp. single-crossing) preferences do not guarantee the existence of stable matchings.

Proof

Statement (1): Consider the following profile with six agents \(1,2,\ldots , 6\):

$$\begin{aligned} \text {Profile}~\mathcal {P}_1:&\text {agent}~1:1 \succ _1 3 \succ _1 4 \succ _1 2 \succ _1 5 \succ _1 6, \\&\text {agent }2:2 \succ _2 4 \succ _2 3 \succ _2 6 \succ _2 5 \succ _2 1, \\&\text {agent }3:3 \succ _3 2 \succ _3 1 \succ _3 6 \succ _3 5, \\&\text {agent }4:4 \succ _4 1 \succ _4 2, \\&\text {agent }5:5 \succ _5 2 \succ _5 3 \succ _5 1,\\&\text {agent }6:6 \succ _6 2 \succ _6 3 \succ _6 1. \end{aligned}$$

One can check that the profile is narcissistic, and it is single-crossing with respect to the order \(5 \rhd 6 \rhd 2 \rhd 3 \rhd 4 \rhd 1\). But it is not single-peaked with respect to \(\rhd \) because agent 1’s preference order on \(\{1,3,4\}\) is not single-peaked with respect to \(\rhd \). In fact, the profile is not single-peaked at all since the preference orders of agents 1, 2, and 3 restricted to the alternatives \(\{1,5,6\}\) form a forbidden subprofile (the so-called worst-configuration) for the single-peaked property [2]: In a single-peaked order, regarding the preference orders of agents 1 and 2, agent 5 must be ordered between 1 and 6, which is not possible because of the preference order of agent 3. The profile does not admit a perfect stable matching, i.e., a stable matching of size three. But it admits two stable matchings of size two each: \(\{\{1,3\},\{2,4\}\}\) and \(\{\{1,4\}, \{2,3\}\}\).

Statement (2): Consider the following profile with four agents 1, 2, 3, 4.

$$\begin{aligned} \text {Profile~}\mathcal {P}_2:&\text {agent}~1:1 \succ 2 \succ 3 \succ 4,\qquad \text {agent}~2:2 \succ 4 \succ 1, \\&\text {agent}~3:3 \succ 1 \succ 4, \qquad \qquad \ \text {agent}~4:4 \succ 3 \succ 2 \succ 1. \end{aligned}$$

Once can check that the profile is narcissistic and single-peaked with respect to the order \(1\rhd 2 \rhd 3 \rhd 4\), and single-crossing with respect to the order \(1\rhd ' 3 \rhd ' 2 \rhd ' 4\). It admits two different stable matchings \(\{\{1, 2\}, \{3, 4\}\}\) and \(\{\{1, 3\}, \{2, 4\}\}\).

Statement (3): Consider the following profile with six agents \(1,2,\ldots , 6\).

$$\begin{aligned} \hbox {Profile}~{\mathcal {P}_3} :&\text {agent}~1:1 \succ 5 \succ 2,\qquad \ \qquad \text {agent}~2:2 \succ 1 \succ 3, \\&\text {agent}~3:3 \succ 2 \succ 4, \qquad \qquad \ \text {agent}~4:4 \succ 3 \succ 5, \\&\text {agent}~5:5 \succ 4 \succ 1 \succ 6,\qquad \text {agent}~6:6 \succ 5. \end{aligned}$$

It is narcissistic, and single-peaked and single-crossing with respect to the order \(3 \rhd 2 \rhd 1 \rhd 4 \rhd 5 \rhd 6\). One can check that the profile is single-peaked with respect to the order \(\rhd \). For single-crossingness, observe that each pair of agents is ranked by at most two different agents so that the profile is (tie-sensitive) single-crossing with respect to any ordering.

However, no matching M is stable for this profile. To see this, notice that the preferences of agents from \(A^*\,{:}{=}\,\{1,2,3,4,5\}\) form a certain cyclic structure: For each agent \(i\in A^*\) it holds that agent i is the most preferred agent of agent \((i\bmod 5)+1\). Now, consider an arbitrary matching M. Since \(|A^*|\) is odd, there is at least one agent \(i\in A^*\) with \(M(i)\notin A^*\). It is straightforward to see that agent i and agent \((i\bmod 5)+1\) will form a blocking pair for M. \(\square \)

For the case when ties in the preferences are allowed, Ronn [48] showed that Stable Roommates becomes NP-hard even if the preferences are complete. The constructed instances in his hardness proof, however, are not always single-peaked or single-crossing. It is even not clear whether the problem remains NP-hard for this restricted case. If the preferences need not be complete, however, then we can show NP-hardness, by a completely different reduction, obtaining our main intractability result.

Before we state the corresponding theorem, we prove the following two lemmas which are used heavily in our preference profile construction to force two agents of specific types to be matched together. The first lemma summarizes an observation on a profile that is similar to profile \(\mathcal {P}_3\) presented in the proof of Proposition 9.

Lemma 1

Let \(A=\{a^1,a^2,a^3, a^4, a^{5}\}\) be a set of five distinct agents and let X be a non-empty set of agents disjoint from A. The preference orders of the agents in A satisfy the following, where (X) means that the agents in set X are tied with each other:

$$\begin{aligned}&\text {agent}~a^1:a^1 \succ a^{5}\succ a^2, \qquad \text {agent}~a^{2} :a^2 \succ a^{1}\succ a^3, \\&\text {agent}~a^3:a^3 \succ a^{2} \succ a^4,\qquad \text {agent}~a^{4} :a^{4}\succ a^{3}\succ a^{5}, \qquad \text {agent}~a^{5} :a^{5}\succ (X) \succ a^{4} \succ a^1. \end{aligned}$$

Then, the following holds.

  1. (1)

    Every stable matching M for A satisfies \(M(a^{5})\in X\), \(M(a^1)=a^2\), and \(M(a^3)=a^4\).

  2. (2)

    The preferences from A are narcissistic and single-peaked with respect to the linear order \(a^{3}\rhd a^{2} \rhd a^1 \rhd a^4 \rhd a^{5} \rhd [X]\), where [X] denotes some fixed linear order of the agents in X.

  3. (3)

    The preferences from A are tie-sensitive single-crossing with respect to any ordering of the agents in A.

Proof

Towards a contradiction to Statement (1), suppose that there is a stable matching M with \(M(a^5)\notin X\). Then, by the preferences of \({\sim } a^5\), there remain three possibilities (i)–(iii) for the partner of \(a^5\). We claim to obtain a blocking pair for M for each of these possibilities.

Case (i)::

\(M(a^{5})\notin \{a^1, a^{4}\}\). This implies that agent \(a^{5}\) does not have a partner. Then, by construction, \(\{a^{5},a^1\}\) will be blocking M.

Case (ii)::

\(M(a^{5}) = a^{4}\). Since \(a^4\) prefers \(a^3\) to \(a^5\), it follows that \(a^3\) must obtain a partner that it prefers to \(a^4\) as, otherwise, \(\{a^3,a^4\}\) will form a blocking pair for M. Since \(a^2\) is the only (acceptable) agent that \(a^3\) prefers to \(a^4\), it follows that \(\{a^{3}, a^{2}\}\in M\). Consequently, \(a^1\) will not be assigned a partner by M. However, \(\{a^1, a^2\}\) will form a blocking pair for M.

Case (iii)::

\(M(a^{5}) = a^{1}\). Analogously to Case (ii), if \(M(a^{5})=a^1\), then we deduce that \(M(a^{4})=a^3\). This implies that \(a^2\) remains unmatched by M. However, \(\{a^2,a^3\}\) will form a blocking pair for M.

We have just shown that \(M(a^5)\in X\). By the preferences of \(a^2\) it follows that \(M(a^2)=a^1\) as otherwise \(a^1\) is unmatched and will form a blocking pair with \(a^2\). Similarly, we can infer that \(M(a^4)=a^3\).

Statement (2) is straight-forward. As for Statement (3), which concerns tie-sensitive single-crossingness , we observe that it holds with respect to every order of the agents: Each pair of agents is ranked by at most two different agents and ties only occur in the preferences of \(a^5\). \(\square \)

Whereas Lemma 1 enforces that a specific agent (i.e., \(a^5\)) must be matched with some agent from a specific group of agents (i.e., X), the forthcoming lemma enforces some specific combination of matchings inside this specific group X. This seems crucial to ensure the narcissistic, single-peaked, and tie-sensitive single-crossing property.

Lemma 2

Let \(X\,{:}{=}\,\{x^1, x^2, \ldots , x^{10}\}\), be two disjoint sets of agents, and let A and B be two disjoint sets of agents such that XRA, and B are pairwise disjoint. Furthermore, assume that the preferences of the agents from X satisfy the following, where the symbols [A] and [B] denote some fixed linear orders of the agents in A and B, respectively:

The following holds for the preferences of X.

  1. (1)

    If M is a stable matching with \(M(x^{10})\in B\), then for each \(i\in \{4,3,2,1\}\) we have that \(\{x^{2i+1},x^{2i}\}\in M\).

  2. (2)

    The above preferences are narcissistic, single-peaked, and tie-sensitive single-crossing with respect to the following order, where \(\overleftarrow{[A]}\) and \(\overleftarrow{[B]}\) denote the reverse of the fixed orders [A] and [B], respectively:

Proof

By our assumption that \(M(x^{10})\in B\) and by the preference order of \(x^{10}\), it follows that \(M(x^9)=x^8\) as otherwise \(\{x^9,x^{10}\}\) will form a blocking pair for M. By an analogous reasoning for \(x^7\), \(x^5\), and \(x^3\), we deduce that \(M(x^7)=x^6\), \(M(x^5)=x^4\), and \(M(x^3)=x^2\), showing Statement (1).

As for Statement (2), clearly, the preferences of the agents in X, are narcissistic. One can check that the preferences are indeed single-peaked with respect to the order \(\rhd \). Since no two agents are ranked by more than two different agents, it is clear that the preferences are tie-sensitive single-crossing, implying single-crossingness due to Proposition 1(1). \(\square \)

Figure 4 illustrates the crucial part of the acceptability graphs of the profiles discussed in Lemma 1 and Lemma 2. Observe that, these graphs display a certain cyclic structure if we make the edges directed: If we construct an arc (uw) for each agent u and its most acceptable agent w, then we obtain a directed cycle. Moreover, we have already seen from profile \(P_3\) in the proof of Proposition 9 that odd cycles imply non-existence of stable matchings. Using this observation, we can show our main result now.

Fig. 4
figure 4

Illustration of the acceptability graphs for Lemma 1 and 2. Left: The node labeled with X represents the agents in X. Thick red lines correspond to a possible stable matching. Right: The nodes labeled with A and B represent the agents in A and B, respectively. There are two possible stable matchings, one represented by thick red lines and the other by double lines

Theorem 2

Stable Roommates for incomplete preferences with ties remains NP-complete, even if the preferences are narcissistic, single-peaked, and (tie-sensitive) single-crossing.

Proof

First, the problem is in NP since one can non-deterministically guess a matching and check stability in polynomial time. To show NP-hardness, we reduce from the NP-complete Independent Set problem [28]:

Independent Set

Input: an undirected graph \(G=(U,E)\) and a non-negative integer k.

Question: Is there a size-k independent set, i.e., a subset \(U'\subseteq U\) of k pairwise non-adjacent vertices?

We assume that each vertex has degree at most three since Independent Set remains NP-hard for this case [27]. Let \((G=(U,E),k)\) be an Independent Set instance with U being the vertex set and E being the edge set. Let \(U\,{:}{=}\,\{u_1, u_2,\dots , u_n\}\). We will construct a Stable Roommates instance \(\mathcal {P}\) with agent set V which is narcissistic, single-peaked, and tie-sensitive single-crossing, and show that G admits a size-k independent set if and only if \(\mathcal {P}\) admits a stable matching.

Main idea and the constructed agents. For each vertex \(u_i \in U\), we introduce ten vertex agents \(u^j_i\), \(1\le j \le 10\), denoted as \(U_i=\{u_i^j\mid 1\le j \le 10\}\). The idea is to obtain an acceptability graph that has a cycle of length ten (see our discussion just prior to the theorem) for each vertex of the input graph, including eight for the neighbors of this vertex. This is used to ensure narcissistic, single-peaked, and single-crossing property simultaneously. Additionally, we introduce two groups of selector agents, each with k sets:

Group (1)::

\(A_j=\{a^i_j\mid 1\le i \le 5\}\), \(1\le j \le k\), and

Group (2)::

\(B_j=\{b^i_j\mid 1\le i \le 5\}\), \(1\le j \le k\).

We will construct preferences for these selector agents to enforce that each two selectors \(a_j^5\) and \(b^5_j\), \(1\le j \le k\), are matched to two vertex agents. Together with the preferences of the vertex agents, we make sure that the vertex agents that are matched to \(a_j^5\) and \(b^5_j\), respectively, correspond to the same vertex.

The agent set V is defined as \(V=\left( \bigcup _{1\le i \le n}U_i\right) \cup \left( \bigcup _{1\le j\le k}(A_j \cup B_j)\right) \). In total, we have constructed \(10n+10k\) agents.

To encode an Independent Set instance, we aim to construct preferences for the vertex agents such that no two vertex agents that are matched to some selector agents correspond to two adjacent vertices. This property will be formally captured later by Claim 1.

Selector agents. The preferences of the selector agents are of the form as described in Lemma 1. To this end, let \(U^1=\{u^1_i\mid 1\le i \le n\}\) and \(U^{10}=\{u^{10}_i\mid 1\le i \le n\}\). We use \((U^1)\) and \((U^{10})\) to express that the agents in the respective subsets are tied.

Vertex agents. The preferences of the vertex agents for each vertex \(u_i\) are of the form described in Lemma 2.

Herein, \(A^5\) represents the following set \(A^5\,{:}{=}\,\{a^5_j\mid 1\le j \le k\}\) and \([A^5]\) denotes the following fixed order of the selector agents in \(A^5\): \([A^5]\,{:}{=}\,a^5_1 \succ a^5_2\succ \cdots \succ a^5_k\). The symbols \(B^5\) and \([B^5]\) are defined in an analogous way: \(B^5\,{:}{=}\,\{b^5_j\mid 1\le j \le k\}\) and \([B^5]\) denotes the following fixed order of the selector agents in \(B^5\): \([B^5]\,{:}{=}\,b^5_1 \succ b^5_2\succ \cdots \succ b^5_k\).

It remains to specify the agents \(r_i^2\), \(r_i^4\), \(r_i^6\), and \(r_i^8\). Recall that the maximum vertex degree of our input graph G is three. By Vizing’s Theorem [56], graph G is 4-edge-colorable, that is, the edge set of G can be partitioned into four subsets \(E_1\), \(E_2\), \(E_3\), and \(E_4\) which are each a matching. Moreover, this partition can be computed in polynomial time [44]. Thus, we first compute the sets \(E_c\), \(1\le c \le 4\). Next, for each \(1\le c \le 4\), if \(E_c\) contains an edge \(e=\{u_i,u_j\}\), then we define \(r^{2c}_i:=u^{2c}_j\) (resp. \(r^{2c}_j\,{:}{=}\,u^{2c}_i\)). If some vertex \(u_i\) is not incident to an edge of color c, then \(r^{2c}_i\) is omitted, that is, the preference order of agent \(u^{2c}_i\) is just \(u_i^{2c} \succ u_i^{2c -1} \succ u_i^{2 c +1}\).

For an illustration, assume that \(e_1\in E_1\) and \(e_4\in E_2\) with \(e_1=\{u_1, u_2\}\) and \(e_4=\{u_1,u_3\}\). Then, \(r_1^2,r_2^2,r_1^4,r_3^4\) are \(r_1^2=u_2^2\), \(r_2^2=u_1^2\), \(r_1^4=u^4_3\), \(r_3^4=u_1^4\).

This completes the construction, which can clearly be performed in polynomial time. Next, we show that our constructed profile is narcissistic, single-peaked, single-crossing, and tie-sensitive single-crossing.

Single-peakedness. The constructed profile is single-peaked with respect to the following linear order \(\rhd \):

$$\begin{aligned}{}[A_k] \rhd [A_{k-1}] \rhd \cdots \rhd [A_1] \rhd [B_k] \rhd [B_{k-1}] \rhd \cdots \\ \cdots \rhd [B_1]\rhd [U^{10,9}] \rhd [U^{1,2}] \rhd [U^{3,4}] \rhd [U^{5,6}] \rhd [U^{7,8}] \text {.} \end{aligned}$$

We specify the notations used in the above order.

  • For each \(j \in \{1,2,\dots , k\}\) and for each \((Q,q)\in \{(A,a),(B,b)\}\), the let \([Q_j]\) denote the order \(q_j^3\rhd q_j^2 \rhd q_j^1 \rhd q_j^4 \rhd q_j^5\) (cf. Lemma 1).

  • The symbol \([U^{10,9}]\) denotes the order \(u^{10}_1\rhd u^{10}_2 \rhd \cdots \rhd u^{10}_n \rhd u^{9}_1\rhd u^{9}_2 \rhd \cdots \rhd u^{9}_n\).

  • For each \(c\in \{1,2,3,4\}\) the symbol \(U^{2 c-1, 2 c}\) denotes the subset \(\{u_i^{2c-1}, u_i^{2c}\mid 1\le i \le n\}\). Intuitively, the symbol \([U^{2 c-1, 2 c}]\) denotes an order of the agents in \(U^{2 c-1, 2 c}\), which makes sure that the preferences of the vertex agents that are “incident” to the edges in \(E_c\) are single-peaked with respect to this order. To define \([U^{2 c-1,2 c}]\), we need the following additional notion: For each edge \(e\in E_c\) let \(u_i\) and \(u_j\) be the respective endpoints with \(i<j\). Then, let [e] denote the order \(u^{2 c -1}_i \rhd u^{2 c}_i \rhd u_j^{2 c-1} \rhd u_j^{2 c}\).

    The order \([U^{2 c -1, 2 c}]\) is defined as follows:

    $$\begin{aligned} {[}U^{2 c-1,2 c}] \,{:}{=}\,[e_{c,1}] \rhd [e_{c,2}] \rhd \cdots \rhd [e_{c,\ell }] \rhd [R], \end{aligned}$$

    where \(e_{c,1}, e_{c,2}, \dots , e_{c,\ell }\) is an arbitrary but fixed order of the edges in \(E_c\), and [R] denotes a fixed order of the vertex agents \(u_i\) of the form \(u_i^{2 c-1}\succ u_i^{2 c}\) that are not “incident” to any edge in \(E_c\).

For an illustration, assume that \(E_1=\{e_1,e_2\}\) with \(e_1=\{u_1, u_2\}\) and \(e_2=\{u_5,u_6\}\). Then, \([U^{1,2}]\) may be defined as \([U^{1,2}]\,{:}{=}\,u_1^{1}\rhd u_1^2 \rhd u_2^1 \rhd u^2_2 \rhd u^{1}_5 \rhd u^2_5 \rhd u^1_6 \rhd u^2_6 \rhd u^1_3 \rhd u^2_3 \rhd u_4^1 \rhd u^2_4\).

Tie-single-crossingness and single-crossingness. To show that the constructed preference profile is also tie-sensitive single-crossing we consider each pair p of agents and let \(\mathsf {Ac}{(}p)\) denote the agents which consider both agents in p as acceptable partners. We show that either all agents in \(\mathsf {Ac}{(}p)\) have the same order on p or if two agents exist that order p differently, then \(|\mathsf {Ac}{(}p)|=2\). It is straight-forward to verify that if we can show the above statement, then the profile is tie-sensitive single-crossing, and it is single-crossing by breaking ties in an arbitrary but fixed way.

To this end, let \(A^5=\{a_j^5\mid 1\le j \le k\}\), \(B^5=\{b_j^5\mid 1\le j \le k\}\), \(U^1=\{u_i^1\mid 1\le i \le n\}\), and \(U^{10}=\{u_i^{10} \mid 1\le i \le n\}\).

Case 1: \(\varvec{p=\{a_j^{z},a_{j}^{z'}\}\subseteq A_j}\) (resp. \(\varvec{p=\{b_j^{z}, b_{j}^{z'}\}\subseteq B_j}\)):

for some value \(j\in \{1,2,\dots , k\}\) and some values \(z,z'\in \{1,2,3,4,5\}\). This implies that \(\mathsf {Ac}{(}p)\subseteq A_j\) (resp. \(A(p)\subseteq B_j\)). Moreover, no agent in \(\mathsf {Ac}{(}p)\) considers the agents in p to be tied with each other. If there are two agents in \(\mathsf {Ac}{(}p)\) that order this pair differently, then these agents must be those from p. It is straightforward to verify that in this case, it holds that \(p=\mathsf {Ac}{(}p)\), implying that \(|\mathsf {Ac}{(}p)|=2\). For instance, if \(p=\{a^1_i,a_i^5\}\), then \(\mathsf {Ac}{(}p)=p\). Otherwise, \(|A(p)|=1\) (For instance, for \(p=\{a^2_i, a^5_i\}\), one can check that \(\mathsf {Ac}{(}p)=\{a^1_i\}\)).

Case 2: \(\varvec{p=\{a_j^{z},a_{j'}^{z'}\}}\) (resp. \(\varvec{p=\{b_j^{z},b_{j'}^{z'}\}}\)):

for two distinct values \(j,j'\in \{1,2,\cdots , k\}\) with \(j\ne j'\) and for some values \(z,z'\in \{1,2,3,4,5\}\). If \(z = z' = 5\), then \(\mathsf {Ac}{(}p)=U^1\) (resp. \(\mathsf {Ac}{(}p)=U^{10}\)); otherwise \(\mathsf {Ac}{(}p)=\emptyset \). For the first case, all agents in \(\mathsf {Ac}{(}p)\) have the same order on p.

Case 3: \(\varvec{p=\{u_i^{j}, u_i^{j'}\} \subseteq U_i}\):

for some value \(i\in \{1,2,\dots , n\}\) and some distinct values \(j,j'\in \{1,2,\dots , 10\}\). This implies that \(\mathsf {Ac}{(}p)\subseteq U_i\), and no agent in \(\mathsf {Ac}{(}p)\) considers the agents in p to be tied with each other. Analogously, we deduce that if there are two agents in \(\mathsf {Ac}{(}p)\) that order this pair differently, then they must be the agents in p themselves. It is straightforward to verify that in this case we have \(p=\mathsf {Ac}{(}p)\). Otherwise, \(|\mathsf {Ac}{(}p)|=1\).

Case 4: \(\varvec{p=\{u_{i}^{j}, u_{i'}^{j'}\}}\):

for two distinct values \(i,i'\in \{1,2,\dots , n\}\) with \(i\ne i'\) and some two (possibly identical) values \(j, j'\in \{1,2,\ldots , 10\}\). If \(j=j'\in \{1,10\}\), then either \(\mathsf {Ac}{(}p)=A^5\) or \(\mathsf {Ac}{(}p)=B^5\). In both cases, all agents in \(\mathsf {Ac}{(}p)\) consider the agents in p to be tied with each other. Otherwise, if the corresponding two vertices \(v_i\) and \(v_{i'}\) are adjacent with \(\{v_i,v_{i'}\}\in E_c\) for some color \(c\in \{1,2,3,4\}\) such that \(j=j'=2c\), then \(\mathsf {Ac}{(}p)=p\). In the remaining cases for j and \(j'\), no agent considers \(u_i^{j}\) and \(u^{j'}_{i'}\) both acceptable as partners and thus, we deduce that \(\mathsf {Ac}{(}p)=\emptyset \).

Case 5: \(\varvec{p=\{u_i^z, a_{j}^{z'}\}}\) (resp. \(\varvec{p=\{u_i^z, b_{j}^{z'}\}}\)):

for some values \(i,j,z,z'\) with \(i \in \{1,2,\dots , n\}\), \(j\in \{1,2,\dots , k\}\), \(z \in \{1,2,\ldots , 10\}\), and \(z'\in \{1,2,\ldots , 5\}\). If \(z=1\) (resp. \(z=10\)) and \(z'=5\), then by the constructed preferences we deduce that \(\mathsf {Ac}{(}p)=p\). If \(z=1\) (resp. \(z=10\)) and \(z'\in \{1,4\}\), then by the constructed preferences we deduce that \(\mathsf {Ac}{(}p)=\{a^5_j\}\) (resp. \(\mathsf {Ac}{(}p)=\{b^5_j\}\)). If \(z\in \{2,10\}\) (resp. \(z \in \{1,9\}\)) and \(z'=5\), then we deduce that \(\mathsf {Ac}{(}p)=\{u^1_i\}\) (resp. \(\mathsf {Ac}{(}p)=\{u^{10}_i\}\)). Otherwise, by construction, we have that \(\mathsf {Ac}{(}p)=\emptyset \).

Correctness of the construction. We show that G has a size-k independent set if and only if \(\mathcal {P}\) admits a stable matching.

For the “only if” part, assume that \(U'\subseteq U\) is a size-k independent set where \(U'=\{u_{q_1},u_{q_2},\ldots , u_{q_k}\}\) with \(q_{i-1}< q_{i}\) for all \(i\in \{2,3,\dots , k\}\). One can verify that the following matching M is stable.

  • For each \(u_{q_j} \in U'\) set \(M(a^5_j) = u^1_{q_j}\), \(M(b^5_j) = u^{10}_{q_j}\), \(M(a^{1}_j)=a^{2}_j\), \(M(a^{3}_j)=a^4_j\), \(M(b^{1}_j)=b^{2}_j\), and \(M(b^{3}_j)=b^4_j\). Note that this in particular defines matchings for all selector agents.

  • For each \(u_i\in U'\) and for each \(c\in \{1,2,3,4\}\), set \(M(u_i^{2c+1})=u_i^{2c}\).

  • For each \(u_i \notin U'\) and for each \(c\in \{1,2,3,4,5\}\) set \(M(u^{2c-1}_i) = u^{2c}_i\).

Before we go on with the “if” part, we observe some properties that each stable matching of our constructed profile must satisfy.

Claim 1

Every stable matching M for our constructed profile satisfies the following two properties.

  1. (1)

    For each \(j\in \{1,2,\ldots , k\}\) the selector agent \(b^5_j\) is matched with some vertex agent of the form \(u^{10}_i\) for some \(i\in \{1,2,\ldots , n\}\).

  2. (2)

    No two vertex agents \(u^{10}_i\) and \(u^{10}_{i'}\) which are both matched to some selector agents correspond to two adjacent vertices.

Proof

(Proof of Claim 1) Let M be a stable matching for our profile. For the first statement, Lemma 1(1) immediately implies that for every selector agent \(b^5_j\), \(1\le j \le k\), it holds that \(M(a^5_j) \in \{u^{10}_i \mid 1\le i \le n\}\).

For the second statement, suppose, towards a contradiction, that there are two vertex agents \(u^{10}_i, u^{10}_{i'}\) (for some distinct \(i,i'\in \{1,2,\ldots ,n\}\)) which are matched to some selector agents such that the corresponding vertices \(u_i\) and \(u_{i'}\) are adjacent, i.e., \(\{u_i,u_{i'}\}\in E_c\) for some \(c\in \{1,2,3,4\}\). This means that \(\{M(u^{10}_i),M(u^{10}_{i'})\}\subseteq \{b^5_j\mid 1\le j \le k\}\). Consequently, by Lemma 2(1), it follows that \(M(u_i^{2c})=u_i^{2c+1}\) and \(M(u_{i'}^{2c})=u_{i'}^{2c+1}\). However, by construction, both \(u^{2c}_{i}\) and \(u^{2c}_{i'}\) prefer each other to their respective partner, forming a blocking pair for M—a contradiction. \(\lozenge \)

To show the “if” part, let M be a stable matching. Then, Claim 1 immediately implies that the subset \(U'=\{u_i \mid M(u^{10}_i)=b^{5}_j \text { for some } j \in \{1,2,\cdots , k\}\}\) is an independent set of size k. \(\square \)

5 Conclusion

We investigated Stable Roommates for preferences with popular structural properties, such as being narcissistic, single-peaked, and single-crossing. We showed that for complete preferences with ties, assuming narcissism and single-peakedness (or narcissism and single-crossingness) guarantees the existence of stable matchings, which can be found in linear time; by comparison, Stable Roommates with complete preferences and ties is NP-complete [48]. For incomplete preferences with ties, however, narcissistic and single-peakedness even combined with single-crossingness do not help to lower the computational complexity—Stable Roommates remains NP-complete.

We conclude with some challenges for future research. First, to better understand the NP-completeness result, one may study the parameterized complexity with respect to the “degree” of incompleteness of the input preferences, such as the number of ties or the number of agents that are in the same equivalence class of the tie-relation. We refer to some recent papers on the parameterized complexity of preference-based stable matching problems [1, 11, 12, 14,15,16, 29, 40,41,42, 45] for this line of research.

Second, we were not able to settle the computational complexity for complete preferences that are also single-peaked and single-crossing.

Third, for incomplete preferences, we extended the concepts of single-peaked and single-crossing preferences. There are, however, further relevant extensions in the literature [20, 25, 37], which deserve attention in the study of stable matching problems. Do our results transfer to preferences with these extensions?

Fourth, the algorithm of Bartholdi III and Trick [4] strongly relies on the following condition:

At each step, there are always two agents that consider each other most acceptable.

To explore the boundary between tractable and intractable cases it is important to understand which structural properties imply this condition. For instance, the so-called worst-restricted property (i.e., no three agents exist such that each of them is least preferred by some agent) [53, 54] is a generalization of the single-peaked property. In fact, we can show that for preferences without ties, the narcissistic and worst-restricted properties are enough to guarantee that there are always two agents which consider each other most acceptable [23]. For profiles with ties, however, it seems unclear how to define a worst-restricted property so that the question of “how far one can generalize structured preferences so that the above condition still holds” remains open.

Finally, we found an issue with Bartholdi III and Trick’s algorithm regarding their claimed O(n) running time (see Example 4). This brings up the question as to whether finding a stable matching can be done faster than in linear time, i.e., faster than \(O(n^2)\) time for complete, narcissistic, and single-peaked preference profiles without ties.