Bridging the Gap Between Stable Marriage and Stable Roommates: A Parametrized Algorithm for Optimal Stable Matchings

In the Stable Roommates Problem (SR), a set of $2n$ agents rank one another in a linear order. The goal is to find a matching that is stable, one that has no pair of agents who mutually prefer each other over their assigned partners. We consider the …

Authors: Christine T. Cheng, Will Rosenbaum

Bridging the Gap Between Stable Marriage and Stable Roommates: A Parametrized Algorithm for Optimal Stable Matchings
Br idging the Gap Betw een S table Mar r iag e and S table R oommates: A P arametr ized Algor ithm f or Optimal S table Matchings Christine T . Cheng 1 and Will R osenbaum 2 1 U niv ersity of Wisconsin-Milw aukee 2 U niv ersity of Liv er pool March 31, 2026 Abstract In the S table Roommates Problem (SR), a set of 2 𝑛 agents rank one another in a linear order . The goal is to find a matching that is stable, one that has no pair of agents who mutuall y pref er each other ov er their assigned par tners. W e consider the problem of finding an optimal stable matching. A gents associate w eights with each of their potential par tners, and the goal is to find a stable matc hing that minimizes the sum of the associated weights. Efficient algorithms exis t f or finding optimal stable marr iages in the S table Marr iage Problem (SM), but the problem is NP -hard f or general SR ins tances. In this paper , we define a notion of structural distance betw een SR ins tances and SM instances, whic h w e call the minimum crossing distance . When an SR instance has minimum crossing distance 0 , the instance is s tr ucturally eq uivalent to an SM ins tance, and this structure can be exploited to find optimal stable matchings efficientl y . More generall y , we sho w that f or an SR instance with minimum crossing distance 𝑘 , optimal stable matchings can be computed in time 2 𝑂 ( 𝑘 ) 𝑛 𝑂 ( 1 ) . Thus, the optimal stable matching problem is fix ed parameter tractable (FPT) with respect to minimum crossing distance. 1 Introduction In their seminal w ork, Gale and Shaple y [ 18 ] introduced the S table Mar riage Problem (SM), as w ell as its non-bipar tite v ersion, the Stable R oommates Problem (SR). In SM, a set of agents is par titioned into tw o groups, traditionall y ref er red to as men and w omen, where each ag ent ranks members of the opposite group in a strict linear order . The goal is to find a matching that is stable , one that has no pair of agents who mutuall y pref er each other ov er their assigned par tners. The main result in [ 18 ] pro vides an efficient algor ithm f or finding such a matc hing, thus establishing that ev er y SM instance has a stable matc hing. In SR, there is a single set of agents, each of whom ranks all other agents in a strict linear order . The notion of stability extends naturall y to this setting. U nlik e SM, ho w ev er , Gale and Shapley show ed that SR instances need not ha v e a stable matching. Irving [ 26 ] later de vised an efficient algor ithm f or SR sol vability , which w as recently sho wn to be optimal [40]. Con wa y [ 34 , 35 ] w as the first to obser v e that when 𝐼 is an SM instance, its set of s table matchings f or m a distributiv e lattice D ( 𝐼 ) . The minimum element of D ( 𝐼 ) is the man-optimal stable matching while its maximum element is the w omen-optimal stable matc hing. All other stable matchings of 𝐼 lie betw een these tw o extreme matc hings, where stable matchings that are better f or one g roup are w orse f or the other . R elated to D ( 𝐼 ) is the r otation poset R ( 𝐼 ) . Its elements are called r otations and represent the minimal differences betw een the stable matchings of 𝐼 . Irving and Leather [ 28 ] pro ved that the s table matchings of 𝐼 are in one-to-one cor respondence with the closed subsets of R ( 𝐼 ) . Further more, R ( 𝐼 ) has the advantag e o ver D ( 𝐼 ) in that it can be deriv ed directly from the pref erence lists of 𝐼 in linear time. F or this reason, rotation posets pla y a central role in SM. R otation posets hav e been emplo y ed to obtain hardness results f or many SM problems such as counting stable matc hings [ 28 ], and computing median s table matchings [ 8 , 9 ], balanced s table matchings [ 16 ], and se x-equal s table matc hings [ 32 , 36 ]. On the other hand, the y ha v e also been used to de vise efficient algor ithms that compute fair or nice stable matc hings like eg alitar ian stable matchings [ 14 , 23 , 29 ] and the more general optimal stable matc hings [20, 23, 29], center stable matchings [12, 13] and robus t stable matchings [6]. SR can be vie w ed as a g eneralization of SM because an SM instance can be transf ormed into an SR instance b y appending all remaining agents to each ag ent ’ s pref erence lists arbitrar il y . It is s traightf or ward to sho w that this transf or mation will result in an SR ins tance with precisely the same s table matchings as the original SM instance. Like SM, a sol vable SR instance 𝐼 also has a rotation poset R ( 𝐼 ) . Gusfield [ 22 ] and Ir ving [ 27 ] (cf. [ 23 ]) sho wed that R ( 𝐼 ) consists of singular and non-singular rotations, and the subposet f or med b y the non-singular rotations R ′ ( 𝐼 ) is the significant one. There is a one-to-one cor respondence between the s table matchings of 𝐼 and the complet e closed subsets of R ′ ( 𝐼 ) . Moreo v er , R ( 𝐼 ) (and theref ore R ′ ( 𝐼 ) ) can be deriv ed from the pref erence lists of 𝐼 in pol ynomial time. Much later , Cheng and Lin [ 10 ] g eneralized the structure of R ′ ( 𝐼 ) to mirr or posets to sho w that the s table matc hings of 𝐼 f or m a median gr aph 𝐺 ( 𝐼 ) , a w ell-studied class of graphs that includes trees, h ypercubes, gr ids and the co ver graphs of dis tr ibutiv e lattices (e.g., see [ 2 , 25 , 33 ]). F or the rest of the section, w e shall assume 𝐼 is a sol v able SR instance and ref er to R ′ ( 𝐼 ) as the mirror pose t of 𝐼 . W e summar ize the cor respondence betw een analogous concepts in SM and SR in Figure 1. It is notable that median graphs—the meta-structures of SR stable matchings—are not ordered while distributiv e lattices— the meta-structures of SM s table matc hings—are ordered. In SM, the agents are divided into tw o groups and this bipar tition defines the tw o “sides” of the distributive lattice. In SR, no such partition e xists f or the ag ents so no natural order ing can be used on the stable matchings. Nonetheless, f or 𝐺 ( 𝐼 ) , an arbitrary stable matching 𝜂 can be designated as the roo t and all the edges of 𝐺 ( 𝐼 ) are directed a wa y from 𝜂 . The result is the Hasse diagram of the median semilattice L ( 𝐼 , 𝜂 ) [ 10 ], which is a more g eneral structure than a dis tr ibutiv e lattice. Moreo v er , different c hoices of roots will generall y result in different median semilattices, some of which ma y pro ve more algorithmicall y advantag eous than others. In spite of the similar ities between the structures f or med b y the SM and SR stable matchings, we do not kno w of an y work that utilizes the mirror posets of SR instances to address computational problems in SR. 1 Part of the reason is that SR instances contain SM instances. Thus, when a problem is computationall y hard in SM, the analogous problem is also hard in SR. Y et there are problems suc h as finding an egalitarian stable matc hing and its generalization, the optimal s table matching, that can be sol ved efficientl y in SM but is NP-hard in SR [ 14 , 15 , 29 ]. Intuitiv ely , the “closer” an SR instance is to an SM instance, the easier it should be to find an optimal s table matching. This intuition is our motiv ation f or dev eloping a fix ed-parameter tractable (FPT) algorithm f or optimal SR stable matchings. The parameter we emplo y , minimum cr ossing distance , captures ho w close the SR instance is to some SM ins tance. Our Contributions In the optimal stable matching problem, w e are giv en a cost function 𝐶 so that 𝐶 ( 𝑎 , 𝑏 ) is the cost to agent 𝑎 of being matched to agent 𝑏 . The cost of stable matching 𝜇 is 𝐶 ( 𝜇 ) = Í { 𝑎 , 𝑏 } ∈ 𝜇 𝐶 ( 𝑎 , 𝑏 ) + 𝐶 ( 𝑏 , 𝑎 ) . The goal is to find a stable matc hing with least cost. When 𝐶 ( 𝑎 , 𝑏 ) is equal to the rank of 𝑏 in 𝑎 ’ s pref erence list, an optimal stable matching is also called an eg alitarian stable matc hing . In Theorem 4.7, w e sho w that the technique used b y Ir ving et al. [ 29 ] to compute an optimal SM s table 1 In Section 4.4.3 of [ 23 ], Gusfield and Irving describe a procedure f or finding a minimum r egr et s table matching of an SR instance 𝐼 . It inv olv es picking the “right” rotations to eliminate in the second phase of Irving’s algorithm. While the procedure makes use of rotations, it does so without being a ware of the poset f or med b y the rotations. 2 Concept SM Instances SR Instances structure of stable matc hings distributiv e lattice median graph structure of (non-singular) rotations arbitrary poset P mir ror poset P relationship betw een stable stable marr iag es ≃ stable matc hings ≃ complet e matchings and rotation sets closed subsets of rotations closed subsets of rotations comple xity of optimal pol ynomial time NP -Hard stable matc hing Figure 1: R elationship between s tructure and ter minology f or SM and SR instances. matching efficientl y can also be used to find a locally optimal s table matching of an SR ins tance 𝐼 . That is, suppose the median graph 𝐺 ( 𝐼 ) is rooted at the s table matching 𝜂 to create the median semilattice L ( 𝐼 , 𝜂 ) . For an y stable matching 𝜇 , denote as [ 𝜂 , 𝜇 ] the set that contains 𝜇 and its predecessors in L ( 𝐼 , 𝜂 ) . It turns out that the subposet induced b y [ 𝜂 , 𝜇 ] f or ms a dis tr ibutiv e lattice. Using Irving et al.’ s technique, a stable matching with the leas t cost in [ 𝜂 , 𝜇 ] can be computed in 𝑂 ( 𝑛 5 log 𝑛 ) time when 𝐼 has 2 𝑛 agents. Our algorithm. Let the maximal elements of L ( 𝐼 , 𝜂 ) be 𝜇 1 , 𝜇 2 , . . . , 𝜇 𝑟 . Notice that ∪ 𝑟 𝑖 = 1 [ 𝜂 , 𝜇 𝑖 ] contains all the stable matc hings of 𝐼 . Moreov er , ev ery optimal stable matching of 𝐼 belongs to one of the sets [ 𝜂 , 𝜇 𝑖 ] , where it is also a local optimum. Thus, w e can obtain an optimal stable matching of 𝐼 as follo w s: first, compute a locall y optimal stable matc hing of [ 𝜂 , 𝜇 𝑖 ] f or 𝑖 = 1 , 2 , . . . , 𝑟 . Then, among the 𝑟 locall y optimal stable matchings, retur n the one with the least cost. By Theorem 4.7, the r unning time of the algor ithm is 𝑂 ( 𝑟 × 𝑛 5 log 𝑛 ) . Clearl y , the fe w er the maximal elements of L ( 𝐼 , 𝜂 ) , the faster is the algorithm. In par ticular , when L ( 𝐼 , 𝜂 ) has onl y one maximal element—and theref ore the maximal element is a maximum element— L ( 𝐼 , 𝜂 ) is actuall y a distributiv e lattice and the algor ithm w e hav e just described reduces to Ir ving et al.’ s algorithm. Ho w then should we choose a root f or 𝐺 ( 𝐼 ) so that the resulting median semilattice has the f e wes t number of maximal elements? T o answ er this question, w e mak e use of the mir ror poset R ′ ( 𝐼 ) , a structure that can be built efficiently from the preference lists of 𝐼 . W e show that rooting 𝐺 ( 𝐼 ) at the stable matching 𝜂 has an analogous action on R ′ ( 𝐼 ) : orienting R ′ ( 𝐼 ) at 𝑆 𝜂 , where 𝑆 𝜂 is the complete closed subset of R ′ ( 𝐼 ) that cor responds to 𝜂 . The or ientation par titions R ′ ( 𝐼 ) into tw o par ts. The low er par t R − consists of the rotations in 𝑆 𝜂 while the upper par t R + contains the rest of the rotations. W e call an edge of the Hasse diagram of R ′ ( 𝐼 ) a cr ossing edg e if it has one endpoint in R − and another endpoint in R + . In Theorem 5.3, w e sho w that the maximal elements of L ( 𝐼 , 𝜂 ) can be described using the crossing edges of R ′ ( 𝐼 ) . Consequently , w e pro v e in Corollar y 5.4 that when R ′ ( 𝐼 ) oriented at 𝑆 𝜂 has 2 𝑘 crossing edges, the corresponding median semilattice L ( 𝐼 , 𝜂 ) has at mos t 3 𝑘 maximal elements. In light of Corollary 5.4, we in v estigate the f ollo wing optimization problem: Minimum Cr ossing Orient a tion (MCO): Given a mirr or poset P , find an orientation of P so that it has the least number of cr ossing edg es among all the orientations of P . Let MCO( P ) denote the number of crossing edges in an optimal or ientation of P . When P = R ′ ( 𝐼 ) , w e also ref er to MCO( P ) as the minimum crossing dis tance of 𝐼 because it measures ho w far the SR instance 𝐼 is from an SM instance. In par ticular , we pro v e in Lemma 6.1 that MCO( P ) = 0 if and onl y if 𝐺 ( 𝐼 ) is the co ver graph of a distributiv e lattice. Corollar y 5.4 g eneralizes this result fur ther b y implying that if MCO( P ) = 𝑘 then 𝐺 ( 𝐼 ) is the union of the co v er g raphs of at most 3 𝑘 distributiv e lattices. In Theorem 6.4, we pro v e that MCO is NP-hard b y doing a reduction from the minimum v er te x co ver problem. Ne xt, b y doing a reduction to Almost 2-S A T , we sho w in Theorem 6.6 that if MCO( P ) = 𝑘 then 3 MCO can be sol ved in time 𝑂 ( 15 𝑘 𝑘 4 𝑚 3 ) , where 𝑚 is the number of edges in the Hasse diag ram of P . Appl ying this FPT result to R ′ ( 𝐼 ) and combining it with our algorithm for finding an optimal s table matching of 𝐼 , we ha v e our main result. Theorem 1.1. Let 𝐼 be an SR instance with 2 𝑛 ag ents and minimum crossing distance 𝑘 . An optimal stable matching f or 𝐼 can be f ound in time 2 𝑂 ( 𝑘 ) 𝑛 𝑂 ( 1 ) . Thus, the optimal stable matching problem is fix ed-parameter tractable with respect to the minimum crossing distance of 𝐼 . Theorem 1.1 serves as a bridge betw een the polynomial-sol v ability of optimal stable matchings in the SM setting and the NP -hardness of the same problem in the SR setting by sho wing that the closer an SR instance is to an SM instance, the f aster it is find an optimal stable matc hing. W e belie ve that the approach w e hav e taken in this paper can be applied to other problems in stable matchings as w ell, transf or ming (polynomial-time or FPT) algorithms in SM to FPT algor ithms in SR so that the more similar an SR instance is to an SM instance, the f aster is the algorithm. Be y ond stable matchings, w e also suspect that the results here are g eneralizable to other combinatorial objects that f or m dis tr ibutiv e lattices in a classical setting (see [38] and [17] f or e xamples) but f or m median graphs in a more general one. In Chapters 2 and 3, w e present the stable marr iage (SM) and s table roommates (SR) problems and their associated structures, respectiv ely , f ocusing on their similarities and differences. W e then outline Irving et al.’ s tec hnique f or computing an optimal SM s table matching in Chapter 2 and sho w ho w it can be g eneralized to the SR setting in Chapter 3. In Chapter 4, we discuss median semilattices and how the y can be analyzed using oriented mir ror posets. In Chapter 5, w e connect the crossing edges of an oriented mir ror poset to the maximal elements of the corresponding median semilattices. Finall y , w e introduce the minimum crossing orientation problem in Chapter 6, prov e its hardness, present its FPT algor ithm and conclude with a proof of Theorem 1.1, our main result. Further R elated W or k As many variants of SM and SR are kno wn to be NP -hard, parameter ized complexity is becoming an increasingly popular tool to unders tand the complexity landscape of these problems [ 7 ]. Most of the literature in this area f ocuses on SM v ar iants, with relativ el y less w ork on SR. The w ork that is most closel y related to ours is Chen et al. [ 5 ], who give an FPT algor ithm f or the egalitarian stable matching problem in SR, parameterized by the eg alitar ian cost of a matching. As w e hav e already noted, the eg alitar ian stable matching problem is a special case of the optimal s table matc hing problem where 𝐶 ( 𝑎 , 𝑏 ) is the rank of 𝑏 in 𝑎 ’ s pref erence list. It is unlikel y that there is a relationship betw een the parameter w e used, the minimum crossing dis tance, and their parameter , the egalitarian cost of a matching. Indeed, the eg alitar ian cost could be Ω ( 𝑛 2 ) f or SR instances with minimum crossing distance 0. For SM, se veral w orks ha v e addressed the relationship betw een the combinator ial structure of rotation posets and the associated algor ithmic complexity of SM variants. Bhanagar et al. [ 3 ] show ed that cer tain pref erence restr ictions still yield sufficiently general rotation posets that certain procedures f or sampling stable marr iag es are inefficient. Subsequently , Cheng and R osenbaum [ 11 ] full y characterized the rotation poset s tructure of such SM instances, both pro ving NP hardness and providing FPT algorithms f or sev eral SM v ar iants. Gupta et al. [ 21 ] considered the comple xity of SM problems parameter ized b y the treewidth of the instances ’ poset. The y sho wed that both the balanced and se x-equal stable marr iag e problems are FPT when parameterized by the tree width of the rotation poset. 2 SM and the Optimal Stable Matching Pr oblem In the S table Marriag e problem (SM), there are 𝑛 men and 𝑛 w omen. Each ag ent has a pref erence list that ranks members of the opposite group in a linear order ing. A matching partitions the 2 𝑛 ag ents into 𝑛 pairs of men and w omen. Such a matching has a bloc king pair if there is a pair of man and w oman who pref er each 4 other o ver their partners in the matching. The goal is to find a stable matc hing , a matching with no blocking pairs. The seminal paper by Gale and Shaple y [ 18 ] in 1962 prov ed that ev er y SM instance 𝐼 has a stable matching. The y presented an algor ithm that computes one in 𝑂 ( 𝑛 2 ) time. Interestingl y , e ven though 𝐼 ma y hav e man y stable matchings, Gale and Shaple y’ s algor ithm can only output tw o types – the man-optimal/w oman-pessimal and the w oman-optimal/man-pessimal stable matchings. In the man-optimal stable matching, 𝜇 𝑀 , ev ery man is matched to his best stable partner and, simultaneously , ev er y w oman is matched to her wors t stable par tner . In the woman-optimal stable matching, 𝜇 𝑊 , the opposite is tr ue. The extremeness of both of these stable matchings motivates the problem of finding fair stable matchings, those that treat both g roups, and more broadl y all agents, equall y . In 1976, Knuth descr ibed the meta-structure of stable matchings that was communicated to him by Con wa y [ 34 , 35 ]. Let 𝑀 ( 𝐼 ) denote the set of all s table matchings of 𝐼 . For 𝜇 ∈ 𝑀 ( 𝐼 ) and ag ent 𝑎 , let 𝜇 ( 𝑎 ) denote the par tner of 𝑎 in 𝜇 . Define a par tial order ing on 𝑀 ( 𝐼 ) as follo w s: for 𝜇 , 𝜇 ′ ∈ 𝑀 ( 𝐼 ) , let 𝜇 ⪯ 𝜇 ′ if, f or each man 𝑚 , 𝜇 ( 𝑚 ) = 𝜇 ′ ( 𝑚 ) or 𝑚 pref ers 𝜇 ( 𝑚 ) to 𝜇 ′ ( 𝑚 ) . It tur ns out that ⪯ induces a distributiv e lattice M ( 𝐼 ) . The minimum element of M ( 𝐼 ) is 𝜇 𝑀 while its maximum element is 𝜇 𝑊 . As one traces a path from the minimum to the maximum element, the stable matchings g raduall y transf orm from 𝜇 𝑀 to 𝜇 𝑊 ; the partners of the men progressiv ely w orsen while the partners of the w omen progressiv ely impro v e. Searching the interior of M ( 𝐼 ) directl y f or a fair s table matching, ho we v er , is not feasible because 𝐼 can ha ve an e xponential number of stable matchings (see [30] and ref erences therein). Let P be a poset whose element set is 𝑃 . A subset 𝑆 ⊆ 𝑃 is closed if for ev ery element 𝑠 ∈ 𝑆 , all the predecessors of 𝑠 are also in 𝑆 . Let 𝐶 ( P ) contain all the closed subsets of P . It is easy to check that when the elements of 𝐶 ( P ) are ordered according to the subset relation, the result is a distributive lattice with ∅ as its minimum element and 𝑃 as its maximum element. A classic result by Birkhoff [ 4 ] in the late 1930’ s states the f ollo wing: Theorem 2.1 ([ 4 ]) . For e very (finite) distributive lattice D , there is a poset P D whose distributiv e lattice of closed subsets, ( 𝐶 ( P D ) , ⊆ ) , is isomor phic to D . W e shall refer to P D as the pose t that encodes t he elements of D because ev ery element of D cor responds to a closed subset of P D and vice v ersa. In Birkhoff’ s proof, P D is derived from D itself. It is the subposet induced b y the join-irr educible elements of D , where the join-ir reducible elements are the ones that hav e an in-degree of 1 in the Hasse diagram 2 of D . For stable matchings, ho we ver , Ir ving and Leather [ 28 ] pro v ed in the mid-1980’ s that the poset that encodes the stable matchings of 𝐼 can be der iv ed directly from the pref erence lists of 𝐼 . The y called it the r otation poset of 𝐼 . The poset contains rotations which are the minimal differences betw een tw o stable matchings. A r otation 𝜌 = ( 𝑚 0 , 𝑤 0 ) , ( 𝑚 1 , 𝑤 1 ) , . . . , ( 𝑚 𝑟 − 1 , 𝑤 𝑟 − 1 ) is a cy clic list of man-w oman pairs so that when 𝜌 is exposed in a stable matching 𝜇 , each ( 𝑚 𝑖 , 𝑤 𝑖 ) ∈ 𝜇 . When 𝜌 is eliminated from 𝜇 , the result is another stable matc hing 𝜇 / 𝜌 = 𝜇 − { ( 𝑚 𝑖 , 𝑤 𝑖 ) , 𝑖 = 0 , 1 , . . . , 𝑟 − 1 } ∪ { ( 𝑚 𝑖 , 𝑤 𝑖 + 1 ) , 𝑖 = 0 , 1 , . . . , 𝑟 − 1 } (1) where addition in the subscript is modulo 𝑟 . It can be sho wn that e very stable matc hing that is not 𝜇 𝑊 has an exposed rotation. Thus, star ting from 𝜇 𝑀 , rotations can be eliminated repeatedl y until 𝜇 𝑊 is reached. This process rev eals all the rotations of 𝐼 e xactly once. It is also the case that star ting at 𝜇 𝑀 , if 𝜇 can be obtained b y eliminating the rotations in set 𝑆 , then 𝑆 is unique to 𝜇 . That is, if 𝜇 can be obtained from 𝜇 𝑀 b y eliminating the rotations in 𝑆 ′ , then 𝑆 ′ = 𝑆 . Let 𝑅 ( 𝐼 ) contain all the rotations of 𝐼 . Ag ain, define a par tial order ing on 𝑅 ( 𝐼 ) as f ollow s: f or 𝜌 and 𝜎 ∈ 𝑅 ( 𝐼 ) , let 𝜌 ≤ 𝜎 if 𝜌 is eliminated bef ore 𝜎 in ev er y sequence of eliminations from 𝜇 𝑀 to 𝜇 𝑊 . The resulting poset, R ( 𝐼 ) , is the rotation pose t of 𝐼 . Here are the ke y results: 2 W e shall vie w the Hasse diagram of a poset as a directed graph where ev ery edge is directed from a low er v er tex to a higher one. 5 Theorem 2.2 ([ 23 , 28 ]) . Let 𝐼 be an SM instance and let R ( 𝐼 ) = ( 𝑅 ( 𝐼 ) , ⪯) be its rotation poset. The distributiv e lattice of stable matchings of 𝐼 , M ( 𝐼 ) , is isomor phic to the distributiv e lattice of the closed subsets of R ( 𝐼 ) , ( 𝐶 ( R ( 𝐼 ) ) , ⊆ ) . In par ticular , a stable matching 𝜇 of 𝐼 cor responds to the closed subset 𝑆 𝜇 of R ( 𝐼 ) iff starting from 𝜇 𝑀 , the rotations in 𝑆 𝜇 are e xactly the rotations that ha v e to be eliminated to obtain 𝜇 . Theorem 2.2 pro vides another wa y of unders tanding ho w the stable matc hings of 𝐼 are related in M ( 𝐼 ) . The closed subsets of R ( 𝐼 ) that corresponds to 𝜇 𝑀 and 𝜇 𝑊 are ∅ and 𝑅 ( 𝐼 ) respectiv ely . For 𝜇 , 𝜇 ′ ∈ 𝑀 ( 𝐼 ) , 𝜇 ⪯ 𝜇 ′ if and only if 𝑆 𝜇 ⊆ 𝑆 𝜇 ′ . Equall y significant, R ( 𝐼 ) can be constructed from the pref erence lists of 𝐼 efficientl y . Theorem 2.3 (See discussion in Section 3.3 of [ 23 ]) . Let 𝐼 be an SM instance consisting of 𝑛 men and 𝑛 w omen. Then 𝐼 has 𝑂 ( 𝑛 2 ) rotations. F ur ther more, a directed acy clic graph that represents 3 R ( 𝐼 ) can be constructed in 𝑂 ( 𝑛 2 ) time. Theorems 2.2 and 2.3 impl y that the rotation poset of 𝐼 is a pol ynomial-sized structure that encodes all the s table matchings of 𝐼 . It can be used to e xplore M ( 𝐼 ) without actuall y constructing M ( 𝐼 ) . This is e xactl y what Ir ving, Leather and Gusfield [ 29 ] did to find an eg alitarian stable matching and, more generall y , an optimal s table matching of 𝐼 . Optimal St able Matchings. F or SM instance 𝐼 , let 𝐶 ( 𝑎 , 𝑏 ) indicate ho w much agent 𝑎 likes agent 𝑏 , a member of the opposite group. The cost function 𝐶 f ollo ws the rule that for 𝑏 ≠ 𝑏 ′ , 𝐶 ( 𝑎 , 𝑏 ) ≠ 𝐶 ( 𝑎 , 𝑏 ′ ) (i.e., no ties are allo w ed) and 𝐶 ( 𝑎 , 𝑏 ) < 𝐶 ( 𝑎 , 𝑏 ′ ) if and onl y if 𝑎 pref ers 𝑏 to 𝑏 ′ . The cost of a stable matching 𝜇 is 𝐶 ( 𝜇 ) =  ( 𝑚 , 𝑤 ) ∈ 𝜇 𝐶 ( 𝑚 , 𝑤 ) + 𝐶 ( 𝑤 , 𝑚 ) . The value of 𝐶 ( 𝜇 ) captures the dissatisfaction of the agents as a whole with respect to their matches in 𝜇 . Giv en 𝐼 and 𝐶 , the objectiv e is to find an optimal stable matc hing , a stable matc hing whose cost is the least among all the stable matc hings of 𝐼 . When 𝐶 ( 𝑎 , 𝑏 ) is the rank of 𝑏 in 𝑎 ’ s pref erence list (i.e., the number of ag ents 𝑎 pref ers to 𝑏 ), an optimal stable matching of 𝐼 is ref er red to as an eg alitarian stable matching of 𝐼 . It is arguabl y a fair s table matching because it treats all ag ents the same wa y . Let 𝜌 = ( 𝑚 0 , 𝑤 0 ) , ( 𝑚 1 , 𝑤 1 ) , . . . , ( 𝑚 𝑟 − 1 , 𝑤 𝑟 − 1 ) be a rotation of 𝐼 . Define the cost of 𝜌 with respect to 𝐶 as 𝐶 ( 𝜌 ) = 𝑟 − 1  𝑖 = 0 [ 𝐶 ( 𝑚 𝑖 , 𝑤 𝑖 ) + 𝐶 ( 𝑤 𝑖 , 𝑚 𝑖 ) ] − 𝑟 − 1  𝑖 = 0 [ 𝐶 ( 𝑚 𝑖 , 𝑤 𝑖 + 1 ) + 𝐶 ( 𝑤 𝑖 + 1 , 𝑚 𝑖 ) ] . Suppose 𝜌 is e xposed in stable matching 𝜇 . Then from equation (1), 𝐶 ( 𝜇 / 𝜌 ) = 𝐶 ( 𝜇 ) − 𝑟 − 1  𝑖 = 0 [ 𝐶 ( 𝑚 𝑖 , 𝑤 𝑖 ) + 𝐶 ( 𝑤 𝑖 , 𝑚 𝑖 ) ] + 𝑟 − 1  𝑖 = 0 [ 𝐶 ( 𝑚 𝑖 , 𝑤 𝑖 + 1 ) + 𝐶 ( 𝑤 𝑖 + 1 , 𝑚 𝑖 ) ] = 𝐶 ( 𝜇 ) − 𝐶 ( 𝜌 ) . Combining this observation with Theorem 2.2, the ne xt result f ollow s: Theorem 2.4 ([ 29 ]) . Let 𝜇 be a stable matching of 𝐼 and let 𝑆 𝜇 be the closed subset in R ( 𝐼 ) that it cor responds to. Then 𝐶 ( 𝜇 ) = 𝐶 ( 𝜇 𝑀 ) − Í 𝜌 ∈ 𝑆 𝜇 𝐶 ( 𝜌 ) . For an y closed subset 𝑆 of R ( 𝐼 ) , let the cost of 𝑆 be 𝐶 ( 𝑆 ) = Í 𝜌 ∈ 𝑆 𝐶 ( 𝜌 ) . In the abo ve theorem, 𝐶 ( 𝜇 𝑀 ) is fix ed. Thus, we can reduce the problem of finding an optimal stable matc hing of 𝐼 to finding a closed subset of R ( 𝐼 ) with maximum cos t . The latter has been s tudied by other researchers (e.g. [ 37 ], [ 24 ], etc.) and can be sol ved b y computing a minimum cut of a flo w netw ork based on R ( 𝐼 ) . 3 More precisely , the transitive closure of this directed acy clic graph contains all the relations in R ( 𝐼 ) . 6 Theorem 2.5 ([ 29 ]) . Given an SM ins tance 𝐼 with 𝑛 men and 𝑚 w omen, an egalitarian stable matching of 𝐼 can be computed in 𝑂 ( 𝑛 4 ) while an optimal stable matching of 𝐼 can be computed in 𝑂 ( 𝑛 4 log 𝑛 ) time. The slight impro v ement in the running time f or the egalitarian stable matching is due to the fact the minimum cut has a nice bound and the edge w eights on the flo w netw ork are integ ral. In [ 14 ], Feder cites an 𝑂 ( 𝑛 3 log 𝑛 ) algorithm f or computing an egalitarian stable matching. 3 SR and the Optimal Stable Matching Pr oblem The Stable R oommates problem (SR) is the non-bipartite v ersion of SM. There are 2 𝑛 ag ents and each one has a pref erence list that orders all the other agents linear l y . The goal again is to find a stable matching. Gale and Shaple y [ 18 ] descr ibed SR in their or iginal paper and pointed out that, unlike SM, some SR instances are unsolv able in that they ha v e no stable matchings. In 1985, Ir ving [ 26 ] finally sol v ed SR, presenting an 𝑂 ( 𝑛 2 ) algorithm that outputs a stable matching f or the solv able instances and reports none f or the unsolv able ones. From here on, we shall only consider SR instances that are sol vable. Let 𝐼 be one of them. Irving’ s algorithm has two phases. In phase 1, the pref erence lists of 𝐼 are transf or med into the phase-1 table 𝑇 0 . In phase 2, starting from 𝑇 0 , e xposed ro tations are eliminated ov er and o v er again until none e xists. This process transf or ms 𝑇 0 into smaller and smaller tables; the final table is equiv alent to a stable matc hing 𝜇 . When 𝑍 is the set of rotations eliminated from 𝑇 0 to obtain 𝜇 , 𝜇 = 𝑇 0 / 𝑍 . W e shall descr ibe Irving’s algor ithm in more detail and define ter ms precisely in the appendix. One impor tant fact to note though is that Ir ving’ s algor ithm does not alwa ys output the same stable matching. The set of rotations eliminated by the algor ithm deter mines the outcome. That is, suppose 𝜇 = 𝑇 0 / 𝑍 and 𝜇 ′ = 𝑇 0 / 𝑍 ′ . Then 𝜇 = 𝜇 ′ if and onl y if 𝑍 = 𝑍 ′ . For an SR instance 𝐼 , let 𝑅 ( 𝐼 ) contain all the e xposed rotations that can be eliminated during an e xecution of phase 2 of Irving’s algor ithm. Like SM, a ro tation 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) in this conte xt is a cy clic sequence of ordered pairs of agents that satisfies cer tain proper ties. If 𝜌 = ( 𝑦 1 , 𝑥 0 ) , ( 𝑦 2 , 𝑥 1 ) , . . . , ( 𝑦 0 , 𝑥 𝑟 − 1 ) is also in 𝑅 ( 𝐼 ) , then 𝜌 is a non-singular rotation; otherwise, 𝜌 is a singular rotation. If 𝜌 is non-singular , then 𝜌 is ref er red to as the dual of 𝜌 . Notice that 𝜌 is also non-singular and its dual is 𝜌 so { 𝜌 , 𝜌 } is a dual pair of non-singular rotations of 𝐼 . Theorem 3.1 ([ 23 , Theorem 4.3.1]) . Let 𝜇 be a stable matching of 𝐼 . If 𝜇 = 𝑇 0 / 𝑍 , then 𝑍 contains ev ery singular rotation and e xactly one of eac h dual pair of non-singular rotations of 𝐼 . Just like in the SM setting, a poset can be created from 𝑅 ( 𝐼 ) . For 𝜎 , 𝜌 ∈ 𝑅 ( 𝐼 ) , let 𝜎 ≤ 𝜌 if f or e v er y sequence of eliminations in the phase 2 of Irving’ s algor ithm in which 𝜌 appears, 𝜎 appears bef ore 𝜌 . The poset R ( 𝐼 ) = ( 𝑅 ( 𝐼 ) , ≤) is the ro tation poset of 𝐼 . Here are some proper ties about the order ing ≤ : Lemma 3.2. (Lemma 4.3.7 in [ 23 ].) Let 𝜌 and 𝜎 be non-singular rotations and 𝜏 be a singular rotation of 𝐼 . Then (i) 𝜌 and 𝜌 are incomparable elements in R ( 𝐼 ) ; (ii) 𝜎 ≤ 𝜌 if and only if 𝜌 ≤ 𝜎 ; (iii) an y predecessor of 𝜏 in R ( 𝐼 ) is a singular rotation. Let 𝑅 ′ ( 𝐼 ) consist of all the non-singular rotations of 𝐼 . Let R ′ ( 𝐼 ) be the subposet induced b y 𝑅 ′ ( 𝐼 ) ; it is ref er red to as the reduced r otation poset of 𝐼 . A subset 𝑆 ⊆ 𝑅 ′ ( 𝐼 ) is complete if it contains ex actly one of each dual pair of rotations of 𝐼 . It is closed if whene ver 𝜌 ∈ 𝑆 , all the predecessors of 𝜌 are also in 𝑆 . Here are the counter parts of Theorems 2.2 and 2.3: Theorem 3.3 ([ 22 , 27 ]) . Let 𝐼 be an SR instance and let R ′ ( 𝐼 ) = ( 𝑅 ′ ( 𝐼 ) , ≤) be its reduced rotation poset. There is a one-to-one correspondence between the s table matchings of 𝐼 and the complete closed subsets of 7 R ′ ( 𝐼 ) . In par ticular , a stable matc hing 𝜇 of 𝐼 cor responds to the complete closed subset 𝑆 𝜇 of R ′ ( 𝐼 ) if and onl y if starting from 𝑇 0 , all the singular rotations of 𝐼 and all the rotations in 𝑆 𝜇 are e xactly the rotations that ha ve to be eliminated to obtain 𝜇 . Theorem 3.4 (See discussion in Section 4.4.1 in [ 23 ]) . Let 𝐼 be an SR instance with 2 𝑛 ag ents. Then 𝐼 has 𝑂 ( 𝑛 2 ) rotations. Further more, a directed acyclic g raph that represents R ′ ( 𝐼 ) can be constructed in 𝑂 ( 𝑛 3 log 𝑛 ) time. Corollary 3.5. Let 𝐼 be an SR instance with 2 𝑛 ag ents and let R ′ ( 𝐼 ) its reduced rotation poset. Giv en a complete closed subset 𝑆 of R ′ ( 𝐼 ) , the stable matc hing of 𝐼 that cor responds to 𝑆 can be obtained in 𝑂 ( 𝑛 2 ) time. Pr oof. See appendix. □ Thus, like the SM setting, there is a pol ynomial-sized structure that encodes the stable matc hings of an SR instance I. What is missing from this discussion though is the meta-structure of the stable matchings of 𝐼 . Indeed, it was not until the w ork of Cheng and Lin [ 10 ] in 2011 that this meta-str ucture w as fully unders tood. The y took a combinator ial approach and vie wed R ′ ( 𝐼 ) in g eneral ter ms, calling it a mirror pose t . Definition 3.6. In a mir ror poset P = ( 𝑃 , ≤) , the element set 𝑃 is par titioned into dual pairs of elements, where the dual of 𝜌 ∈ 𝑃 is denoted as 𝜌 , such that (i) f or each 𝜌 ∈ 𝑃 , 𝜌 and its dual 𝜌 are incomparable and (ii) f or any 𝜎 , 𝜌 ∈ 𝑃 , 𝜎 ≤ 𝜌 if and only if 𝜌 ≤ 𝜎 . A subset 𝑆 ⊆ 𝑃 is par tially complet e if it contains at most one element from each dual pair in P ; it is complet e if it contains exactly one element from each pair in P . It is closed whenev er 𝜌 ∈ 𝑆 , ev er y predecessor of 𝜌 is also in 𝑆 . Definition 3.7. A g raph 𝐺 = ( 𝑉 , 𝐸 ) is a median graph if f or any three v ertices 𝑢 , 𝑣 , 𝑤 , there e xists a unique v er te x that lies in a shor test path from 𝑢 to 𝑣 , 𝑢 to 𝑤 and 𝑣 to 𝑤 . As w e shall see, mir ror posets are related to median graphs, a w ell-studied class of graphs that includes h ypercubes, trees and the co ver graphs 4 of distributiv e lattices. Median g raphs are connected, bipartite and ha ve at mos t | 𝑉 | log 2 | 𝑉 | edges [25]. Theorem 3.8 ([ 10 , Corollary 1 and Lemma 4]) . Let P be a mir ror poset. Denote as 𝐺 ( P ) the graph whose v er tices are the complete closed subsets of P and where an y tw o of them are adjacent if and only if the y differ b y one dual element. Then 𝐺 ( P ) is a median g raph. Moreov er , f or any tw o closed subsets 𝑆 and 𝑆 ′ of P , their distance in 𝐺 ( P ) is 𝑑 ( 𝑆 , 𝑆 ′ ) = | 𝑆 − 𝑆 ′ | = | 𝑆 ′ − 𝑆 | . Figure 2 sho w s an e xample of a mir ror poset and the median graph formed b y its complete closed subsets. Using the cor respondence described in Theorem 3.3, we no w ha v e a meta-str ucture f or the stable matc hings of 𝐼 : Corollary 3.9 ([ 10 ]) . For an SR ins tance 𝐼 , let 𝐺 ( 𝐼 ) denote the graph whose v er tices are the stable matc hings of 𝐼 and an y two s table matchings 𝜇 and 𝜇 ′ are adjacent if and onl y if 𝑆 𝜇 and 𝑆 𝜇 ′ differ b y one rotation. Then 𝐺 ( 𝐼 ) is a median graph. Moreo ver , f or stable matchings 𝜇 and 𝜂 , their dis tance in 𝐺 ( 𝐼 ) is | 𝑆 𝜇 − 𝑆 𝜂 | = | 𝑆 𝜂 − 𝑆 𝜇 | . 4 If P is a poset, the cov er graph of P is the undirected v ersion of the Hasse diagram of P . 8 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 Figure 2: On the left is a mir ror poset P with five dual pairs. On the r ight is the median graph 𝐺 ( P ) f or med by its sev en complete closed subsets. T w o subsets are adjacent in the median graph if and only if the y differ by one element. It is interesting that median graphs, the meta-str uctures f or SR stable matchings, are unordered while distributiv e lattices, the meta-str uctures f or SM stable matc hings, are ordered. The difference has to do with the fact that SM instances hav e tw o sides – the men and the w omen – and these tw o sides are responsible f or the meet and join operation and, consequentl y , the minimum and maximum elements of the distributiv e lattices. In contrast, there are no sides to SR instances and theref ore creating an order ing f or their stable matchings is less natural. Optimal Stable Matchings W e no w consider the optimal s table matching problem f or SR instance 𝐼 . As bef ore, there is a cos t function 𝐶 so that f or dis tinct agents 𝑎 , 𝑏 , 𝑏 ′ , 𝐶 ( 𝑎 , 𝑏 ) ≠ 𝐶 ( 𝑎 , 𝑏 ′ ) and 𝐶 ( 𝑎 , 𝑏 ) < 𝐶 ( 𝑎 , 𝑏 ′ ) if and onl y if 𝑎 prefers 𝑏 to 𝑏 ′ . The cost of a stable matc hing 𝜇 is 𝐶 ( 𝜇 ) =  { 𝑎 , 𝑏 } ∈ 𝜇 𝐶 ( 𝑎 , 𝑏 ) + 𝐶 ( 𝑏 , 𝑎 ) . A stable matching of 𝐼 with the least cost is an optimal s table matc hing . When 𝐶 ( 𝑎 , 𝑏 ) is the rank of 𝑏 in 𝑎 ’ s pref erence list, then an optimal s table matching of 𝐼 is also called an eg alitarian stable matc hing of 𝐼 . The structural similarities between SM s table matchings and SR s table matchings sugg est that the approach f or finding an optimal s table matching in the SM setting might work in the SR setting. T o do so, ho we v er , w e need a result similar to equation (1) that describes ho w two adjacent s table matchings in M ( 𝐼 ) are related. Lemma 3.10. Let 𝜇 and 𝜇 ′ be two stable matchings of SR instance 𝐼 that are adjacent in 𝐺 ( 𝐼 ) . Let 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) be the rotation so that 𝑆 𝜇 ′ − 𝑆 𝜇 = { 𝜌 } . Then 𝜇 ′ = 𝜇 − { { 𝑥 0 , 𝑦 0 } , { 𝑥 1 , 𝑦 1 } , . . . , { 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 } } ∪ { { 𝑥 0 , 𝑦 1 } , { 𝑥 1 , 𝑦 2 } , . . . , { 𝑥 𝑟 − 1 , 𝑦 0 } } . Pr oof. See appendix. □ Pro ving the lemma abo v e is more complicated because the rotations of 𝐼 are exposed with respect to tables rather than stable matc hings. W e work out the details in the appendix. For rotation 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) , let us define its cost as 𝐶 ( 𝜌 ) = 𝑟 − 1  𝑖 = 0 [ 𝐶 ( 𝑥 𝑖 , 𝑦 𝑖 ) + 𝐶 ( 𝑦 𝑖 , 𝑥 𝑖 ) ] − 𝑟 − 1  𝑖 = 0 [ 𝐶 ( 𝑥 𝑖 , 𝑦 𝑖 + 1 ) + 𝐶 ( 𝑦 𝑖 + 1 , 𝑥 𝑖 ) ] where the addition in the subscript is modulo 𝑟 . Theorem 3.11. Let 𝜇 and 𝜇 ′ be tw o stable matchings of SR ins tance 𝐼 . Then 𝐶 ( 𝜇 ′ ) = 𝐶 ( 𝜇 ) −  𝜌 ∈ 𝑆 𝜇 ′ − 𝑆 𝜇 𝐶 ( 𝜌 ) . 9 Pr oof. From Corollar y 3.9, the distance between 𝜇 and 𝜇 ′ in 𝐺 ( 𝐼 ) is | 𝑆 𝜇 ′ − 𝑆 𝜇 | . Assume | 𝑆 𝜇 ′ − 𝑆 𝜇 | = ℓ . Then there is a path Ψ from 𝜇 to 𝜇 ′ in 𝐺 ( 𝐼 ) so that Ψ = ( 𝜇 0 , 𝜇 1 , . . . , 𝜇 ℓ ) with 𝜇 0 = 𝜇 and 𝜇 ℓ = 𝜇 ′ . For simplicity , let 𝑆 𝑖 = 𝑆 𝜇 𝑖 f or 𝑖 = 0 , . . . , ℓ . Assume 𝜌 ∈ 𝑆 𝜇 ′ − 𝑆 𝜇 . Then 𝜌 ∈ 𝑆 𝜇 because 𝑆 𝜇 is a complete subset of R ′ ( 𝐼 ) . It must also be the case that f or some 𝑖 , 𝑆 𝑖 − 𝑆 𝑖 − 1 = { 𝜌 } . Other wise, 𝜌 ∈ 𝑆 0 , 𝑆 1 , . . . , 𝑆 ℓ . Since 𝑆 ℓ = 𝑆 𝜇 ′ and 𝜌 ∈ 𝑆 𝜇 ′ , both 𝜌 and 𝜌 are in 𝑆 𝜇 ′ , a contradiction. Hence, every element in 𝑆 𝜇 ′ − 𝑆 𝜇 can be found in ∪ ℓ 𝑖 = 1 ( 𝑆 𝑖 − 𝑆 𝑖 − 1 ) . That is, | ∪ ℓ 𝑖 = 1 ( 𝑆 𝑖 − 𝑆 𝑖 − 1 ) | ≥ ℓ . But ∪ ℓ 𝑖 = 1 ( 𝑆 𝑖 − 𝑆 𝑖 − 1 ) cannot ha ve more than ℓ elements since | 𝑆 𝑖 − 𝑆 𝑖 − 1 | = 1 f or each 𝑖 . Thus, ∪ ℓ 𝑖 = 1 ( 𝑆 𝑖 − 𝑆 𝑖 − 1 ) = 𝑆 𝜇 ′ − 𝑆 𝜇 . Let 𝑆 𝑖 − 𝑆 𝑖 − 1 = 𝜌 𝑖 f or 𝑖 = 1 , . . . , ℓ . From our discussion, 𝑆 𝜇 ′ − 𝑆 𝜇 = { 𝜌 1 , 𝜌 2 , . . . , 𝜌 ℓ } . Lemma 3.10 implies that 𝐶 ( 𝜇 𝑖 ) = 𝐶 ( 𝜇 𝑖 − 1 ) − 𝐶 ( 𝜌 𝑖 ) f or 𝑖 = 1 , . . . , ℓ . Thus, 𝐶 ( 𝜇 ℓ ) = 𝐶 ( 𝜇 ℓ − 1 ) − 𝐶 ( 𝜌 ℓ ) = [ 𝐶 ( 𝜇 ℓ − 2 ) − 𝐶 ( 𝜌 ℓ − 1 ) ] − 𝐶 ( 𝜌 ℓ ) = [ 𝐶 ( 𝜇 ℓ − 3 ) − 𝐶 ( 𝜌 ℓ − 2 ) ] − 𝐶 ( 𝜌 ℓ − 1 ) − 𝐶 ( 𝜌 ℓ ) . . . = 𝐶 ( 𝜇 0 ) − 𝐶 ( 𝜌 1 ) − 𝐶 ( 𝜌 2 ) − · · · − 𝐶 ( 𝜌 ℓ ) = 𝐶 ( 𝜇 0 ) −  𝜌 ∈ 𝑆 𝜇 ′ − 𝑆 𝜇 𝐶 ( 𝜌 ) . □ Notice that Theorem 3.11 is quite similar to Theorem 2.4. If 𝜇 is fix ed, then finding an optimal stable matching of 𝐼 is equiv alent to finding a complete closed subset 𝑆 of R ′ ( 𝐼 ) that maximizes Í 𝜌 ∈ 𝑆 − 𝑆 𝜇 𝐶 ( 𝜌 ) . U nfortunately , this is not an easy problem. Feder [ 14 , 15 ] has sho wn that computing an egalitarian stable matching in the SR setting is NP -hard. Nonetheless, this approach to finding an optimal stable matc hing can still be fruitful. 4 Median Semilattices and Local Optima W e hav e already noted that the meta-structure of an SR instance ’ s stable matc hings is unordered. But it is still possible to impose an order ing on it because median graphs can be transformed into an ordered str ucture called a median semilattice . Definition 4.1. A median semilattice L is a meet semilattice (i.e., the greatest low er bound of any tw o elements alw ay s e xists) such that (i) f or an y element 𝑣 , the subposet induced b y 𝑣 and its predecessors is a distributiv e lattice and (ii) an y three elements ha v e an upper bound whenev er any tw o of them ha ve an upper bound. The ne xt proposition states when a median semilattice is a distributiv e lattice. Proposition 4.2. A median semilattice L is a distributiv e lattice if and only if it has a maximum element. Pr oof. Let ˆ 0 be the minimum element of L . Suppose L has a maximum element ˆ 1 . From the definition of median semilattices, the subposet induced ˆ 1 and its predecessors is a distributiv e lattice. But this subposet contains all the elements of L so L itself is a distr ibutiv e lattice. On the other hand, if L is a distributive lattice, it must ha v e a maximum element by definition. □ Let 𝐺 be a connected graph and 𝑢 be a v er te x of 𝐺 . The canonical or der ⊑ 𝑢 induces a partial order ing on the v er tices 𝐺 as f ollow s: f or vertices 𝑣 and 𝑤 , 𝑣 ⊑ 𝑢 𝑤 if and only if 𝑑 ( 𝑢 , 𝑤 ) = 𝑑 ( 𝑢 , 𝑣 ) + 𝑑 ( 𝑣 , 𝑤 ) . That is, 10 𝑣 ⊑ 𝑢 𝑤 if and only if 𝑣 lies on a shor test path from 𝑢 to 𝑤 . A result by A v ann [ 1 ] connects median graphs to median semilattices. Cheng and Lin [10] clar ifies the co v er graph of the median semilattices. Theorem 4.3. ([ 1 , 10 ] From median graphs to median semilattices.) Let 𝐺 = ( 𝑉 , 𝐸 ) be a median graph and 𝑢 be a v er te x of 𝐺 . The poset ( 𝑉 , ⊑ 𝑢 ) is a median semilattice whose minimum element is 𝑢 . Moreo ver , the co ver graph of ( 𝑉 , ⊑ 𝑢 ) is 𝐺 . An implication of the theorem is that if we take a median graph 𝐺 , root it at one of its vertices 𝑢 and direct all the edges of 𝐺 a wa y from 𝑢 , the result is the Hasse diag ram of the median semilattice ( 𝑉 , ⊑ 𝑢 ) . For this reason, we refer to ( 𝑉 , ⊑ 𝑢 ) as the median semilattice obtained by roo ting 𝐺 at 𝑢 . Note that the same result holds if 𝑢 is replaced b y another verte x 𝑣 of 𝐺 . Thus, a median g raph 𝐺 can be transf or med into one or mor e median semilattices. Figures 3 and 4 ha v e some ex amples. Suppose P = ( 𝑃 , ≤) is a mir ror poset. Let 𝐺 ( P ) be the median graph f or med by the complete closed subsets of P as descr ibed in Theorem 3.8. R oot 𝐺 ( P ) at a complete closed subset 𝑊 . According to our discussion abo ve, it results in a median semilattice, which w e denote as L ( P , 𝑊 ) with order ing relation ⊑ 𝑊 . T o better understand L ( P , 𝑊 ) , we now introduce the notion of orienting P . One wa y of thinking about L ( P , 𝑊 ) is that w e are viewing 𝐺 ( P ) from the perspectiv e of 𝑊 . A cor responding action on P is to orient P at 𝑊 . Definition 4.4. Let P = ( 𝑃 , ≤) be a mirror poset. An orientation of P is a partitioning of 𝑃 into 𝑃 − ∪ 𝑃 + where 𝑃 − is a complete closed subset of P and 𝑃 + = 𝑃 − 𝑃 − . W e denote this orientation as P = ( 𝑃 − ∪ 𝑃 + , ≤) and sa y that P is orient ed at 𝑃 − and the base of the orientation is P . The cr ossing edg es of P = ( 𝑃 − ∪ 𝑃 + , ≤) are the edges between 𝑃 − and 𝑃 + in the Hasse diagram of P . When P is already or iented at 𝑃 − and the median graph 𝐺 ( P ) is rooted at 𝑃 − , w e refer to the resulting median semilattice L ( P , 𝑃 − ) simpl y as L ( 𝑃 ) . In our discussion, we call the elements in 𝑃 − and 𝑃 + as the neg ativ e and positiv e elements of P respectiv ely . Since 𝑃 − is a complete subset of P , ev er y dual pair of elements has ex actly one element in 𝑃 − and one element in 𝑃 + . Thus, f or each dual pair { 𝜌 , 𝜌 } , w e shall rename the elements as { 𝜌 − , 𝜌 + } where 𝜌 − ∈ 𝑃 − and 𝜌 + ∈ 𝑃 + . A dditionally , because 𝑃 − is a closed subset of P , none of its elements has a predecessor in 𝑃 + so an y crossing edges of P = ( 𝑃 − ∪ 𝑃 + , ≤) must be directed from 𝑃 − to 𝑃 + . For this reason, when we illustrate an orientation of P , the elements of 𝑃 − are at the bottom while the elements of 𝑃 + are at the top. See Figures 3 and 4 ag ain f or some ex amples. Suppose P = ( 𝑃 − ∪ 𝑃 + , ≤) and 𝑄 ⊆ 𝑃 − ∪ 𝑃 + . Let 𝑄 − = 𝑄 ∩ 𝑃 − and 𝑄 + = 𝑄 ∩ 𝑃 + . The ne xt lemma pro vides a simple wa y of deter mining when tw o complete closed subsets of P are comparable in L ( P ) . Lemma 4.5. Let P = ( 𝑃 − ∪ 𝑃 + , ≤) and let 𝑆 and 𝑇 be tw o complete closed subsets of P . Then, 𝑆 ⊑ 𝑇 in L ( P ) if and only if 𝑆 + ⊆ 𝑇 + . Pr oof. Consider the complete closed subsets 𝑆 and 𝑇 . By conv ention, L ( P ) is rooted at 𝑃 − so 𝑆 ⊑ 𝑇 if and onl y if 𝑆 ⊑ 𝑃 − 𝑇 . Using the definition of ⊑ 𝑃 − and the f act that 𝑃 − contains onl y negativ e elements, we ha v e 𝑆 ⊑ 𝑃 − 𝑇 ⇐ ⇒ 𝑑 ( 𝑃 − , 𝑇 ) = 𝑑 ( 𝑃 − , 𝑆 ) + 𝑑 ( 𝑆 , 𝑇 ) ⇐ ⇒ | 𝑇 + | = | 𝑆 + | + 𝑑 ( 𝑆 , 𝑇 ) ⇐ ⇒ 𝑑 ( 𝑆 , 𝑇 ) = | 𝑇 + | − | 𝑆 + | . But from Theorem 3.8, 𝑑 ( 𝑆 , 𝑇 ) = | 𝑇 − 𝑆 | = | 𝑇 + − 𝑆 + | + | 𝑇 − − 𝑆 − | so 𝑆 ⊑ 𝑃 − 𝑇 ⇐ ⇒ | 𝑇 + − 𝑆 + | + | 𝑇 − − 𝑆 − | = | 𝑇 + | − | 𝑆 + | . (2) Assume 𝑆 + ⊆ 𝑇 + . Since both 𝑆 and 𝑇 are complete closed subsets of P , 𝑇 − ⊆ 𝑆 − . It f ollo ws that | 𝑇 + − 𝑆 + | = | 𝑇 + | − | 𝑆 + | while | 𝑇 − − 𝑆 − | = 0 . The r ight-hand side of (2) is satisfied, so when 𝑆 + ⊆ 𝑇 + , it is the case that 𝑆 ⊑ 𝑃 − 𝑇 . 11 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 − 1 𝜌 − 2 𝜌 − 3 𝜌 − 4 𝜌 − 5 𝜌 + 1 𝜌 + 2 𝜌 + 3 𝜌 + 4 𝜌 + 5 𝜌 − 1 𝜌 − 2 𝜌 + 3 𝜌 − 4 𝜌 − 5 𝜌 − 1 𝜌 − 2 𝜌 − 3 𝜌 − 4 𝜌 − 5 𝜌 − 1 𝜌 − 2 𝜌 − 3 𝜌 4 + 𝜌 − 5 𝜌 − 1 𝜌 − 2 𝜌 − 3 𝜌 − 4 𝜌 5 + 𝜌 − 1 𝜌 − 2 𝜌 − 3 𝜌 4 + 𝜌 5 + 𝜌 − 1 𝜌 2 + 𝜌 − 3 𝜌 − 4 𝜌 5 + 𝜌 1 + 𝜌 − 2 𝜌 − 3 𝜌 4 + 𝜌 5 + Figure 3: At the top left is the median semilattice L ( P , 𝑊 ) f or med b y rooting the median graph 𝐺 ( P ) in Figure 2 at the complete closed subset 𝑊 = { 𝜌 1 , 𝜌 2 , 𝜌 3 , 𝜌 4 , 𝜌 5 } . It has three maximal elements. At the bottom left is the mirror poset P oriented at 𝑊 ; the lo wer half of P consists of the elements of 𝑊 and the other half has the elements of 𝑃 − 𝑊 . Each 𝜌 𝑖 is renamed as 𝜌 − 𝑖 and its dual as 𝜌 + 𝑖 . The renamed poset is shown on the bottom right. It has three pairs of crossing edges from P − to P + : { ( 𝜌 − 2 , 𝜌 + 4 ) , ( 𝜌 − 4 , 𝜌 + 2 ) } , { ( 𝜌 − 3 , 𝜌 + 4 ) , ( 𝜌 − 4 , 𝜌 + 3 ) } and { ( 𝜌 − 3 , 𝜌 + 5 ) , ( 𝜌 − 5 , 𝜌 + 3 ) } . At the top right, the complete closed subsets of P are updated to reflect the change in the naming con v ention. 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 1 𝜌 2 𝜌 3 𝜌 4 𝜌 5 𝜌 − 1 𝜌 − 2 𝜌 + 3 𝜌 − 4 𝜌 − 5 𝜌 + 1 𝜌 + 2 𝜌 − 3 𝜌 + 4 𝜌 + 5 Figure 4: This time around, the median graph 𝐺 ( P ) in Figure 2 is rooted at 𝑊 = { 𝜌 1 , 𝜌 2 , 𝜌 3 , 𝜌 4 , 𝜌 5 } to create another median semilattice. This semilattice has tw o maximal elements. By our conv ention, P is oriented with 𝑊 as the base and the rotations are renamed to reflect this orientation. The resulting poset on the r ight has onl y one pair of crossing edges: { ( 𝜌 − 2 , 𝜌 + 4 ) , ( 𝜌 − 4 , 𝜌 + 2 ) } . 12 Con versel y , assume 𝑆 ⊑ 𝑃 − 𝑇 . From the r ight-hand side of (2), | 𝑇 − − 𝑆 − | = ( | 𝑇 + | − | 𝑆 + | ) − | 𝑇 + − 𝑆 + | . But f or an y complete closed subsets 𝑆 and 𝑇 , | 𝑇 + − 𝑆 + | ≥ | 𝑇 + | − | 𝑆 + | so | 𝑇 − − 𝑆 − | ≤ 0 . Since | 𝑇 − − 𝑆 − | cannot be less than 0, it f ollo ws that | 𝑇 − − 𝑆 − | = 0. That is, 𝑇 − ⊆ 𝑆 − so 𝑆 + ⊆ 𝑇 + . □ For any complete closed subset 𝑇 of P = ( 𝑃 − ∪ 𝑃 + , ≤) , define the interval [ 𝑃 − , 𝑇 ] in L ( P ) as [ 𝑃 − , 𝑇 ] = { 𝑆 : 𝑃 − ⊑ 𝑊 𝑆 ⊑ 𝑊 𝑇 } . Since 𝑃 − is the minimum element of L ( P ) , [ 𝑃 − , 𝑇 ] consists of 𝑇 and all the predecessors of 𝑇 in L ( P ) . From the definition of median semilattices, the subposet induced b y the elements in [ 𝑃 − , 𝑇 ] is a distributiv e lattice. No w , according to Birkhoff’ s result in Theorem 2.1, there must be a poset that encodes the elements of [ 𝑃 − , 𝑇 ] . W e want to identify this poset ne xt. Theorem 4.6. Let P = ( 𝑃 − ∪ 𝑃 + , ≤) and let 𝑇 be a complete closed subset of P . Denote as P 𝑇 + the subposet of P induced by the elements of 𝑇 + . There is a one-to-one cor respondence betw een the complete closed subsets in the inter v al [ 𝑃 − , 𝑇 ] of L ( P ) and the closed subsets of P 𝑇 + . In par ticular , 𝑆 ∈ [ 𝑃 − , 𝑇 ] if and only if 𝑆 + is a closed subset of P 𝑇 + . Pr oof. Assume 𝑆 ∈ [ 𝑃 − , 𝑇 ] . Then 𝑆 ⊑ 𝑇 in L ( P ) . By Lemma 4.5, 𝑆 + ⊆ 𝑇 + . W e jus t ha v e to argue that 𝑆 + a closed subset of P 𝑇 + . Let 𝜌 + ∈ 𝑆 + . If 𝜎 + ≤ 𝜌 + in P 𝑇 + , then 𝜎 + ≤ 𝜌 + in P . No w , 𝑆 itself is a closed subset of P so e v er y predecessor of 𝜌 + , whether positiv e or negativ e, is in 𝑆 . Thus, 𝜎 + ∈ 𝑆 + and, theref ore, 𝑆 + is a closed subset of P 𝑇 + . Ne xt, let 𝑆 + be a closed subset of P 𝑇 + . It f ollo ws that 𝑆 = 𝑆 + ∪ { 𝜏 − ∈ 𝑃 − : 𝜏 + ∉ 𝑆 + } is a complete subset of P . W e will show that 𝑆 is also a closed subset of P . Case 1: Let 𝜌 + ∈ 𝑆 . It means that 𝜌 + ∈ 𝑆 + . Since 𝑆 + ⊆ 𝑇 + and 𝑇 + ⊆ 𝑇 , it f ollo ws that 𝜌 + ∈ 𝑇 . No w 𝑇 is a complete closed subset of P so all the predecessors of 𝜌 + , whether positiv e or negativ e, are also in 𝑇 . In par ticular , (i) if 𝜎 + ≤ 𝜌 + , then 𝜎 + ∈ 𝑇 + , and (ii) if 𝜎 − ≤ 𝜌 + , then 𝜎 − ∈ 𝑇 − . Consider 𝜎 + so 𝜎 + ≤ 𝜌 + . From (i) and the fact that 𝑆 + is a closed subset of P 𝑇 + implies that if 𝜌 + ∈ 𝑆 + then 𝜎 + ∈ 𝑆 + . Theref ore 𝜎 + ∈ 𝑆 . Ne xt, consider 𝜎 − so 𝜎 − ≤ 𝜌 + . From (ii), 𝜎 + ∉ 𝑇 + because 𝑇 is a complete closed subset of P , so 𝜎 + ∉ 𝑆 + . This means 𝜎 − ∈ { 𝜏 − ∈ 𝑃 − : 𝜏 + ∉ 𝑆 + } and theref ore 𝜎 − ∈ 𝑆 . Thus, all the predecessors of 𝜌 + in P are also in 𝑆 . Case 2: Ne xt, let 𝜌 − ∈ 𝑆 so 𝜌 + ∉ 𝑆 + . As a neg ativ e rotation, 𝜌 − can onl y hav e neg ative predecessors in P because of our con v ention. Let 𝜎 − ≤ 𝜌 − . Then 𝜌 + ≤ 𝜎 + because P is a mirror poset. If 𝜎 + ∈ 𝑆 + , w e argued abo ve that all its positiv e predecessors must be in 𝑆 + , including 𝜌 + . But 𝜌 + ∉ 𝑆 + so 𝜎 + ∉ 𝑆 + . It f ollow s that 𝜎 − ∈ { 𝜏 − ∈ 𝑃 − : 𝜏 + ∉ 𝑆 + } and, hence, 𝜎 − ∈ 𝑆 . W e hav e no w sho wn that 𝑆 is a closed subset of P . Since 𝑆 + ⊆ 𝑇 + because 𝑆 + is a closed subset of P 𝑇 + , Lemma 4.5 implies that 𝑆 ⊑ 𝑇 in L ( P ) and theref ore 𝑆 ∈ [ 𝑃 − , 𝑇 ] . □ As an application of Theorem 4.6, consider the top r ight median semilattice in Figure 3 rooted at 𝑃 − . Let 𝑇 = { 𝜌 + 1 , 𝜌 − 2 , 𝜌 − 3 , 𝜌 + 4 , 𝜌 + 5 } so 𝑇 + = { 𝜌 + 1 , 𝜌 + 4 , 𝜌 + 5 } . Thus, P 𝑇 + is the subposet of P f or med b y 𝜌 + 1 , 𝜌 + 4 and 𝜌 + 5 . Its closed subsets are ∅ , { 𝜌 + 4 } , { 𝜌 + 5 } , { 𝜌 + 4 , 𝜌 + 5 } , { 𝜌 + 1 , 𝜌 + 4 , 𝜌 + 5 } . It is easy to see that there is a one-to-one cor respondence betw een these closed subsets of P 𝑇 + and the complete closed subsets in the inter v al [ 𝑃 − , 𝑇 ] of the median semilattice. Local Optima. Let us no w shift the setting bac k to the SR ins tance 𝐼 and its set of stable matchings 𝑀 ( 𝐼 ) . For an y subset 𝑀 ′ ⊆ 𝑀 ( 𝐼 ) , define a stable matching 𝜆 as a local optimum of 𝑀 ′ with respect to the cost function 𝐶 if 𝜆 has the least cost among all the stable matchings in 𝑀 ′ . In the next theorem, w e will only consider subsets 𝑀 ′ of 𝑀 ( 𝐼 ) so that stable matchings in 𝑀 ′ f or m a distributive lattice in some median semilattice. Finding a local optimum will then reduce to finding a maximum-cos t closed subset of some poset. As we already sho wed in the SM case, this can be done efficientl y . 13 Theorem 4.7. Let 𝐼 be an SR instance with 2 𝑛 ag ents. Let L ( 𝐼 , 𝜂 ) be the median semilattice obtained by rooting 𝐺 ( 𝐼 ) at 𝜂 ∈ 𝑀 ( 𝐼 ) . For any 𝜇 ∈ 𝑀 ( 𝐼 ) , finding a local optimum of the inter v al [ 𝜂 , 𝜇 ] takes 𝑂 ( 𝑛 5 log 𝑛 ) time. Pr oof. In this proof, w e shall view the stable matchings 𝜆 in L ( 𝐼 , 𝜂 ) in terms of their complete closed subsets 𝑆 𝜆 so w e can appl y the concepts and results w e ha v e discussed ear lier . W e will also or ient the reduced rotation poset R ′ ( 𝐼 ) at 𝑆 𝜂 b y par titioning its element set into 𝑅 − ∪ 𝑅 + where 𝑅 − = 𝑆 𝜂 . Thus, we can ref er to the non-singular rotations of 𝐼 as neg ative or positiv e based on their membership in 𝑅 − and 𝑅 + respectiv ely . For e very complete closed subset 𝑆 of R ′ ( 𝐼 ) , 𝑆 − = 𝑆 ∩ 𝑅 − and 𝑆 + = 𝑆 ∩ 𝑅 + . Consider 𝜆 ∈ [ 𝜂 , 𝜇 ] . From Theorem 3.11, its cost is 𝐶 ( 𝜆 ) = 𝐶 ( 𝜂 ) −  𝜌 ∈ 𝑆 𝜆 − 𝑆 𝜂 𝐶 ( 𝜌 ) = 𝐶 ( 𝜂 ) −  𝜌 ∈ 𝑆 + 𝜆 𝐶 ( 𝜌 ) = 𝐶 ( 𝜂 ) − 𝐶 ( 𝑆 + 𝜆 ) where the second equality f ollo ws from the f act that 𝑆 𝜂 consists of all the neg ative rotations. Thus, 𝜆 ∗ is the local optimum of [ 𝜂 , 𝜇 ] if and onl y if 𝐶 ( 𝑆 + 𝜆 ) ≤ 𝐶 ( 𝑆 + 𝜆 ∗ ) f or any 𝜆 ∈ [ 𝜂 , 𝜇 ] . No w , according to Theorem 4.6, f or ev ery 𝜆 ∈ [ 𝜂 , 𝜇 ] , 𝑆 + 𝜆 is a closed subset of P 𝑆 + 𝜇 . So we can simply find a maximum-cost closed subset of P 𝑆 + 𝜇 . Ag ain, according to Theorem 4.6, this maximum-cost closed subset contains the positiv e elements of some complete closed subset 𝑆 ∗ ∈ [ 𝑆 𝜂 , 𝑆 𝜇 ] . In tur n, 𝑆 ∗ cor responds to some stable matc hing 𝜆 ∗ in [ 𝜂 , 𝜇 ] , which has to be a local optimum of [ 𝜂 , 𝜇 ] since 𝐶 ( 𝜆 ∗ ) ≤ 𝐶 ( 𝜆 ) f or any 𝜆 ∈ [ 𝜂 , 𝜇 ] . Let us no w analyze the running time of the algorithm we ha v e just outlined f or finding a local optimum in the interval [ 𝜂 , 𝜇 ] . Giv en SR instance 𝐼 and cost function 𝐶 , w e hav e to firs t compute a directed acy clic graph 𝐻 ( 𝐼 ) whose transitiv e closure is R ′ ( 𝐼 ) . From Corollar y 3.5, this can be done in 𝑂 ( 𝑛 3 log 𝑛 ) time. It also implies that 𝐻 ( 𝐼 ) has 𝑂 ( 𝑛 2 ) v er tices and 𝑂 ( 𝑛 3 log 𝑛 ) edg es. Ne xt, e xtract the induced subgraph containing the rotations in 𝑆 + 𝜇 . The transitiv e closure of this subgraph is P 𝑆 + 𝜇 because negativ e rotations cannot be successors of positive rotations. W e can now compute a maximum-cost closed subset of P 𝑆 + 𝜇 using the algorithm Ir ving et al. used f or Corollary 2.5. The r unning time anal ysis is based on the f act that when the representation of the rotation poset has | 𝑉 | v er tices and | 𝐸 | edg es, the minimum cut can be obtained in 𝑂 ( | 𝑉 | | 𝐸 | log 𝑛 ) time. In our case | 𝑉 | = 𝑂 ( 𝑛 2 ) and | 𝐸 | = 𝑂 ( 𝑛 3 log 𝑛 ) so a maximum-cost closed subset of P 𝑆 + 𝜇 can be obtained in 𝑂 ( 𝑛 5 log 𝑛 ) time. Once the maximum-cos t closed subset of P 𝑆 + 𝜇 is f ound, w e add the negativ e elements of the dual pairs missing from the subset to create 𝑆 ∗ . According to Corollary 3.5, giv en 𝑆 ∗ , the stable matching corresponding to 𝑆 ∗ can be obtained in 𝑂 ( 𝑛 2 ) time. □ 5 Maximal Elements in a Median Semilattice In the previous section, w e show ed ho w the technique f or finding an optimal stable matching in SM instances can be e xtended to finding a local optimal stable matching in SR instances under cer tain conditions. In par ticular , in the median semilattice L ( 𝐼 , 𝜂 ) , w e can efficiently find a local optimum of the inter v al [ 𝜂 , 𝜇 ] f or an y 𝜇 . W e tak e adv antage of this fact as f ollo ws: Consider the maximal elements of L ( 𝐼 , 𝜂 ) . Assume the y are 𝜇 1 , 𝜇 2 , . . . , 𝜇 𝑟 . Notice that ∪ 𝑟 𝑖 = 1 [ 𝜂 , 𝜇 𝑖 ] contains all the stable matchings of 𝐼 . Fur thermore, an optimal stable matching of 𝐼 must lie in one of the inter vals. Suppose 𝜇 ∗ 𝑖 is the local optimum of [ 𝜂 , 𝜇 𝑖 ] f or 𝑖 = 1 , . . . , 𝑟 . Then the stable matching with the least cos t among { 𝜇 ∗ 𝑖 , 𝑖 = 1 , . . . , 𝑟 } has to be an optimal stable matching of 𝐼 . T o implement this plan w e must identify the maximal elements of L ( 𝐼 , 𝜂 ) and bound their size. W e will once more work with mirror posets and median semilattices to establish our results. Suppose P has been or iented as ( 𝑃 − ∪ 𝑃 + , ≤) and 𝐻 𝐷 ( P ) its Hasse diag ram. Recall that an edge of 𝐻 𝐷 ( P ) is a cr ossing edg e if one endpoint of the edge is in 𝑃 − and another is in 𝑃 + . Crossing edges come in pairs because P is a mir ror poset. As w e shall see, they pla y an impor tant role. 14 Proposition 5.1. Let 𝜎 − , 𝜌 + be elements of the mirror poset P = ( 𝑃 − ∪ 𝑃 + , ≤) such that 𝜎 − < 𝜌 + . There must be a crossing edg e ( 𝛼 − , 𝛽 + ) so that 𝜎 − ≤ 𝛼 − < 𝛽 + ≤ 𝜌 + . Pr oof. Since 𝜎 − < 𝜌 + , there is a directed path 𝜏 1 , 𝜏 2 , . . . , 𝜏 𝑚 with 𝜏 1 = 𝜎 − and 𝜏 𝑚 = 𝜌 + in 𝐻 𝐷 ( P ) . Since 𝜏 1 ∈ 𝑃 − and 𝜏 𝑚 ∈ 𝑃 + , the directed path must cross from 𝑃 − to 𝑃 + ; i.e., there is some 𝜏 𝑖 so that 𝜏 𝑖 ∈ 𝑃 − and 𝜏 𝑖 + 1 ∈ 𝑃 + . Thus, ( 𝜏 𝑖 , 𝜏 𝑖 + 1 ) is a crossing edge of P . But, additionally , the path from 𝜏 1 to 𝜏 𝑚 f or ms a chain in P so 𝜏 1 ≤ 𝜏 𝑖 < 𝜏 𝑖 + 1 ≤ 𝜏 𝑚 . □ W e say that the pair { 𝛼 , 𝛽 } is inv olved in a cr ossing edg e of P = ( 𝑃 − ∪ 𝑃 + , ≤) if ( 𝛼 − , 𝛽 + ) and ( 𝛽 − , 𝛼 + ) are crossing edg es of the or iented mir ror poset. For 𝐴 ⊆ 𝑃 − ∪ 𝑃 + , let 𝑃𝑟 𝑒 𝑑 ( 𝐴 ) contain all the predecessors of the elements of 𝐴 in P . Lemma 5.2. Assume that P = ( 𝑃 − ∪ 𝑃 + , ≤) has 2 𝑘 crossing edg es in vol ving the pairs { 𝛼 𝑖 , 𝛽 𝑖 } , 𝑖 = 1 , . . . , 𝑘 . Ev er y complete closed subset 𝑆 of P can be e xpressed as 𝑆 = 𝐴 𝑆 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) ∪ 𝐵 𝑆 where (i) 𝐴 𝑆 = Ð 𝑘 𝑖 = 1 𝐴 𝑆 , 𝑖 and 𝐴 𝑆 , 𝑖 ∈ { { 𝛼 + 𝑖 , 𝛽 − 𝑖 } , { 𝛼 − 𝑖 , 𝛽 + 𝑖 } , { 𝛼 − 𝑖 , 𝛽 − 𝑖 } } f or each 𝑖 and (ii) 𝐵 𝑆 has one element from each dual pair { 𝜌 − , 𝜌 + } such that neither 𝜌 − nor 𝜌 + are in 𝐴 𝑆 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) . Pr oof. By assumption, f or each pair { 𝛼 𝑖 , 𝛽 𝑖 } , 𝛼 − 𝑖 < 𝛽 + 𝑖 and 𝛽 − 𝑖 < 𝛼 + 𝑖 in P . Since 𝑆 is a complete closed subset, if 𝛽 + 𝑖 ∈ 𝑆 , then so is 𝛼 − 𝑖 ∈ 𝑆 . Similarl y , if 𝛼 + 𝑖 ∈ 𝑆 , then so is 𝛽 − 𝑖 ∈ 𝑆 . It f ollow s that f or each 𝑖 , one of { 𝛼 + 𝑖 , 𝛽 − 𝑖 } , { 𝛼 − 𝑖 , 𝛽 + 𝑖 } or { 𝛼 − 𝑖 , 𝛽 − 𝑖 } is a subset of 𝑆 . W e shall call this particular subset 𝐴 𝑆 , 𝑖 and let 𝐴 𝑆 = Ð 𝑘 𝑖 = 1 𝐴 𝑆 , 𝑖 . No w , 𝐴 𝑆 ⊆ 𝑆 and 𝑆 is a closed subset of P so 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) ⊆ 𝑆 too. Additionall y , because 𝑆 is a complete closed subset, 𝑆 − ( 𝐴 𝑆 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) ) must contain one element from each dual pair { 𝜌 − , 𝜌 + } such that neither 𝜌 − nor 𝜌 + are in 𝐴 𝑆 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) . Let 𝐵 𝑆 = 𝑆 − ( 𝐴 𝑆 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) ) . Thus, 𝑆 = 𝐴 𝑆 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) ∪ 𝐵 𝑆 . □ W e now describe the maximal elements of L ( P ) . Theorem 5.3. Assume that P = ( 𝑃 − ∪ 𝑃 + , ≤) has 2 𝑘 crossing edges inv ol ving the pairs { 𝛼 𝑖 , 𝛽 𝑖 } , 𝑖 = 1 , . . . , 𝑘 . Ev er y maximal element 𝑇 of 𝐿 ( P ) can be e xpressed as 𝑇 = 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) ∪ 𝐶 𝑇 where (i) 𝐴 𝑇 = Ð 𝑘 𝑖 = 1 𝐴 𝑇 , 𝑖 and 𝐴 𝑇 , 𝑖 ∈ { { 𝛼 + 𝑖 , 𝛽 − 𝑖 } , { 𝛼 − 𝑖 , 𝛽 + 𝑖 } , { 𝛼 − 𝑖 , 𝛽 − 𝑖 } } f or each 𝑖 and (ii) 𝐶 𝑇 contains 𝜌 + of each dual pair { 𝜌 − , 𝜌 + } such that neither 𝜌 − nor 𝜌 + are in 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) . Pr oof. The elements of L ( P ) , including its maximal elements, are complete closed subset of P . Thus, from Lemma 5.2, a maximal element 𝑇 = 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) ∪ 𝐵 𝑇 where 𝐵 𝑇 has one element from eac h dual pair { 𝜌 − , 𝜌 + } such that neither 𝜌 + nor 𝜌 − are in 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) . No w , define set 𝑈 as 𝑈 = 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) ∪ 𝐶 𝑇 . W e shall argue ne xt that 𝑈 is also a complete closed subset of P . Since 𝑇 is a complete subset of P , the set 𝑈 is also one because both 𝐵 𝑇 and 𝐶 𝑇 contain e xactly one element from each dual pair missing a representativ e in 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) . W e just ha v e that to show that 𝑈 is a closed subset as w ell. Suppose not. Then some 𝜌 + ∈ 𝐶 𝑇 is missing a predecessor in 𝑈 , sa y 𝜎 − or 𝜎 + . Case 1: 𝜎 − is missing from 𝑈 . Since 𝜎 − < 𝜌 + , by Proposition 5.1, there is pair { 𝛼 𝑖 , 𝛽 𝑖 } in vol v ed in a crossing edge of 𝐻 ( P ) so that (i) 𝜎 − ≤ 𝛼 − 𝑖 < 𝛽 + 𝑖 ≤ 𝜌 + or (ii) 𝜎 − ≤ 𝛽 − 𝑖 < 𝛼 + 𝑖 ≤ 𝜌 + . By construction, 𝐴 𝑇 contains 𝛼 − 𝑖 or 𝛽 − 𝑖 . W e ha v e four subcases to consider . For eac h one, w e will argue that some contradiction arises so case 1 cannot be tr ue. If (i) is tr ue and 𝛼 − 𝑖 ∈ 𝐴 𝑇 or (ii) is tr ue and 𝛽 − 𝑖 ∈ 𝐴 𝑇 , then 𝜎 − ∈ 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) and cannot be missing from 𝑈 . On the other hand, if (i) is tr ue and 𝛽 − 𝑖 ∈ 𝐴 𝑇 , w e know that 𝜌 − ≤ 𝛽 − 𝑖 < 𝛼 + 𝑖 ≤ 𝜎 + because P is a mir ror poset. This implies that 𝜌 − ∈ 𝐴 𝑇 ∪ 𝑃 𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) , contradicting the f act that 𝜌 + ∈ 𝐶 𝑇 . Similarl y , if (ii) is true and 𝛼 − 𝑖 ∈ 𝐴 𝑇 , w e know that 𝜌 − ≤ 𝛼 − 𝑖 < 𝛽 + 𝑖 ≤ 𝜎 + so 𝜌 − ∈ 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) , again contradicting the f act that 𝜌 + ∈ 𝐶 𝑇 . 15 Case 2: 𝜎 + is missing from 𝑈 . Since 𝜎 + < 𝜌 + , w e ha ve 𝜌 − < 𝜎 − . No w , 𝜎 + ∉ 𝑈 implies 𝜎 + ∉ 𝐶 𝑇 . This means that 𝜎 − ∈ 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) so 𝜌 − ∈ 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) ; otherwise, an element of 𝐴 𝑇 is missing a predecessor . But this contradicts the fact that 𝜌 + ∈ 𝐶 𝑇 . Our argument sho ws that 𝑈 = 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) ∪ 𝐶 𝑇 is a complete closed subset of P . No w , 𝑇 + consists of the positiv e elements in 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) and in 𝐵 𝑇 . But the positiv e elements of 𝐵 𝑇 are all in 𝐶 𝑇 . Thus, 𝑇 + ⊆ 𝑈 + and theref ore 𝑇 ⊑ 𝑈 in L ( P ) b y Lemma 4.5. But 𝑇 is a maximal element of 𝐿 ( P ) . So it must be the case that 𝐵 𝑇 = 𝐶 𝑇 and 𝑇 = 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) ∪ 𝐶 𝑇 . □ W e emphasize that both Lemma 5.2 and Theorem 5.3 w ork in one direction only . The con verse of both results are not necessarily true in the f ollowing sense: Suppose that a choice is made f or each 𝐴 𝑆 , 𝑖 and the y are combined with 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑆 ) and some 𝐵 𝑆 or 𝐶 𝑆 . The result need not be a complete closed subset of P or , if it is one, it ma y not be a maximal element of L ( P ) . The f or mer case occurs because the elements in 𝐴 𝑆 , 𝑖 and 𝐴 𝑆 , 𝑗 , 𝑖 ≠ 𝑗 , ma y be related. For e xample, when 𝐴 𝑆 , 𝑖 = { 𝛼 − 𝑖 , 𝛽 + 𝑖 } , 𝐴 𝑆 , 𝑗 = { 𝛼 + 𝑗 , 𝛽 − 𝑗 } and, additionall y , 𝛼 𝑖 = 𝛼 𝑗 , 𝑆 will not be a complete subset of P . The ne xt corollar y uses Theorem 5.3 to bound the number of maximal elements in L ( P ) . Corollary 5.4. Assume that P = ( 𝑃 − ∪ 𝑃 + , ≤) has 2 𝑘 crossing edg es. Then L ( P ) has at most 3 𝑘 maximal elements. Pr oof. From Theorem 5.3, e very maximal element 𝑇 of 𝐿 ( P ) can be written as 𝑇 = 𝐴 𝑇 ∪ 𝑃𝑟 𝑒 𝑑 ( 𝐴 𝑇 ) ∪ 𝐶 𝑇 . Notice that 𝑇 is completely determined b y 𝐴 𝑇 , which in turn is made up of 𝐴 𝑇 , 𝑖 , 𝑖 = 1 , . . . , 𝑘 . Each 𝐴 𝑇 , 𝑖 can be one of three possible sets. It f ollow s that there can be at most 3 𝑘 distinct f orms of 𝑇 . □ Corollary 5.5. Let 𝐼 be an SR ins tance with 2 𝑛 ag ents. Let L ( 𝐼 , 𝜂 ) be the median semilattice obtained b y rooting 𝐺 ( 𝐼 ) at the stable matching 𝜂 . Suppose that when R ′ ( 𝐼 ) is or iented at 𝑆 𝜂 , the or ientation has at most 2 𝑘 crossing edg es. Then L ( 𝐼 , 𝜂 ) has at most 3 𝑘 maximal elements and computing an optimal stable matching of 𝐼 can be done in 3 𝑘 𝑛 𝑂 ( 1 ) time. Pr oof. The f act that L ( 𝐼 , 𝜂 ) has at most 3 𝑘 maximal elements f ollo ws from Corollary 5.4 immediatel y . So w e consider the problem of computing an optimal stable matching of 𝐼 . Let R ′ ( 𝐼 ) = ( 𝑅 − ∪ 𝑅 + , ≤) with 𝑅 − = 𝑆 𝜂 . Firs t, w e need to identify the crossing edges. Consider the directed acy clic graph 𝐻 ( 𝐼 ) whose transitiv e closure is R ′ ( 𝐼 ) as described in Theorem 3.4. Do a transitiv e reduction of 𝐻 ( 𝐼 ) so that onl y the edges in the Hasse diagram of R ′ ( 𝐼 ) are left. Identify all the pairs in v olv ed in a crossing edg e. These steps can be done in 𝑛 𝑂 ( 1 ) time. Assume { 𝛼 𝑖 , 𝛽 𝑖 } , 𝑖 = 1 , . . . , 𝑘 , are in vol v ed in a crossing edge of the or iented R ′ ( 𝐼 ) . Consider the 3 𝑘 possible f or ms of a maximal element 𝑇 as descr ibed in Theorem 5.3. Discard those that are not complete closed subsets of R ′ ( 𝐼 ) . This step can be completed in 3 𝑘 𝑛 𝑂 ( 1 ) time since R ′ ( 𝐼 ) has onl y 𝑂 ( 𝑛 2 ) elements. For eac h valid 𝑇 , compute the maximum-cost complete closed subset 𝑆 ∗ in [ 𝑆 𝜂 , 𝑇 ] . According to Theorem 4.7, this can be done in 𝑂 ( 𝑛 5 log 𝑛 ) time. Finall y , among the maximum-cos t complete closed subsets, find the one that has the leas t cost and output the s table matching that it corresponds to. The latter has to be an optimal stable matc hing of 𝐼 . This step also takes 3 𝑘 𝑛 𝑂 ( 1 ) time. □ 6 Minimum Crossing Edg es In the pre vious sections, w e sho wed that the s tructure of the median semilattice L ( 𝐼 , 𝜂 ) can be unders tood in ter ms of the reduced rotation poset R ′ ( 𝐼 ) when the latter is or iented at 𝑆 𝜂 . In par ticular , the number of crossing edg es of the or iented R ′ ( 𝐼 ) pla ys a very impor tant role—it can be used to bound the number of maximal elements in L ( 𝐼 , 𝜂 ) and, consequently , bound the r unning time for finding an optimal stable matching of 𝐼 . 16 But L ( 𝐼 , 𝜂 ) is one of man y possible semilattices that can arise from the median graph 𝐺 ( 𝐼 ) . By choosing a different root f or 𝐺 ( 𝐼 ) and, in parallel, a different base f or R ′ ( 𝐼 ) , the resulting orientation of R ′ ( 𝐼 ) can ha v e f ar fe w er crossing edges. W e can then substantiall y impro v e the r unning time f or computing an optimal stable matching of 𝐼 . Thus, we consider the f ollo wing optimization problem: Minimum Cr ossing Orient a tion (MCO): Given a mirr or poset P , find an orientation of P so that it has the least number of cr ossing edg es among all the orientations of P . Let MCO ( P ) denote the number of crossing edges in an op timal or ientation of P . W e shall also ref er to it as the minimum cr ossing distance of P . When P is the reduced rotation poset of SR ins tance 𝐼 , w e will also ref er to MCO ( P ) as the minimum crossing dis tance of 𝐼 . W e begin by c haracter izing the mir ror posets with minimum crossing distance 0. Lemma 6.1. Let P be a mir ror poset. Then MCO ( P ) = 0 if and only if P has an or ientation ( 𝑃 − ∪ 𝑃 + , ≤) so that L ( P ) is a distributiv e lattice. Fur ther more, giv en a directed acyclic graph 𝐻 whose transitiv e closure contains e xactly the relations in P , we can determine if MCO ( P ) = 0 in time linear in the size of 𝐻 . T o pro v e Lemma 6.1, we shall mak e use of the ne xt tw o results. Recall that in a mir ror poset P = ( 𝑃 , ≤) , a subset 𝑈 ⊆ 𝑃 is partially complete if it contains at mos t one element of ev er y dual pair of elements in P . Lemma 6.2 (Lemma 3 in [ 10 ]) . Let P = ( 𝑃 , ≤) be a mir ror poset, and let 𝑈 be one of its par tiall y complete closed subset. Then there is a complete closed subset 𝑆 so that 𝑈 ⊆ 𝑆 . Corollary 6.3. Let P = ( 𝑃 , ≤) be a mir ror poset. For ev er y element 𝜌 of P , there is a complete closed subset 𝑆 𝜌 that contains 𝜌 and its predecessors. Pr oof. Let Pred ( 𝜌 ) contain all the predecessors of 𝜌 . Consider 𝑈 = { 𝜌 } ∪ Pred ( 𝜌 ) . W e no w pro v e that 𝑈 is a partially complete closed subset. Let 𝜏 ∈ 𝑈 and 𝜎 < 𝜏 . Then 𝜎 < 𝜏 ≤ 𝜌 . It f ollow s that 𝜎 ∈ Pred ( 𝜌 ) . That is, 𝑈 is a closed subset. Suppose 𝑈 is not partially complete. Then there is a pair of dual elements 𝜎 and 𝜎 in 𝑈 . Thus, 𝜎 ≤ 𝜌 and 𝜎 ≤ 𝜌 . But P is a mir ror poset so 𝜌 ≤ 𝜎 and 𝜌 ≤ 𝜎 . This implies that 𝜌 ≤ 𝜌 , violating the proper ty that an element and its dual are incomparable in a mir ror poset. Hence, 𝑈 is par tiall y complete. From Lemma 6.2, there must be a complete closed subset 𝑆 𝜌 so that 𝑈 ⊆ 𝑆 𝜌 . □ Pr oof of Lemma 6.1. Assume MCO ( P ) = 0 and ( 𝑃 − ∪ 𝑃 + , ≤) is an or ientation of P that has no crossing edg es. By Corollar y 5.4, L ( P ) has at most 3 0 = 1 maximal element; i.e., L ( P ) has a maximum element. Thus, L ( P ) is a distributive lattice b y Proposition 4.2. On the other hand, assume ( 𝑃 − ∪ 𝑃 + , ≤) is an or ientation of P and L ( P ) is a distributive lattice. A ccording to Proposition 4.2, L ( P ) has a maximum element 𝑇 . W e will now argue that 𝑇 = 𝑃 + . Suppose not and 𝜌 − ∈ 𝑇 . Let 𝑈 contain 𝜌 + and its predecessors. By Corollar y 6.3, P has a complete closed subset 𝑆 𝜌 + so that 𝑈 ⊆ 𝑆 𝜌 + . Since 𝑇 is the maximum element of L ( P ) , 𝑆 + 𝜌 + ⊆ 𝑇 + b y Lemma 4.5. It f ollo ws that 𝜌 + ∈ 𝑇 . But 𝜌 − ∈ 𝑇 too, contradicting the f act that 𝑇 is a complete closed subset of P . Hence, 𝑇 = 𝑃 + . In other w ords, 𝑃 + is also a complete closed subset of P so ( 𝑃 − ∪ 𝑃 + , ≤) has no crossing edges. Ne xt, w e descr ibe an algorithm f or determining if MCO ( P ) = 0 . Consider 𝐻 whose transitiv e closure contains e xactly the relations in P , and let ˆ 𝐻 be its undirected v ersion. R un a g raph tra versal (BFS or DFS) on ˆ 𝐻 . For eac h v er te x of ˆ 𝐻 , record the connected component that contains the v er tex. If some dual pair 𝜌 and 𝜌 lie in the same connected component of ˆ 𝐻 , return “no”; other wise, return “yes.” Clearl y , the algorithm r uns in time linear in the size of ˆ 𝐻 and theref ore of 𝐻 . W e no w argue its correctness. Ag ain, assume MCO ( P ) = 0 and ( 𝑃 − ∪ 𝑃 + , ≤) is an or ientation of P that has no crossing edges. For e very dual pair { 𝜌 , 𝜌 } , one element lies in 𝑃 − and another in 𝑃 + . Since there are no edg es between 𝑃 − and 𝑃 + in the Hasse diag ram of P , there is no path between 𝜌 and 𝜌 in ˆ 𝐻 so the two elements hav e to lie in different connected components of ˆ 𝐻 . It f ollow s that the algor ithm will return “yes.” 17 Con versel y , assume the algor ithm retur ned “y es.” Pick an element 𝜌 . Notice that in ˆ 𝐻 , there is a path from 𝜌 to another element 𝜎 if and onl y if there is a path from 𝜎 to 𝜌 because P is a mir ror poset. Assume 𝜌 lies in connected component 𝐶 1 and 𝜌 lies in connected component 𝐶 2 . Since the algor ithm returned “y es, ” 𝐶 1 ≠ 𝐶 2 . Fur thermore, the vertices in 𝐶 1 are duals of the v er tices in 𝐶 2 according to our discussion. Put the v er tices of 𝐶 1 into 𝑃 − and the vertices of 𝐶 2 into 𝑃 + . Do this again until all the elements of P ha ve been assigned to 𝑃 − or 𝑃 + . Then the duals of the elements in 𝑃 − are in 𝑃 + and vice v ersa. There are also no edges betw een 𝑃 − and 𝑃 + in the Hasse diagram of P since their respectiv e elements lie in different connected components of ˆ 𝐻 . Thus, 𝑃 − and 𝑃 + are both complete closed subsets of P so ( 𝑃 − ∪ 𝑃 + , ≤) is an or ientation of P with no crossing edg es. □ R ecall that 𝐺 ( P ) is the median graph formed b y the complete closed subsets of P . The parameter MCO ( P ) giv es a quantitative measure of ho w structurally similar 𝐺 ( P ) is to the co vering g raph of a distributiv e lattice. According to Proposition 6.1, MCO ( P ) = 0 if and onl y if 𝐺 ( P ) can be rooted at some complete closed subset 𝑆 and the result is a distributive lattice. The said 𝑆 is the base that should be used so that the or ientation of P has no crossing edges. More generall y , Corollar y 5.4 implies that if MCO ( P ) = 2 𝑘 , then 𝐺 ( P ) is the union of the co v er ing graphs of at most 3 𝑘 distributiv e lattices. In the remainder of this section, w e analyze the computational comple xity of MC O. W e first pro v e that MCO is NP -hard in general. W e then show that MCO is fix ed-parameter tractable when parameterized b y MCO ( P ) . F inally , w e pro ve our main result, Theorem 1.1, which states that finding an optimal stable matching of SR ins tance 𝐼 is fix ed-parameter tractable when parameterized by the minimum crossing dis tance of 𝐼 . When giv en a mir ror poset P = ( 𝑃 , ≤) , w e will use ( 𝑃 − , 𝑃 + ) to denote a partition of 𝑃 . W e shall sa y that the par tition is perfect if both 𝑃 − and 𝑃 + are complete subsets of P . If 𝑃 − is additionall y a closed subset of P , then ( 𝑃 − , 𝑃 + ) is an orientation of P . Thus, like the earlier sections of the paper, we will consider the crossing edg es of ( 𝑃 − , 𝑃 + ) . 6.1 Hardness of MC O Giv en a graph 𝐺 = ( 𝑉 , 𝐸 ) , a v ertex cov er 𝐴 ⊆ 𝑉 is a set of v ertices such that e v er y edg e 𝑒 = { 𝑢 , 𝑣 } ∈ 𝐸 has a nontrivial intersection with 𝐴 . The minimum vertex co ver pr oblem (MV C) seeks a verte x cov er of minimum cardinality . The decision variant—deciding if 𝐺 admits a v er te x cov er of a giv en size —is in one of Karp’ s original list of NP -complete problems [ 31 ]. Subsequently , Gare y , Johnson, and Stoc kmey er [ 19 ] sho wed that MV C is NP -hard ev en when restricted to graphs of maximum deg ree 3 . A straightf orward reduction sho ws that Gare y et al.’ s result fur ther implies the f ollowing. F act 6.1. Minimum V er te x Cov er (MV C) is NP -hard ev en when restricted to 3 -regular graphs (i.e., g raphs in which e v er y v er tex has degree 3). For completeness, w e pro v e Fact 6.1 in the appendix. W e will no w use it to show that MCO is NP -hard. Theorem 6.4. The minimum crossing or ientation problem (MCO) is NP -hard. Pr oof. By Fact 6.1, it suffices to giv e a polynomial time reduction from MV C on 3 -regular g raphs to MCO. Giv en a graph 𝐺 = ( 𝑉 , 𝐸 ) , f or m the poset P = ( 𝑃 , ≤) where 𝑃 = { 𝑣 , 𝑣 | 𝑣 ∈ 𝑉 } , and f or each edge { 𝑢 , 𝑣 } ∈ 𝐸 , 𝑣 ≤ 𝑢 and 𝑢 ≤ 𝑣 . It is easy to chec k that P is a mirror poset and its Hasse diagram has edge set 𝐸 P = { ( 𝑢 , 𝑣 ) , ( 𝑣 , 𝑢 ) | { 𝑢 , 𝑣 } ∈ 𝐸 } . For eac h subset 𝑈 ⊆ 𝑉 of vertices of 𝐺 , associate with it a per f ect par tition ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) of 𝑃 where 𝑃 − 𝑈 = { 𝑢 | 𝑢 ∈ 𝑈 } ∪ { 𝑣 | 𝑣 ∈ 𝑉 \ 𝑈 } and symmetrically 𝑃 + 𝑈 = { 𝑢 | 𝑢 ∈ 𝑈 } ∪ { 𝑣 | 𝑣 ∈ 𝑉 \ 𝑈 } (3) 18 It is clear that the cor respondence 𝑈 ↔ ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) is a bi jection between subsets of 𝑉 in 𝐺 and the per f ect par titions of P . Claim 1. Let 𝑈 ⊆ 𝑉 . Then 𝑈 is a verte x cov er of 𝐺 if and onl y if ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) is an or ientation of P . Pr oof of Claim 1. Firs t, suppose 𝑈 is a v er te x co ver . That is, f or ev ery { 𝑢 , 𝑣 } ∈ 𝐸 , 𝑢 ∈ 𝑈 or 𝑣 ∈ 𝑈 (or both). W e will show that ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) is an or ientation of P —i.e., 𝑃 − 𝑈 is a complete closed subset of P so none of the elements in 𝑃 − 𝑈 ha ve a predecessor in 𝑃 + 𝑈 . Suppose to the contrary that there is some ( 𝑢 , 𝑣 ) ∈ 𝐸 P with 𝑢 ∈ 𝑃 + 𝑈 and 𝑣 ∈ 𝑃 − 𝑈 . By the definition of P , w e must hav e { 𝑢 , 𝑣 } ∈ 𝐸 . By the definition of 𝑃 + 𝑈 , w e hav e 𝑢 ∉ 𝑈 , and b y the definition of 𝑃 − 𝑈 , w e hav e 𝑣 ∉ 𝑈 . Thus, the edge { 𝑢 , 𝑣 } is not co vered b y 𝑈 so 𝑈 is not a v er te x cov er , a contradiction. Con versel y , let ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) be an or ientation of P . Suppose { 𝑢 , 𝑣 } ∈ 𝐸 is an edge in 𝐺 . Since ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) is an or ientation, the associated edge ( 𝑢 , 𝑣 ) ∈ 𝐸 P does not cross from 𝑃 + 𝑈 to 𝑃 − 𝑈 . That is, either (i) 𝑢 ∉ 𝑃 + 𝑈 so 𝑢 ∈ 𝑃 + 𝑈 and theref ore 𝑢 ∈ 𝑈 or (ii) 𝑣 ∉ 𝑃 − 𝑈 so 𝑣 ∈ 𝑃 − 𝑈 and theref ore 𝑣 ∈ 𝑈 . Thus, the edg e { 𝑢 , 𝑣 } is co vered b y 𝑈 . Since 𝑒 was c hosen arbitrar ily , 𝑈 is a v er te x cov er of 𝐺 , and Claim 1 f ollo ws. In the ne xt claim, w e will sho w that when 𝐺 is a 3 -regular graph and 𝑈 is a v er te x co v er of 𝐺 , the number of crossing edg es of the or ientation ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) of P can be computed from the size of 𝑈 . Claim 2. Suppose 𝐺 = ( 𝑉 , 𝐸 ) is a 3 -regular graph with 𝑛 v er tices. Let 𝑈 ⊆ 𝑉 be a v er te x cov er of 𝐺 . Then ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) has 6 | 𝑈 | − 3 𝑛 crossing edges. Pr oof of Claim 2. Let 𝑈 be a v er tex co v er of 𝐺 . By Claim 1, ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) is an or ientation of P . For an edge 𝑒 of 𝐺 , we sa y that 𝑈 double-co ver s 𝑒 if both endpoints of 𝑒 are in 𝑈 ; other wise, 𝑈 sing le-co v ers 𝑒 . Let 𝑒 = { 𝑢 , 𝑣 } . Notice that 𝑈 double-co v ers 𝑒 if and only if 𝑢 , 𝑣 ∈ 𝑃 − 𝑈 and 𝑢 , 𝑣 ∈ 𝑃 + 𝑈 . The latter is tr ue if and only if ( 𝑢 , 𝑣 ) and ( 𝑣 , 𝑢 ) are crossing edges of ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) . Thus, 𝑈 double-co v ers 𝑘 edg es of 𝐺 if and onl y if the or ientation ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) of P has 2 𝑘 crossing edges. Let 𝐸 1 and 𝐸 2 denote the set containing the edg es single-co v ered and double-co v ered b y 𝑈 respectiv ely . Since 𝑈 is a verte x co ver of 𝐺 , its complement 𝑉 \ 𝑈 is an independent set. Moreov er , ev er y edge 𝑒 ∈ 𝐸 1 is incident to 𝑉 \ 𝑈 . No w , each v er te x 𝑣 ∈ 𝑉 \ 𝑈 has deg ree 3, so | 𝐸 1 | = 3 | 𝑉 \ 𝑈 | = 3 𝑛 − 3 | 𝑈 | . (4) T o compute | 𝐸 2 | , obser v e that | 𝐸 1 | + | 𝐸 2 | = | 𝐸 | = 3 2 𝑛 because 𝐺 is a 3 -regular graph. Applying (4), | 𝐸 2 | = 3 | 𝑈 | − 3 2 𝑛 . Thus, the orientation ( 𝑃 − 𝑈 , 𝑃 + 𝑈 ) has 2 | 𝐸 2 | = 6 | 𝑈 | − 3 𝑛 crossing edg es. The reduction from the 3 -regular 𝐺 to P = ( 𝑃 , ≤) takes time linear in the size of 𝐺 . From Claim 2, 𝑈 is a minimum v er te x co v er of 𝐺 if and onl y if ( 𝑃 − 𝑈 ∪ 𝑃 + 𝑈 , ≤) is a minimum crossing orientation of P . Since MV C f or 3-regular graphs is NP-hard, it f ollow s that MCO is also NP -hard. □ 6.2 An FPT Algorithm f or MCO W e now sho w that MCO is fix ed-parameter tractable (FPT) with respect to the parameter 𝑘 = MCO ( 𝑃 ) via a reduction from MCO to the Almost 2-SA T problem. R ecall that a 2 -S A T instance consis ts of 𝑛 v ar iables 𝑥 1 , 𝑥 2 , . . . , 𝑥 𝑛 and 𝑚 clauses 𝜙 1 , 𝜙 2 , . . . , 𝜙 𝑚 (possibl y with duplicate clauses), where eac h clause is a disjunction of tw o literals. The Max- 2 -S A T problem seeks a Boolean assignment of the 𝑛 v ar iables that maximizes the number of satisfied clauses. Max- 2 -S A T is NP -hard [ 19 ], but in a celebrated result, Razgon and O’Sullivan [ 39 ] show ed that Max- 2 -S A T admits an FPT algorithm, parameter ized by the number of un satisfied clauses. Formally , an input to the Almost 2 -SAT 19 problem is a triple ( 𝑋 , Φ , 𝑘 ) where 𝑋 consists of 𝑛 v ar iables, Φ consists of 𝑚 tw o-literal clauses (possibl y with duplicate clauses) and 𝑘 is an integ er . The output is either an assignment of Boolean values to the variables in 𝑋 such that at mos t 𝑘 clauses in Φ are not satisfied, or the (correct) asser tion that no such assignment e xists. Theorem 6.5 (Razgon and O’Sullivan [ 39 ]) . Suppose ( Φ , 𝑋 ) is a 2-S A T instance and 𝑘 is the minimum number of unsatisfied clauses in Φ o v er all Boolean assignments to 𝑋 . Then a Boolean assignment that does not satisfy k clauses in Φ can be f ound in time 𝑂 ( 15 𝑘 𝑘 4 𝑚 3 ) . W e now mak e use of Theorem 6.5 to pro ve the ne xt result. Theorem 6.6. Suppose P is a mir ror poset with 2 𝑛 v er tices and its Hasse diagram has 𝑚 edg es. Let 𝑘 = MCO ( P ) . Then a minimum crossing or ientation of P can be f ound in time 𝑂 ( 15 𝑘 𝑘 4 𝑚 3 ) . In par ticular , MCO is fix ed-parameter tractable with respect to 𝑘 = MCO ( P ) . Pr oof. Let P = ( 𝑃 , ≤) be a mirror poset with 𝑃 =  𝜌 1 , 𝜌 1 , 𝜌 2 , 𝜌 2 , . . . , 𝜌 𝑛 , 𝜌 𝑛  . Let 𝐸 P denote the edg e set of the Hasse diagram of P . W e will find an orientation of P with at most 𝑘 crossing edg es b y constr ucting a 2 -S A T instance ( 𝑋 , Φ ) from P as f ollo ws. Let 𝑋 = { 𝑥 1 , 𝑥 2 , . . . , 𝑥 𝑛 } , where 𝑥 𝑖 cor responds to the dual pair { 𝜌 𝑖 , 𝜌 𝑖 } . For each edg e 𝑒 = ( 𝜎 𝑖 , 𝜎 𝑗 ) ∈ 𝐸 P , where 𝜎 𝑖 ∈  𝜌 𝑖 , 𝜌 𝑖  and 𝜎 𝑗 ∈  𝜌 𝑗 , 𝜌 𝑗  , define the type-1 clause of 𝑒 as 𝜑 1 𝑒 = 𝑦 𝑖 ∨ 𝑧 𝑗 such that 𝑦 𝑖 = ( 1 − 𝑥 𝑖 if 𝜎 𝑖 = 𝜌 𝑖 𝑥 𝑖 if 𝜎 𝑖 = 𝜌 𝑖 , and 𝑧 𝑗 = ( 𝑥 𝑗 if 𝜎 𝑗 = 𝜌 𝑗 1 − 𝑥 𝑗 if 𝜎 𝑗 = 𝜌 𝑗 . (5) Define the type-2 clause of 𝑒 as 𝜑 2 𝑒 = 𝑧 𝑖 ∨ 𝑦 𝑗 . In the 2 -S A T instance ( 𝑋 , Φ ) , let Φ consist of 𝑘 + 1 copies of type-1 clause 𝜑 1 𝑒 and one cop y of type-2 clause 𝜑 2 𝑒 f or each edg e 𝑒 ∈ 𝐸 P . Giv en a Boolean assignment 𝑓 of the v ar iables in 𝑋 , create a perf ect par tition ( 𝑃 − , 𝑃 + ) of 𝑃 using the f ollo wing r ule: f or each 𝑥 𝑖 , if 𝑓 ( 𝑥 𝑖 ) = 0 , let 𝜌 𝑖 ∈ 𝑃 − and 𝜌 𝑖 ∈ 𝑃 + ; otherwise, let 𝜌 𝑖 ∈ 𝑃 − and 𝜌 𝑖 ∈ 𝑃 + . W e note that the r ule is in fact a bi jection from the set of all Boolean assignments of the variables in 𝑋 to the set of all perfect partitions of 𝑃 . Thus, w e shall sa y that ( 𝑃 − , 𝑃 + ) is the perfect partition t hat corr esponds to 𝑓 and 𝑓 is the Boolean assignment that corr esponds to ( 𝑃 − , 𝑃 + ) . W e no w pro ve important proper ties about 𝑓 and ( 𝑃 − , 𝑃 + ) . Claim 1. Let 𝑓 be a Boolean assignment of 𝑋 and ( 𝑃 − , 𝑃 + ) be its corresponding per f ect par tition. Let 𝑒 = ( 𝜎 𝑖 , 𝜎 𝑗 ) ∈ 𝐸 P . Then 𝑓 satisfies the type-1 clause 𝜑 1 𝑒 if and onl y if it is not the case that 𝜎 𝑖 ∈ 𝑃 + and 𝜎 𝑗 ∈ 𝑃 − . Pr oof of Claim 1. The Boolean assignment 𝑓 does not satisfy the clause 𝜑 1 𝑒 = 𝑦 𝑖 ∨ 𝑧 𝑗 if and only if 𝑦 𝑖 = 𝑧 𝑗 = 0 . By (5), 𝑦 𝑖 = 0 precisel y when 𝜎 𝑖 = 𝜌 𝑖 and 𝑓 ( 𝑥 𝑖 ) = 1 or 𝜎 𝑖 = 𝜌 𝑖 and 𝑓 ( 𝑥 𝑖 ) = 0 . In both cases, 𝜎 𝑖 ∈ 𝑃 + in the corresponding partition ( 𝑃 − , 𝑃 + ) of 𝑓 . Similarl y , by (5), 𝑧 𝑗 = 0 precisel y 𝜎 𝑗 = 𝜌 𝑗 and 𝑓 ( 𝑥 𝑗 ) = 0 or 𝜎 𝑗 = 𝜌 𝑗 and 𝑓 ( 𝑥 𝑗 ) = 1 . In both cases, 𝜎 𝑗 ∈ 𝑃 − . Thus, 𝑓 does not satisfy 𝜑 1 𝑒 = 𝑦 𝑖 ∨ 𝑧 𝑗 if and onl y if 𝜎 𝑖 ∈ 𝑃 + and 𝜎 𝑗 ∈ 𝑃 − . Claim 2. Let 𝑓 be a Boolean assignment of 𝑋 and ( 𝑃 − , 𝑃 + ) be its corresponding per f ect par tition. Let 𝑒 = ( 𝜎 𝑖 , 𝜎 𝑗 ) ∈ 𝐸 P . Then 𝑓 satisfies the type-2 clause 𝜑 2 𝑒 if and onl y if it is not the case that 𝜎 𝑖 ∈ 𝑃 − and 𝜎 𝑗 ∈ 𝑃 + . Pr oof of Claim 2. The Boolean assignment 𝑓 does not satisfy 𝜑 2 𝑒 = 𝑧 𝑖 ∨ 𝑦 𝑗 if and only if 𝑧 𝑖 = 𝑦 𝑗 = 0 . Appl ying the same reasoning w e used to pro ve Claim 1, we note that 𝑧 𝑖 = 0 precisel y when 𝜎 𝑖 ∈ 𝑃 − and 𝑦 𝑗 = 0 precisely when 𝜎 𝑗 ∈ 𝑃 + . Thus, 𝑓 does not satisfy 𝜑 2 𝑒 if and onl y if 𝜎 𝑖 ∈ 𝑃 − and 𝜎 𝑗 ∈ 𝑃 + . Claim 3. If Boolean assignment 𝑓 of 𝑋 that does not satisfy at mos t 𝑘 clauses in Φ then its corresponding perfect partition ( 𝑃 − , 𝑃 + ) is an or ientation of P that has at most 𝑘 crossing edg es. 20 Pr oof of Claim 3. Assume 𝑓 does not satisfy at most 𝑘 clauses in Φ . Let ( 𝑃 − , 𝑃 + ) be its corresponding perfect partition. Consider 𝑒 ∈ 𝐸 P . If 𝑓 does not satisfy 𝜑 1 𝑒 , the type-1 clause of 𝑒 , then 𝑓 does not satisfy 𝑘 + 1 clauses in Φ because there are 𝑘 + 1 copies of 𝜑 1 𝑒 in Φ . This is a contradiction. Thus, 𝑓 satisfies all type-1 clauses in Φ . By Claim 1, 𝑃 − is a closed subset of P so ( 𝑃 − , 𝑃 + ) is an orientation of P . All clauses of Φ not satisfied b y 𝑓 must be type-2, and there are at most 𝑘 of them. By Claim 2, the orientation ( 𝑃 − , 𝑃 + ) has at most 𝑘 crossing edg es. Claim 4. If ( 𝑃 − , 𝑃 + ) is an orientation of P that has at most 𝑘 crossing edg es, then its corresponding Boolean assignment 𝑓 of 𝑋 does not satisfy at most 𝑘 clauses in Φ . Pr oof of Claim 4. Suppose ( 𝑃 − , 𝑃 + ) is an orientation of P that has at mos t 𝑘 crossing edg es. Let 𝑓 be the Boolean assignment of 𝑋 that cor responds to ( 𝑃 − , 𝑃 + ) . Since 𝑃 − is a closed subset of P , none of the edg es in 𝐸 P are directed from 𝑃 + to 𝑃 − so 𝑓 satisfies all type-1 clauses in Φ b y Claim 1. A dditionally , because ( 𝑃 − , 𝑃 + ) has at most 𝑘 crossing edges, 𝑓 does not satisfy at most 𝑘 type-2 clauses by Claim 2. Thus, 𝑓 does not satisfy at most 𝑘 clauses in Φ . Let P be a mir ror poset with 2 𝑛 v er tices and 𝑚 edg es in 𝐸 P . W e no w descr ibe our FPT algor ithm f or finding an or ientation of P with at most 𝑘 crossing edges. First, create the 2-S A T instance ( 𝑋 , Φ ) . The latter has 𝑛 v ar iables and 𝑚 ′ = ( 𝑘 + 2 ) 𝑚 clauses. Then use the FPT algor ithm f or Almost 2-SA T from Theorem 6.5 to find a Boolean assignment 𝑓 f or 𝑋 so that the number of clauses in Φ not satisfied b y 𝑓 is at most 𝑘 . If 𝑓 e xists, con vert 𝑓 to its cor responding per f ect par tition ( 𝑃 − , 𝑃 + ) and retur n the par tition. By Claim 3, ( 𝑃 − , 𝑃 + ) is an orientation of P with at most 𝑘 crossing edg es. Other wise, if 𝑓 does not e xist, return that P has no orientation with at most 𝑘 crossing edges. By Claim 4, this answ er is cor rect. Constructing the 2-S A T instance from P takes 𝑂 ( 𝑛 + 𝑘 𝑚 ) time. Running the FPT algorithm f or Almost 2-S A T takes 𝑂 ( 15 𝑘 𝑘 ( 𝑚 ′ ) 3 ) = 𝑂 ( 15 𝑘 𝑘 4 𝑚 3 ) time. Finally , con verting 𝑓 to its cor responding per f ect par tition ( 𝑃 − , 𝑃 + ) takes 𝑂 ( 𝑛 ) time. Thus, our FPT algor ithm r uns in 𝑂 ( 15 𝑘 𝑘 4 𝑚 3 ) time, as claimed. □ Remar k 6.7. In Section 4.3.4 of [ 23 ], Gusfield and Ir ving descr ibed tw o alter nativ e wa y s of representing the stable matc hings of a (solv able) SR instance 𝐼 . The first one creates a graph 𝐺 ′ from the reduced rotation poset R ′ ( 𝐼 ) , a mirror poset. They show ed that there is a one-to-one correspondence between the maximal independent sets of 𝐺 ′ and the complete closed subsets of R ′ ( 𝐼 ) and, theref ore, the stable matchings of 𝐼 . But v er tex co vers are the complements of independent sets. Thus, their result also implies that there is a bi jection between the the minimal v er te x cov ers of 𝐺 ′ and the stable matchings of 𝐼 . Our reduction in the proof of Theorem 6.4 goes in the opposite direction. W e create a mirror poset P from a giv en graph 𝐺 and w e show that there is a one-to-one correspondence between the v er te x co vers of 𝐺 and the or ientations of P . Further more, the size of a v er te x cov er dictates the number of crossing edg es in the or ientation. In their second representation, Gusfield and Irving create a 2-S A T ins tance ( 𝑋 ′ , Φ ′ ) from R ′ ( 𝐼 ) . The y sho wed that the satisfying assignments of Φ ′ are in one-to-one cor respondence with the complete closed subsets of R ′ ( 𝐼 ) and, theref ore, the stable matchings of 𝐼 . In the proof of Theorem 6.6, our reduction also creates a 2-S A T instance ( 𝑋 , Φ ) from a mir ror poset P . The difference between Φ ′ and Φ is that Φ ′ contains a single cop y of all the type-1 clauses in Φ (along with additional (redundant) clauses cor responding to edges in the transitiv e closure of the Hasse diagram of P ), but Φ ′ does not contain an y of the type-2 clauses in Φ . W e use the type-2 clauses to minimize the number of crossing edges in the corresponding or ientation. W e now ha v e all the ingredients to prov e Theorem 1.1, which w e restate here. Theorem 1.1 Let 𝐼 be an SR instance with 2 𝑛 ag ents and minimum crossing distance 𝑘 . An optimal stable matching f or 𝐼 can be f ound in time 2 𝑂 ( 𝑘 ) 𝑛 𝑂 ( 1 ) . Thus, the optimal s table matc hing problem is fixed parameter tractable with respect to minimum crossing distance. 21 Pr oof of Theorem 1.1. Let 𝐼 be an SR ins tance with 2 𝑛 ag ents. By Theorem 3.4, its reduced rotation poset R ′ ( 𝐼 ) can be computed in 𝑛 𝑂 ( 1 ) time. By Theorem 6.6, w e can find an or ientation of R ′ ( 𝐼 ) with 𝑘 = MCO ( P ) crossing edg es in 2 𝑂 ( 𝑘 ) 𝑛 𝑂 ( 1 ) time. Finall y , appl ying Corollar y 5.5, w e can find an optimal s table matching of 𝐼 in time 2 𝑂 ( 𝑘 ) 𝑛 𝑂 ( 1 ) , as desired. □ 7 Conclusion In this paper , we ha v e introduced the minimum crossing distance as a parameter that measures the structural similarity between an SR ins tance and an SM instance. Our main result es tablishes that finding an optimal stable matching is FPT when parameter ized b y the minimum crossing distance. Theorem 1.1 ser v es as a br idg e betw een the tw o kno wn results about the optimal stable matching problem — that it is polynomiall y-sol v able f or SM instances but NP -hard f or SR instances — because the closer an SR instance is to an SM instance, the f aster is the algor ithm. W e conclude by describing some interesting directions f or fur ther in ves tigation. T ypical minimum crossing distances. What is the typical minimum crossing distance f or sol vable SR ins tances that ar ise in practice? For SR instances whose pref erence lists are g enerated in a restricted manner , are their minimum crossing dis tances typically small or bounded? A deeper understanding of the relationship betw een preference structures and minimum crossing dis tances would shed light on the practicality of our FPT algorithm for optimal s table matchings. Tight er bounds for cr ossing edg es and maximal elements. Corollary 5.4 states that when an oriented mir ror poset has 2 𝑘 crossing edg es, the cor responding median semilattice has at most 3 𝑘 maximal elements. Can this upper bound be impro v ed? U nder what circumstances is the number of maximal elements exponential in 𝑘 ? Mor e bridg e r esults betw een SM and SR. In the paper, w e mentioned that computing a center stable matching [ 12 , 13 ] and a robust stable matching [ 6 ] in SM can be done in polynomial time. If the y turn out to be NP -hard problems in SR, can their polynomial-time algorithms be transf or med into FPT algor ithms f or SR? Similarl y , can the FPT algorithms f or balanced and se x-equal stable matchings in SM [ 21 ] be e xtended to FPT algorithms for SR? R efer ences [1] S. P . A v ann. Metric ter nary distributiv e semi-lattices. Pr oceedings of the American Mathematical Society , 12:407–414, 1961. [2] Hans-J ¨ urg en Bandelt and Victor Chepoi. Metric g raph theory and geometry: A sur v e y . Contemporary Mathematics , pag es 49–86, 2008. [3] N ay antara Bhatnagar , Sam Greenber g, and Dana Randall. Sampling S table Mar r iag es: Why Spouse- sw apping W on’ t W ork. In Pr oceedings of the Ninet eenth Annual A CM-SIAM Symposium on Discr et e Algorithms , SOD A ’08, pages 1223–1232, Philadelphia, P A, USA, 2008. Society f or Industrial and Applied Mathematics. [4] Gar rett Birkhoff. Rings of sets. Duke Mathematical Journal , 3(3):443–454, September 1937. ISSN 0012-7094, 1547-7398. doi: 10.1215/S0012-7094-37-00334-X . [5] Jiehua Chen, Dann y Her melin, Manuel Sorg e, and Harel Y edidsion. Ho w hard is it to satisfy (almost) all roommates?, February 2018. 22 [6] Jiehua Chen, Piotr Sko wron, and Manuel Sorg e. Matchings under preferences: Strength of s tability and trade-offs. In Anna R. Karlin, Nicole Immor lica, and Ramesh Johar i, editors, Pr oceedings of the 2019 A CM Confer ence on Economics and Computation, EC 2019, Phoenix, AZ, USA, June 24-28, 2019 , pag es 41–59. A CM, 2019. doi: 10.1145/3328526.3329555 . URL https://doi.org/10.1145/ 3328526.3329555 . [7] Jiehua Chen, Chr istine Cheng, Da vid Manlo ve, and Ildik ´ o Schlotter , editors. F rontier s of P aramet erized Algorithmics of Matc hing under Pr efer ences (Dagstuhl Seminar 25342) , Dagstuhl R epor ts, Dagstuhl, Germany , 2025. Schloss Dagstuhl – Leibniz-Zentr um f ¨ ur Inf or matik. URL https://www .dagstuhl.de/ 25342 . [8] Christine T . Cheng. The Generalized Median S table Matchings: Finding Them Is Not That Easy. In Eduardo Sany Laber , Claudson Bornstein, Loana Tito Nogueira, and Luerbio F ar ia, editors, L ATIN 2008: Theore tical Informatics , Lecture Notes in Computer Science, pag es 568–579, Berlin, Heidelber g, 2008. Springer . ISBN 978-3-540-78773-0. doi: 10.1007/978-3-540-78773-0 49 . [9] Christine T . Cheng. Unders tanding the Generalized Median Stable Matchings. Algorithmica , 58(1): 34–51, September 2010. ISSN 1432-0541. doi: 10.1007/s00453-009-9307-2 . [10] Christine T . Cheng and Anhua Lin. Stable roommates matchings, mirror posets, median graphs, and the local/global median phenomenon in stable matc hings. SIAM Journal on Discre te Mathematics , 25(1): 72–94, 2011. doi: 10.1137/090750299 . [11] Christine T . Cheng and Will R osenbaum. Stable Matc hings with Res tr icted Pref erences: Structure and Comple xity. A CM T ransactions on Economics and Computation , 10(3):1–45, September 2022. ISSN 2167-8375, 2167-8383. doi: 10.1145/3565558 . [12] Christine T . Cheng, Eric McDer mid, and Ichiro Suzuki. Center stable matchings and centers of co v er graphs of distributiv e lattices. In L uca Aceto, Monika Henzinger , and Jir ´ ı Sgall, editors, Automata, Languag es and Prog ramming - 38th International Colloquium, ICALP 2011, Zurich, Switzerland, July 4-8, 2011, Pr oceedings, P ar t I , v olume 6755 of Lectur e N ot es in Computer Science , pag es 678–689. Spr inger , 2011. doi: 10.1007/978-3-642-22006-7 57 . URL https://doi.org/10.1007/978- 3- 642- 22006- 7 57 . [13] Christine T . Cheng, Eric McDer mid, and Ichiro Suzuki. Eccentricity , center and radius computations on the co ver graphs of distributiv e lattices with applications to stable matchings. Discre t. Appl. Math. , 205: 27–34, 2016. doi: 10.1016/J.D AM.2015.11.016 . URL https://doi.org/10.1016/j.dam.2015.11.016 . [14] T . Feder . A ne w fixed point approach for stable networks stable marr iages. In Pr oceedings of the T wenty-F irs t Annual A CM Symposium on Theor y of Computing - ST OC ’89 , pag es 513–522, Seattle, W ashington, U nited States, 1989. A CM Press. ISBN 978-0-89791-307-2. doi: 10.1145/73007.73056 . [15] T . Feder . A new fix ed point approach f or stable netw orks and stable mar riages. Jour nal of Computer and Sys tem Sciences , 45:233–284, 1992. [16] T om ´ as Feder . Stable Ne twor ks and Product Gr aphs , v olume 555. Amer ican Mathematical Soc., 1995. [17] Stef an Felsner . Lattice str ucture from planar graphs. Electronic Jour nal of Combinatorics , 11:R15, 2004. [18] D. Gale and L. S. Shapley . Colleg e Admissions and the S tability of Marr iage. The American Mathematical Monthly , 69(1):9–15, January 1962. ISSN 0002-9890. doi: 10.1080/00029890.1962.11989827 . [19] M.R. Garey , D.S. Johnson, and L. Stoc kmey er . Some simplified NP -complete g raph problems. Theore tical Computer Science , 1(3):237–267, 1976. ISSN 0304-3975. doi: 10.1016/0304-3975(76)90059-1 . 23 [20] Y annai A. Gonczarow ski, Noam Nisan, Rafail Ostro vsky , and Will R osenbaum. A stable mar riage requires communication. Games and Economic Behavior , 2019. ISSN 0899-8256. doi: 10.1016/j.g eb.2018.10.013 . [21] Sushmita Gupta, Saket Saurabh, and Meira v Zehavi. On T ree width and Stable Marr iag e: Parameterized Algorithms and Hardness R esults (Complete Characterization). SIAM Journal on Discr et e Mathematics , 36(1):596–681, March 2022. ISSN 0895-4801, 1095-7146. doi: 10.1137/19M130491X . [22] Dan Gusfield. The Structure of the Stable R oommate Problem: Efficient Representation and Enumeration of All S table Assignments. SIAM Jour nal on Computing , 17(4):742–769, Augus t 1988. ISSN 0097-5397, 1095-7111. doi: 10.1137/0217048 . [23] Dan Gusfield and R ober t W Ir ving. The Stable Marriag e Problem: Structur e and Algorithms . Foundations of Computing. MIT Press, London, England, A ugust 1989. [24] Dorit S. Hochbaum. A new —old algor ithm for minimum-cut and maximum-flow in closure g raphs. N etw orks , 37(4):171–193, July 2001. ISSN 0028-3045, 1097-0037. doi: 10.1002/net.1012 . [25] Wilfried Imr ic h and Sandi Kla v ˇ zar . Product Gr aphs: Structur e and Recognition . John Wile y & Sons, Ne w Y ork, 2000. ISBN 978-0-471-37039-0. [26] R ober t W Ir ving. An efficient algor ithm f or the “stable roommates ” problem. Journal of Algorithms , 6 (4):577–595, December 1985. ISSN 01966774. doi: 10.1016/0196-6774(85)90033-1 . [27] R ober t W . Ir ving. On the stable room-mates problem. T echnical R epor t CSC/86/R5, U niversity of Glasgo w , Department of Computing Science, Glasgow , Scotland, 1986. [28] R ober t W . Ir ving and Paul Leather . The Comple xity of Counting Stable Mar riages. SIAM Jour nal on Computing , 15(3):655–667, 1986. doi: 10.1137/0215048 . [29] R ober t W . Ir ving, Paul Leather , and Dan Gusfield. An efficient algor ithm f or the “optimal” stable mar riage. Journal of the A CM , 34(3):532–543, Jul y 1987. ISSN 0004-5411. doi: 10.1145/28869.28871 . [30] Anna R. Kar lin, Shay an Ov eis Gharan, and R obbie W eber . A simply e xponential upper bound on the maximum number of s table matchings. In Ilias Diak onikolas, Da vid Kempe, and Monika Henzing er , editors, Pr oceedings of the 50t h Annual A CM SIGA CT Symposium on Theory of Computing, STOC 2018, Los Ang eles, CA, USA, June 25-29, 2018 , pages 920–925. A CM, 2018. doi: 10.1145/3188745.3188848 . URL https://doi.org/10.1145/3188745.3188848 . [31] Richard M. Kar p. R educibility Among Combinator ial Problems. In Michael J ¨ unger , Thomas M. Liebling, Denis Naddef, Georg e L. Nemhauser , William R. Pulle yblank, Gerhard Reinelt, Gio vanni Rinaldi, and Laurence A. W olse y , editors, 50 Y ears of Integ er Prog ramming 1958-2008 , pag es 219–241. Springer Ber lin Heidelberg, Berlin, Heidelber g, 2010. ISBN 978-3-540-68274-5 978-3-540-68279-0. doi: 10.1007/978-3-540-68279-0 8 . [32] Akik o Kato. Comple xity of the sex-equal s table mar riage problem. Japan Jour nal of Industrial and Applied Mathematics , 10(1):1, F ebr uar y 1993. ISSN 1868-937X. doi: 10.1007/BF03167200 . [33] Sandi Klav ˇ zar and Henry Martyn Mulder . Median graphs: Character izations, location theor y and related structures. Jour nal of Combinatorial Mathematics and Combinat orial Computing , 30:103–127, 1999. [34] D.E. Knuth, N .G. De Brui jn, and M. Goldstein. Stable Marriag e and Its Relation to Other Combinatorial Pr oblems: An Introduction to t he Mathematical Analysis of Algorithms . CRM Proceedings & Lecture Notes. American Mathematical Society , 1997. ISBN 978-0-8218-0603-6. 24 [35] Donald E. Knuth. Mariag es stables et leurs r elations av ec d’autres probl ` emes combinatoir es . Les Presses de l’U niversit ´ e de Montr ´ eal, Montr ´ eal, 1976. [36] Eric McDer mid and R ober t W . Ir ving. Sex-Eq ual Stable Matchings: Comple xity and Exact Algor ithms. Algorithmica , 68(3):545–570, Marc h 2014. ISSN 1432-0541. doi: 10.1007/s00453-012-9672-0 . [37] J. Picard. Maximum closure of a graph and applications to combinatorial problems. Manag ement Science , 22:1268–1272, 1976. [38] James Propp. Generating random elements of finite distributive lattices. Electronic Journal of Combinatorics , 4:R15, 1997. [39] Igor Razgon and Barr y O’Sullivan. Almost 2-S A T is fix ed-parameter tractable. Journal of Computer and Sys tem Sciences , 75(8):435–450, December 2009. ISSN 00220000. doi: 10.1016/j.jcss.2009.04.002 . [40] Will R osenbaum. A quadratic lo wer bound f or stable roommates sol vability , 2025. https://ar xiv .org/abs/ 2502.06464 . A Appendix The goal of this section is to pro ve tw o results from the main section of the paper: Corollary 3.5 and Lemma 3.10. T o do so, w e need to discuss Irving’ s algor ithm and the notions of tables and rotations in more detail. W e will mention some definitions and lemmas again from the main section so that the flo w of the discussion is smoother . W e warn readers that w e will use 𝑇 to ref er to pseudotables and tables so that the lemmas we quote are consis tent with those in [23]. Irving’s algorithm. Let 𝐼 be an SR instance. A pseudotable 𝑇 of 𝐼 contains a list f or each ag ent. Initiall y , it consists of just the ag ents ’ preference lis ts. Subsequently , pairs of agents { 𝑥 , 𝑦 } are delet ed ; i.e., 𝑥 is remo ved from 𝑦 ’ s list and 𝑦 is remo v ed from 𝑥 ’ s list. Let 𝑓 𝑇 ( 𝑥 ) , 𝑠 𝑇 ( 𝑥 ) and ℓ 𝑇 ( 𝑥 ) denote the first, second and last entr ies in 𝑥 ’ s list in 𝑇 . The pseudotable 𝑇 is a table of 𝐼 if, additionally , (i) none of the lists in 𝑇 are empty , (ii) for each 𝑥 , 𝑓 𝑇 ( 𝑥 ) = 𝑦 if and only if ℓ 𝑇 ( 𝑦 ) = 𝑥 and (iii) f or each pair of ag ents { 𝑥 , 𝑧 } , the pair { 𝑥 , 𝑧 } is absent from 𝑇 if and onl y if 𝑥 pref ers ℓ 𝑇 ( 𝑥 ) to 𝑧 or 𝑧 pref ers ℓ 𝑇 ( 𝑧 ) to 𝑥 . When 𝑇 is a table, another table 𝑈 or a stable matching 𝜇 is embedded in 𝑇 if all the pairs in 𝑈 or 𝜇 can be f ound in 𝑇 . The table 𝑈 is also called a subtable of 𝑇 . Assume 𝑇 is a table. A cy clic sequence of ordered pairs of ag ents 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) such that 𝑦 𝑖 = 𝑓 𝑇 ( 𝑥 𝑖 ) and 𝑦 𝑖 + 1 = 𝑠 𝑇 ( 𝑥 𝑖 ) f or 𝑖 = 0 , . . . , 𝑟 − 1 is a ro tation exposed in 𝑇 . The 𝑋 -set of 𝜌 is { 𝑥 0 , 𝑥 1 , . . . , 𝑥 𝑟 − 1 } while its 𝑌 -set is { 𝑦 0 , 𝑦 1 , . . . , 𝑦 𝑟 − 1 } . T o eliminate 𝜌 from 𝑇 , all pairs { 𝑦 𝑖 , 𝑧 } such that 𝑦 𝑖 pref ers 𝑥 𝑖 − 1 to 𝑧 , 𝑖 = 0 , . . . , 𝑘 − 1 are deleted. The result is 𝑇 / 𝜌 , which is another table as long as ev ery ag ent’ s list is non-empty . It is kno wn that when some list in 𝑇 has tw o or more entr ies, at least one rotation is e xposed in 𝑇 . On the other hand, when ev ery list in 𝑇 has e xactly one entry , pair ing each agent with the only entr y in their list results in a matching because of property (ii) of a table and is stable because of property (iii). Let us no w discuss how Irving’ s algor ithm computes a stable matching f or a solv able SR instance 𝐼 . W e note that since 𝐼 is solv able, e very agent ’ s list in Ir ving’ s algor ithm will ne ver be empty . The algor ithm has tw o phases. W e will skip o v er the details of the firs t phase because ev ery e xecution of the phase yields the same output – the phase-1 table 𝑇 0 . If each list in 𝑇 0 has e xactly one entry , the algor ithm outputs the cor responding stable matc hing and ends. Otherwise, it proceeds to the second phase. While the cur rent table 𝑇 has a list with tw o or more entries, it finds an e xposed rotation and eliminates it. The algor ithm does this 25 o ver and ov er ag ain until each list in 𝑇 has onl y one entr y . Ag ain, the algor ithm outputs the corresponding stable matc hing and ends. When 𝐼 has 2 𝑛 agents, the running time of Irving’ s algor ithm is 𝑂 ( 𝑛 2 ) . Assume table 𝑇 is obtained when the sequence of rotations ⟨ 𝜌 1 , 𝜌 2 , . . . , 𝜌 𝑘 ⟩ is eliminated from 𝑇 0 . Suppose the same result occurs when another sequence of rotations ⟨ 𝜎 1 , 𝜎 2 , . . . , 𝜎 𝑘 ⟩ is eliminated from 𝑇 0 . It turns out that { 𝜌 1 , 𝜌 2 , . . . , 𝜌 𝑘 } = { 𝜎 1 , 𝜎 2 , . . . , 𝜎 𝑘 } . Let us denote the set as 𝑍 . Then table 𝑇 = 𝑇 0 / 𝑍 and 𝑇 is a subtable of 𝑇 0 . The same notation applies when 𝑇 corresponds to a stable matching 𝜇 ; i.e., 𝜇 = 𝑇 0 / 𝑍 . R otations. W e cite and pro v e ne w results on rotations. Let 𝜌 be exposed in table 𝑇 . The ne xt lemma descr ibes the effects of eliminating 𝜌 from 𝑇 . Lemma A.1. (Lemma 4.2.7 in [ 23 ].) Let 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) be a rotation exposed in table 𝑇 . Then if 𝑇 / 𝜌 contains no empty lists, (i) 𝑓 𝑇 / 𝜌 ( 𝑥 𝑖 ) = 𝑦 𝑖 + 1 f or 𝑖 = 0 , . . . , 𝑟 − 1, (ii) ℓ 𝑇 / 𝜌 ( 𝑦 𝑖 ) = 𝑥 𝑖 − 1 f or 𝑖 = 0 , . . . , 𝑟 − 1, (iii) 𝑓 𝑇 / 𝜌 ( 𝑥 ) = 𝑓 𝑇 ( 𝑥 ) f or each 𝑥 not in the 𝑋 -set of 𝜌 and ℓ 𝑇 / 𝜌 ( 𝑦 ) = ℓ 𝑇 ( 𝑦 ) f or each 𝑦 not in the 𝑌 -set of 𝜌 . Remar k A.2. As noted in [ 23 ], when 𝜌 is eliminated from 𝑇 , the front of eac h 𝑥 𝑖 ’ s lis t (or simpl y 𝑥 𝑖 ) is mov ed one st ep down from 𝑦 𝑖 to 𝑦 𝑖 + 1 while the bac k of each 𝑦 𝑖 ’ s list (or simpl y 𝑦 𝑖 ) is mo ved one or mor e st eps up from 𝑥 𝑖 to 𝑥 𝑖 − 1 . While each 𝑥 𝑖 ’ s list is modified from the front and each 𝑦 𝑖 ’ s list is modified from the back, it is impor tant to remember that there ma y be some ag ents 𝑧 whose lists are modified in the middle when 𝜌 is eliminated from 𝑇 . These are the agents that lie betw een 𝑥 𝑖 − 1 and 𝑥 𝑖 in 𝑦 𝑖 ’ s list f or 𝑖 = 0 , 1 , . . . , 𝑘 − 1 . For such an ag ent 𝑧 , 𝑦 𝑖 is remo v ed from their list. W e kno w 𝑦 𝑖 is in the middle of 𝑧 ’ s list because if 𝑓 𝑇 ( 𝑧 ) = 𝑦 𝑖 then ℓ 𝑇 ( 𝑦 𝑖 ) = 𝑧 but 𝑧 is ahead of 𝑥 𝑖 in 𝑦 𝑖 ’ s list. Similarl y , if ℓ 𝑇 ( 𝑧 ) = 𝑦 𝑖 then 𝑓 𝑇 ( 𝑦 𝑖 ) = 𝑧 but 𝑥 𝑖 − 1 is ahead of 𝑧 in 𝑦 𝑖 ’ s list. Let 𝑅 ( 𝐼 ) contain all the e xposed rotations that can be eliminated dur ing an e xecution of phase 2 of Ir ving’ s algorithm. There are tw o types of rotations in 𝑅 ( 𝐼 ) . A rotation 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) is non-singular if 𝜌 = ( 𝑦 1 , 𝑥 0 ) , ( 𝑦 2 , 𝑥 1 ) , . . . , ( 𝑦 0 , 𝑥 𝑟 − 1 ) is also a rotation. Otherwise, 𝜌 is singular . If 𝜌 and 𝜌 are rotations then 𝜌 is called the dual of 𝜌 and vice v ersa. Notice that the 𝑋 -set of 𝜌 is the 𝑌 -set of 𝜌 and the 𝑌 -set of 𝜌 is the 𝑋 -set of 𝜌 . Theorem A.3. (Theorem 4.3.1 in [ 23 ].) Let 𝜇 be a stable matc hing of 𝐼 . If 𝜇 = 𝑇 0 / 𝑍 , then 𝑍 contains e v er y singular rotation and e xactly one of eac h dual pair of non-singular rotations of 𝐼 . Just like in the SM setting, a poset can be created from 𝑅 ( 𝐼 ) . For 𝜎 , 𝜌 ∈ 𝑅 ( 𝐼 ) , let 𝜎 ≤ 𝜌 if f or e v er y sequence of eliminations in the phase 2 of Irving’ s algor ithm in which 𝜌 appears, 𝜎 appears bef ore 𝜌 . The poset R ( 𝐼 ) = ( 𝑅 ( 𝐼 ) , ≤) is the ro tation poset of 𝐼 . Here are some proper ties about the order ing ≤ : Lemma A.4. (Lemma 4.3.7 in [ 23 ].) Let 𝜌 and 𝜎 be non-singular rotations and 𝜏 be a singular rotation of 𝐼 . Then (i) 𝜌 and 𝜌 are incomparable elements in R ( 𝐼 ) ; (ii) 𝜎 ≤ 𝜌 if and only if 𝜌 ≤ 𝜎 ; (iii) an y predecessor of 𝜏 in R ( 𝐼 ) is a singular rotation. Denote a pair { 𝑥 , 𝑦 } a stable pair of 𝐼 if { 𝑥 , 𝑦 } ∈ 𝜇 f or some stable matching 𝜇 of 𝐼 . It is a fixed pair if it is in ev ery stable matching of 𝐼 . The ne xt lemma descr ibes the relationship between the pairs that can be f ound in rotations and the stable pairs of 𝐼 . Lemma A.5. (Lemma 4.4.1 in [ 23 ].) In SR instance 𝐼 , { 𝑥 , 𝑦 } is a s table pair but not a fix ed pair if and onl y if the pair ( 𝑥 , 𝑦 ) or the pair ( 𝑦 , 𝑥 ) is in a non-singular rotation of 𝐼 26 In general, an ag ent 𝑥 of 𝐼 has man y stable par tners. They can then be ordered from the most pref er red of 𝑥 to the least pref er red of 𝑥 . Suppose 𝑦 and 𝑦 ′ are tw o of them. W e shall say that the sequence ⟨ 𝑦 , 𝑦 ′ ⟩ is a consecutiv e sequence of stable partners of 𝑥 if 𝑦 is the 𝑖 th most pref erred stable partner of 𝑥 while 𝑦 ′ is the ( 𝑖 + 1 ) st mos t pref er red stable partner of 𝑥 . The ne xt lemma pro vides a strong er characterization of the ag ents in a rotation. Lemma A.6. Let 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) be a non-singular rotation of 𝐼 . For each 𝑥 𝑖 , ⟨ 𝑦 𝑖 , 𝑦 𝑖 + 1 ⟩ is a consecutiv e sequence of stable partners of 𝑥 𝑖 . Similarl y , f or each 𝑦 𝑖 , ⟨ 𝑥 𝑖 − 1 , 𝑥 𝑖 ⟩ is a consecutiv e sequence of s table par tners of 𝑦 𝑖 . Pr oof. Since 𝜌 is a non-singular rotation of 𝐼 , its dual 𝜌 = ( 𝑦 1 , 𝑥 0 ) , ( 𝑦 2 , 𝑥 1 ) , . . . , ( 𝑦 0 , 𝑥 𝑟 − 1 ) is another non-singular rotation of 𝐼 . No w , ( 𝑥 𝑖 , 𝑦 𝑖 ) ∈ 𝜌 while ( 𝑦 𝑖 , 𝑥 𝑖 − 1 ) , ( 𝑦 𝑖 + 1 , 𝑥 𝑖 ) ∈ 𝜌 . It f ollow s from Lemma A.5 that 𝑦 𝑖 and 𝑦 𝑖 + 1 are stable partners of 𝑥 𝑖 while 𝑥 𝑖 − 1 and 𝑥 𝑖 are stable partners of 𝑦 𝑖 . Let 𝑇 be a table in which 𝜌 is e xposed. By definition, 𝑦 𝑖 = 𝑓 𝑇 ( 𝑥 𝑖 ) and 𝑦 𝑖 + 1 = 𝑠 𝑇 ( 𝑥 𝑖 ) . Thus, 𝑥 𝑖 pref ers 𝑦 𝑖 to 𝑦 𝑖 + 1 . Using a table in which 𝜌 is e xposed, the same reasoning implies that 𝑦 𝑖 pref ers 𝑥 𝑖 − 1 to 𝑥 𝑖 . Suppose that 𝑥 𝑖 has some stable par tner 𝑣 so that 𝑥 𝑖 pref ers 𝑦 𝑖 to 𝑣 and 𝑣 to 𝑦 𝑖 + 1 . By Lemma A.5, there is a rotation 𝜎 such that ( 𝑥 𝑖 , 𝑣 ) ∈ 𝜎 or ( 𝑣 , 𝑥 𝑖 ) ∈ 𝜎 . Let 𝑇 be a table in which 𝜎 is e xposed. Then 𝑇 / 𝜎 is another table and rotations can continue to be eliminated to obtain a stable matching 𝜇 . Assume 𝜇 = 𝑇 0 / 𝑍 so 𝜎 ∈ 𝑍 . By Theorem A.3, one of 𝜌 and 𝜌 has to be in 𝑍 . W e will now ar gue that this is not possible. Consider table 𝑇 again. If ( 𝑥 𝑖 , 𝑣 ) ∈ 𝜎 , then 𝑓 𝑇 ( 𝑥 𝑖 ) = 𝑣 so { 𝑥 𝑖 , 𝑦 𝑖 } is absent from 𝑇 . On the other hand, if ( 𝑣 , 𝑥 𝑖 ) ∈ 𝜎 , then ℓ 𝑇 ( 𝑥 𝑖 ) = 𝑣 and { 𝑥 𝑖 , 𝑦 𝑖 + 1 } is absent from 𝑇 . But in order for 𝜌 to be e xposed in a table, 𝑥 𝑖 has to ha v e 𝑦 𝑖 and 𝑦 𝑖 + 1 in its list. Similarl y , f or 𝜌 to be e xposed, 𝑥 𝑖 has to be in 𝑦 𝑖 + 1 and 𝑦 𝑖 ’ s list. So 𝜌 and 𝜌 cannot be e xposed in a subtable of 𝑇 ; i.e., they could not ha v e been eliminated af ter 𝜎 to obtain 𝜇 . It must be the case then that 𝜌 or 𝜌 was eliminated bef ore 𝜎 to obtain 𝜇 . Assume 𝜌 was eliminated firs t. Consider the table just after it was eliminated. The first entry in 𝑥 𝑖 ’ s list is 𝑦 𝑖 + 1 so { 𝑥 𝑖 , 𝑣 } has been deleted. It will then be impossible f or 𝜎 to be e xposed in later subtables. If instead 𝜌 w as eliminated first, then in the table after 𝜌 w as eliminated, the las t entry in 𝑥 𝑖 ’ s list is 𝑦 𝑖 . Ag ain, { 𝑥 𝑖 , 𝑣 } has been deleted so 𝜎 cannot be e xposed in later subtables. W e hav e sho wn that 𝜎 cannot e xist, which implies 𝑣 cannot e xist. That is, 𝑦 𝑖 + 1 is the stable partner that 𝑥 𝑖 pref ers ne xt after 𝑦 𝑖 . Swapping the role of 𝜌 and 𝜌 abo v e, w e also conclude that 𝑥 𝑖 is the s table partner that 𝑦 𝑖 pref ers next after 𝑥 𝑖 − 1 . □ Remar k A.7. Let 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) be a non-singular rotation exposed in table 𝑇 . Assume { 𝑢 , 𝑣 } w as deleted from 𝑇 when 𝜌 w as eliminated. Follo wing up on R emark A.2, 𝑢 ’ s list or 𝑣 ’ s list w as modified in the middle if and only if the pair { 𝑢 , 𝑣 } is not a stable pair . Corollary A.8. Suppose ( 𝑥 , 𝑦 ) is in a non-singular rotation 𝜌 of 𝐼 . Then the rest of 𝜌 can be deter mined from ( 𝑥 , 𝑦 ) . That is, 𝜌 is the only non-singular rotation of 𝐼 that contains { 𝑥 , 𝑦 } . Pr oof. Suppose 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) and onl y ( 𝑥 0 , 𝑦 0 ) is kno wn. (If ( 𝑥 𝑖 , 𝑦 𝑖 ) , 𝑖 > 0 , is the kno wn pair , rotate 𝜌 so ( 𝑥 𝑖 , 𝑦 𝑖 ) becomes ( 𝑥 0 , 𝑦 0 ) .) Then b y Lemma A.6, 𝑦 1 is the stable par tner that 𝑥 0 pref ers after 𝑦 0 while 𝑥 1 is the stable partner that 𝑦 1 pref ers after 𝑥 0 . Applying the same reasoning, ( 𝑥 1 , 𝑦 1 ) determines ( 𝑥 2 , 𝑦 2 ) , ( 𝑥 2 , 𝑦 2 ) determines ( 𝑥 3 , 𝑦 3 ) , etc. Eventuall y , the process will circle back to ( 𝑥 0 , 𝑦 0 ) and all of 𝜌 is deter mined. All that was needed to cons tr uct 𝜌 was ( 𝑥 0 , 𝑦 0 ) . □ Lemma A.9. Let 𝜌 and 𝜌 ′ be non-singular rotations of 𝐼 such that ( 𝑥 , 𝑦 ) ∈ 𝜌 and ( 𝑥 , 𝑦 ′ ) ∈ 𝜌 ′ . If 𝑥 pref ers 𝑦 to 𝑦 ′ , then 𝜌 is a predecessor of 𝜌 ′ in R ( 𝐼 ) . Pr oof. Let 𝑇 ′ be a table in whic h 𝜌 ′ is e xposed. Assume 𝑇 ′ = 𝑇 0 / 𝑍 ′ . W e need to sho w that 𝜌 ∈ 𝑍 ′ . Since ( 𝑥 , 𝑦 ′ ) ∈ 𝜌 ′ , 𝑓 𝑇 ′ ( 𝑥 ) = 𝑦 ′ . This means that the pair { 𝑥 , 𝑦 } w as deleted in an earlier s tep when some rotation 27 𝜎 ∈ 𝑍 ′ w as eliminated. Keeping in mind that { 𝑥 , 𝑦 } is a stable pair and R emarks A.2 and A.7, according to Lemma A.5, there are onl y two possible w ay s { 𝑥 , 𝑦 } was deleted: (i) ( 𝑥 , 𝑦 ) ∈ 𝜎 or (ii) ( 𝑦 , 𝑥 ) ∈ 𝜎 . Assume case (ii) is true. Then consider the table just bef ore 𝜎 is eliminated. Since ( 𝑦 , 𝑥 ) ∈ 𝜎 , the last entry in 𝑥 ’ s list is 𝑦 so { 𝑥 , 𝑦 ′ } w as already deleted. It is impossible f or 𝜌 ′ to be exposed in later subtables. Thus, ( 𝑥 , 𝑦 ) ∈ 𝜎 . By Corollar y A.8, 𝜎 = 𝜌 . □ Corollary A.10. If 𝜌 and 𝜎 are incomparable non-singular rotations in R ( 𝐼 ) , then their 𝑋 -sets as well as their 𝑌 -sets are disjoint. Pr oof. Suppose 𝑥 lies in the 𝑋 -sets of 𝜌 and 𝜎 . Then some ( 𝑥 , 𝑦 ) ∈ 𝜌 and some ( 𝑥 , 𝑦 ′ ) ∈ 𝜎 . By Corollary A.8, ( 𝑥 , 𝑦 ) completel y deter mines 𝜌 and ( 𝑥 , 𝑦 ′ ) completel y deter mines 𝜎 so 𝑦 ≠ 𝑦 ′ . Both 𝑦 and 𝑦 ′ are also stable partners of 𝑥 . From Lemma A.9, if 𝑥 pref ers 𝑦 to 𝑦 ′ , 𝜌 is a predecessor of 𝜎 ; if 𝑥 pref ers 𝑦 ′ to 𝑦 , 𝜎 is a predecessor of 𝜌 . On the other hand, if 𝑦 lies in the 𝑌 -sets of 𝜌 and 𝜎 , then 𝑦 lies in the 𝑋 -sets of 𝜌 and 𝜎 . Then some ( 𝑦 , 𝑥 ) ∈ 𝜌 and some ( 𝑦 , 𝑥 ′ ) ∈ 𝜎 . Appl ying the same reasoning abov e, 𝜌 and 𝜎 are comparable in R ( 𝐼 ) , which means their duals are also comparable in R ( 𝐼 ) . □ Lemma A.11. Assume the f ollo wing conditions hold in 𝑇 0 , the phase-1 table of SR instance 𝐼 : (i) ⟨ 𝑦 , 𝑦 ′ ⟩ is a consecutive sequence of stable par tners of 𝑥 and 𝑣 lies between 𝑦 and 𝑦 ’ in 𝑥 ’ s list (i.e., 𝑦 ≺ 𝑥 𝑣 ≺ 𝑥 𝑦 ′ ); (ii) ⟨ 𝑢 , 𝑢 ′ ⟩ is a consecutive sequence of stable par tners of 𝑣 and 𝑥 lies betw een 𝑢 and 𝑢 ′ in 𝑣 ’ s list (i.e., 𝑢 ≺ 𝑣 𝑥 ≺ 𝑣 𝑢 ′ ). A dditionally , there are non-singular rotations 𝜎 and 𝜌 of 𝐼 such that ( 𝑢 ′ , 𝑣 ) ∈ 𝜎 and ( 𝑥 , 𝑦 ) ∈ 𝜌 . Then 𝜎 is a predecessor of 𝜌 in R ( 𝐼 ) . Pr oof. Consider a table 𝑇 in which 𝜌 is e xposed. Let 𝑇 = 𝑇 0 / 𝑍 . W e will argue that 𝜎 ∈ 𝑍 . Since ( 𝑥 , 𝑦 ) ∈ 𝜌 , 𝑓 𝑇 ( 𝑥 ) = 𝑦 . Fur thermore, 𝑠 𝑇 ( 𝑥 ) = 𝑦 ′ from Lemma A.6. Thus, { 𝑥 , 𝑣 } has already been deleted from 𝑇 . It happened when some rotation 𝜏 ∈ 𝑍 w as eliminated. Since { 𝑥 , 𝑣 } is not a stable pair , according to R emarks A.2 and A.7, some ( 𝑤 ′ , 𝑣 ) ∈ 𝜏 and when 𝜏 w as eliminated 𝑣 w as mo ved up from 𝑤 ′ to a more pref er red stable par tner 𝑤 , the pair { 𝑥 , 𝑣 } w as deleted. From Lemma A.6, this means ⟨ 𝑤 , 𝑤 ′ ⟩ is a consecutiv e sequence of stable partners of 𝑣 , and 𝑥 lies betw een them. But there can only be one such consecutiv e sequence of s table par tners of 𝑣 so it must be the case that ⟨ 𝑤 , 𝑤 ′ ⟩ = ⟨ 𝑢 , 𝑢 ′ ⟩ and ( 𝑢 ′ , 𝑣 ) ∈ 𝜏 . From Corollar y A.8, 𝜏 = 𝜎 . Thus, 𝜎 is a predecessor of 𝜌 . □ Lemma A.12. (Lemma 4.3.2 in [ 23 ].) If 𝜌 and 𝜎 are rotations e xposed in a table 𝑇 and 𝜎 ≠ 𝜌 , then ( 𝑇 / 𝜌 ) / 𝜎 = ( 𝑇 / 𝜎 ) / 𝜌 . Lemma A.13. Let 𝜎 and 𝜌 be non-singular rotations in R ( 𝐼 ) such that 𝜎 is e xposed in a table 𝑇 and 𝜌 is e xposed in 𝑇 / 𝜎 . If 𝜎 and 𝜌 are incomparable in R ( 𝐼 ) , then 𝜌 is also e xposed in 𝑇 . Further more, ( 𝑇 / 𝜎 ) / 𝜌 = ( 𝑇 / 𝜌 ) / 𝜎 . Pr oof. Assume 𝜎 and 𝜌 are incomparable in R ( 𝐼 ) . Let 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) . From Lemma A.5, ⟨ 𝑦 𝑖 , 𝑦 𝑖 + 1 ⟩ is a consecutiv e sequence of stable partners of 𝑥 𝑖 f or 𝑖 = 0 , 1 , . . . , 𝑟 − 1 . By Corollar y A.10, the 𝑋 -sets and the 𝑌 -sets of 𝜎 and 𝜌 are disjoint. Thus, when 𝜎 w as eliminated from 𝑇 , the front of each 𝑥 𝑖 ’ s list w as unaffected and the back of each 𝑦 𝑖 ’ s list w as unaffected. In other words, 𝑓 𝑇 / 𝜎 ( 𝑥 𝑖 ) = 𝑓 𝑇 ( 𝑥 𝑖 ) and ℓ 𝑇 / 𝜎 ( 𝑦 𝑖 ) = ℓ 𝑇 ( 𝑦 𝑖 ) f or 𝑖 = 0 , 1 , . . . , 𝑟 − 1. Suppose 𝜌 is not e xposed in 𝑇 . It must be the case that 𝑠 𝑇 / 𝜎 ( 𝑥 𝑖 ) ≠ 𝑠 𝑇 ( 𝑥 𝑖 ) f or some 𝑥 𝑖 . Assume it is 𝑥 0 . No w , 𝜌 is exposed in 𝑇 / 𝜎 , so 𝑠 𝑇 / 𝜎 ( 𝑥 0 ) = 𝑦 1 . Since 𝑠 𝑇 ( 𝑥 0 ) ≠ 𝑦 1 , the list of 𝑥 0 in 𝑇 looks like the f ollo wing: 𝑥 0 : 𝑦 0 , 𝑣 , . . . , 𝑦 1 , . . . 28 There is an agent 𝑣 that is between consecutive stable par tners 𝑦 0 and 𝑦 1 of 𝑥 0 . When 𝜎 w as eliminated from 𝑇 , the pair { 𝑥 0 , 𝑣 } w as deleted so 𝜌 is e xposed in 𝑇 / 𝜎 . For this to happen, 𝑣 ’ s list in 𝑇 looks like the f ollo wing: 𝑣 : . . . 𝑢 . . . 𝑥 0 . . . 𝑢 ′ There are consecutiv e stable partners 𝑢 , 𝑢 ′ of 𝑣 so that 𝑥 0 lies betw een consecutive stable par tners 𝑢 and 𝑢 ′ and ( 𝑢 ′ , 𝑣 ) ∈ 𝜎 . When 𝜎 w as eliminated from 𝑇 , 𝑣 w as mov ed from 𝑢 ′ to 𝑢 and { 𝑥 0 , 𝑣 } w as eliminated. By Lemma A.11, 𝜎 is a predecessor of 𝜌 . But this contradicts the assumption that 𝜎 and 𝜌 are incomparable. So 𝜌 is e xposed in 𝑇 as w ell. W e also note that 𝜎 ≠ 𝜌 because 𝜌 is e xposed in 𝑇 𝜎 . By Lemma A.12, ( 𝑇 / 𝜎 ) / 𝜌 = ( 𝑇 / 𝜌 ) / 𝜎 . □ Main claims. W e will no w pro ve the three results w e mentioned at the beginning of the appendix. W e cite a f ew more lemmas that w e need f or the proof. Lemma A.14. (Corollary 4.2.2 in [ 23 ].) If 𝑈 is a subtable of table 𝑇 then 𝑈 can be obtained from 𝑇 b y eliminating a sequence of rotations. Lemma A.15. (Lemma 4.3.8 in [ 23 ].) Let 𝑍 0 contain all the singular rotations in R ( 𝐼 ) . Then 𝑍 0 is closed and e very stable matching is embedded in the table 𝑇 ′ 0 = 𝑇 0 / 𝑍 0 . Combining Lemmas A.14 and A.15, w e note that every stable matc hing can be obtained from the table 𝑇 ′ 0 b y eliminating a sequence of rotations. Clearl y , these rotations ha ve to be non-singular . Lemma A.16. (Lemma 4.3.4 in [ 23 ].) If both of the rotations 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) and 𝜌 = ( 𝑦 1 , 𝑥 0 ) , ( 𝑦 2 , 𝑥 1 ) , . . . , ( 𝑦 0 , 𝑥 𝑟 − 1 ) are e xposed in the table 𝑇 , then f or 𝑖 = 0 , . . . , 𝑟 − 1 , the list of 𝑥 𝑖 in 𝑇 contains onl y 𝑦 𝑖 and 𝑦 𝑖 + 1 , and the list of 𝑦 𝑖 in 𝑇 contains onl y 𝑥 𝑖 − 1 and 𝑥 𝑖 . The elimination of 𝜌 or 𝜌 from 𝑇 reduces the list of eac h 𝑥 𝑖 and each 𝑦 𝑖 to a single entry , but affects no other list. Corollary 3.5. Let 𝐼 be a solv able SR instance with 2 𝑛 ag ents and let R ′ ( 𝐼 ) its r educed ro tation poset. Given a complet e closed subset 𝑆 of R ′ ( 𝐼 ) , the stable matc hing of 𝐼 that corr esponds to 𝑆 can be obtained in 𝑂 ( 𝑛 2 ) time. Pr oof. Let 𝜇 be the stable matc hing that cor responds to 𝑆 . From Lemmas A.14 and A.15, the rotations in 𝑆 can be ordered sequentiall y and deleted from 𝑇 ′ 0 to obtain 𝜇 . Let Π 𝑆 be one such sequence. For eac h agent 𝑎 , let X 𝑎 and Y 𝑎 consist of the rotations in 𝑆 so that 𝑎 is in the 𝑋 -set or the 𝑌 -set of the rotations respectiv ely . Assume X 𝑎 ≠ ∅ . Let 𝜌 1 , 𝜌 2 , . . . , 𝜌 𝑟 ∈ X 𝑎 . For 𝑖 = 1 , . . . , 𝑟 , let ( 𝑎 , 𝑏 𝑖 ) ∈ 𝜌 𝑖 . Without loss of generality , assume the 𝑏 𝑖 ’ s are ordered from 𝑎 ’ s most pref erred to least pref er red. Then b y Lemma A.9, 𝜌 1 , 𝜌 2 , . . . , 𝜌 𝑟 − 1 are predecessors of 𝜌 𝑟 in R ′ ( 𝐼 ) . That is, in Π 𝑆 , 𝜌 𝑟 is the last one to be eliminated among the rotations in X 𝑎 . Let 𝑇 be the resulting table when 𝜌 𝑟 and all the rotations pr ior to 𝜌 𝑟 in Π 𝑆 ha ve been eliminated from 𝑇 ′ 0 . Then 𝑓 𝑇 ( 𝑎 ) = 𝑏 𝑟 + 1 , the stable par tner that 𝑎 pref ers after 𝑏 𝑟 according to Lemma A.6. The elimination of the rotations after 𝜌 𝑟 in Π 𝑆 ma y still delete entries from 𝑎 ’ s list, but none of them can delete 𝑏 𝑟 + 1 because 𝑎 is not in their 𝑋 -sets. Thus, when all the rotations in Π 𝑆 ha ve been deleted, the onl y entr y in 𝑎 ’ s list is 𝑏 𝑟 + 1 . Suppose Y 𝑎 ≠ ∅ . Let 𝜎 1 , 𝜎 2 , . . . , 𝜎 𝑟 ∈ Y 𝑎 . For 𝑖 = 1 , . . . , 𝑟 , let ( 𝑐 𝑖 , 𝑎 ) ∈ 𝜎 𝑖 . Assume the 𝑐 𝑖 ’ s are ordered from 𝑎 ’ s most pref er red to least preferred. From Lemma A.6, 𝑎 has a stable par tner 𝑐 0 in the 𝑋 -set of 𝜎 1 that 𝑎 pref ers just bef ore 𝑐 1 . Further more, ( 𝑎 , 𝑐 0 ) ∈ 𝜎 1 and, f or 𝑖 = 2 , . . . , 𝑟 , ( 𝑎 , 𝑐 ′ 𝑖 ) ∈ 𝜎 𝑖 where 𝑐 ′ 𝑖 is the stable par tner that 𝑎 pref ers just before 𝑐 𝑖 . None of them is pref er red by 𝑎 to 𝑐 0 so 𝜎 1 is a predecessor of 𝜎 2 , 𝜎 3 , . . . , 𝜎 𝑟 in R ′ ( 𝐼 ) . Hence, 𝜎 2 , . . . , 𝜎 𝑟 are predecessors of 𝜎 1 in R ′ ( 𝐼 ) . It f ollow s that in Π 𝑆 , 𝜎 1 is the last one to be eliminated among the rotations in Y 𝑎 . Let 𝑇 be the table when 𝜎 1 and all rotations prior to 𝜎 1 in Π 𝑆 ha ve been eliminated from 𝑇 ′ 0 . Then ℓ 𝑇 ( 𝑎 ) = 𝑐 0 . The elimination of the rotations after 𝜎 1 in Π 𝑆 ma y 29 still delete entries from 𝑎 ’ s list, but none of them can delete 𝑐 0 because 𝑎 is not in their 𝑌 -sets. Hence, 𝑐 0 is the onl y entr y left in 𝑎 ’ s list once all the rotations in Π 𝑆 are deleted. W e hav e sho wn that when X 𝑎 ≠ ∅ or Y 𝑎 ≠ ∅ , the par tner of 𝑎 in 𝜇 can be determined by jus t ex amining the rotations that contain 𝑎 . But it is possible that X 𝑎 = Y 𝑎 = ∅ . This happens when 𝑎 is par t of a fixed pair; i.e., there is an agent 𝑏 so that { 𝑎 , 𝑏 } is in ev er y stable matc hing of 𝐼 . For suc h agents 𝑎 , run Ir ving’ s algorithm to produce a stable matching 𝜂 of 𝐼 . Then 𝑎 ’s partners in 𝜇 and 𝜂 are the same. There are 𝑂 ( 𝑛 2 ) total pairs in the rotations in 𝑆 . By e xamining them, it is possible in 𝑂 ( 𝑛 2 ) time to simultaneousl y deter mine f or all agents 𝑎 the stable par tner 𝑏 𝑟 + 1 in the abov e discussion when X 𝑎 ≠ ∅ or the stable partner 𝑐 0 in the abo ve discussion when Y 𝑎 ≠ ∅ . Finall y , f or agents that are part of fix ed pair , r un Irving’ s algor ithm which takes 𝑂 ( 𝑛 2 ) time. Thus, all the par tners of all the agents can be deter mined in 𝑂 ( 𝑛 2 ) time. □ Lemma 3.10. Let 𝜇 and 𝜇 ′ be two stable matchings of SR instance 𝐼 that ar e adjacent in 𝐺 ( 𝐼 ) . Le t 𝜌 = ( 𝑥 0 , 𝑦 0 ) , ( 𝑥 1 , 𝑦 1 ) , . . . , ( 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 ) be the (non-singular) r otation so that 𝑆 𝜇 ′ − 𝑆 𝜇 = { 𝜌 } . Then 𝜇 ′ = 𝜇 − { { 𝑥 0 , 𝑦 0 } , { 𝑥 1 , 𝑦 1 } , . . . , { 𝑥 𝑟 − 1 , 𝑦 𝑟 − 1 } } ∪ { { 𝑥 0 , 𝑦 1 } , { 𝑥 1 , 𝑦 2 } , . . . , { 𝑥 𝑟 − 1 , 𝑦 0 } } . Pr oof. Let Π 𝜇 ′ = ⟨ 𝜎 1 , 𝜎 2 , . . . , 𝜎 𝑘 ⟩ and Π 𝜇 = ⟨ 𝜏 1 , 𝜏 2 , . . . , 𝜏 𝑘 ⟩ be sequences of non-singular rotations eliminated from 𝑇 ′ 0 to obtain the stable matching 𝜇 ′ and 𝜇 respectiv ely . Thus, 𝑆 𝜇 ′ = { 𝜎 1 , 𝜎 2 , . . . , 𝜎 𝑘 } and 𝜌 ∈ 𝑆 𝜇 ′ while 𝑆 𝜇 = { 𝜏 1 , 𝜏 2 , . . . , 𝜏 𝑘 } and 𝜌 ∈ 𝑆 𝜇 . Moreo v er , 𝑈 = 𝑆 𝜇 ′ − { 𝜌 } = 𝑆 𝜇 − { 𝜌 } . Suppose 𝜎 𝑖 = 𝜌 and 𝑖 ≠ 𝑘 . Consider the rotations 𝜎 𝑖 + 1 , 𝜎 𝑖 + 2 , . . . , 𝜎 𝑘 . They clear ly are not predecessors of 𝜌 because 𝜌 w as eliminated bef ore them to obtain 𝜇 . Moreo ver , 𝜌 is not a predecessor to any of them because the y are all in 𝑆 𝜇 but 𝜌 ∉ 𝑆 𝜇 . Thus, 𝜌 and 𝜎 𝑗 are incomparable in R ( 𝐼 ) f or 𝑗 = 𝑖 + 1 , . . . , 𝑘 . Let 𝑇 1 = 𝑇 ′ 0 / 𝜎 1 and 𝑇 𝑗 = 𝑇 𝑗 − 1 / 𝜎 𝑗 f or 𝑗 = 2 , . . . , 𝑘 . Thus, 𝜎 𝑖 = 𝜌 is exposed in 𝑇 𝑖 − 1 while 𝜎 𝑖 + 1 is exposed in 𝑇 𝑖 = 𝑇 𝑖 − 1 / 𝜎 𝑖 . Since 𝜌 and 𝜎 𝑖 + 1 are incomparable rotations, b y Lemma A.13, 𝜌 and 𝜎 𝑖 + 1 can be sw apped in Π 𝜇 ′ and the result is still 𝜇 ′ . Applying this argument o v er and ov er ag ain, Lemma A.13 implies that when the sequence ⟨ 𝜎 1 , . . . , 𝜎 𝑖 − 1 , 𝜎 𝑖 + 1 , . . . , 𝜎 𝑘 , 𝜌 ⟩ is eliminated from 𝑇 ′ 0 , the result is 𝜇 ′ . Thus, w e shall assume that in both Π 𝜇 ′ and Π 𝜇 , 𝜌 and 𝜌 are the last rotations eliminated to obtain 𝜇 and 𝜇 ′ respectiv ely . Let 𝑇 ′ = 𝑇 ′ 0 / 𝑈 . From the pre vious parag raph, both 𝜌 and 𝜌 are e xposed in 𝑇 ′ . From Lemma A.16, the list of 𝑥 𝑖 contains 𝑦 𝑖 , 𝑦 𝑖 + 1 while the list of 𝑦 𝑖 contains 𝑥 𝑖 − 1 , 𝑥 𝑖 , for 𝑖 = 0 , . . . , 𝑟 − 1 . Eliminating 𝜌 from 𝑇 ′ results in 𝜇 ′ ; it also deletes 𝑥 𝑖 and 𝑦 𝑖 from each other’ s lists. Thus, { { 𝑥 𝑖 , 𝑦 𝑖 + 1 } , 𝑖 = 0 , . . . , 𝑟 − 1 } ⊆ 𝜇 ′ . On the other hand, 𝜌 = ( 𝑦 1 , 𝑥 0 ) , ( 𝑦 2 , 𝑥 1 ) , . . . , ( 𝑦 0 , 𝑥 𝑟 − 1 ) . Applying the same reasoning, eliminating 𝜌 from 𝑇 ′ results in 𝜇 and { { 𝑦 𝑖 , 𝑥 𝑖 } , 𝑖 = 0 , . . . , 𝑟 − 1 } ⊆ 𝜇 . No w , f or agents 𝑣 ∉ { 𝑥 0 , 𝑥 1 , . . . , 𝑥 𝑟 − 1 , 𝑦 0 , 𝑦 1 , . . . , 𝑦 𝑟 − 1 } , the elimination of 𝜌 nor 𝜌 did not affect 𝑣 ’ s list so it must be the case that 𝑣 ’ s list consists of jus t one entr y and it is 𝑣 ’ s par tner in both 𝜇 and 𝜇 ′ . Thus, 𝜇 ′ = 𝜇 − { { 𝑦 𝑖 , 𝑥 𝑖 } , 𝑖 = 0 , . . . , 𝑟 − 1 } ∪ { { 𝑥 𝑖 , 𝑦 𝑖 + 1 } , 𝑖 = 0 , . . . , 𝑟 − 1 } . □ B Hardness of 3 -R egular MV C In this appendix, we pro vide a proof of the NP-hardness of minimum v er te x co ver on 3 -regular graphs (F act 6.1). Our starting point is the f ollowing theorem due to Gare y , Johnson, and Stoc kmey er [19] Theorem B.1 ([ 19 ]) . Minimum V er te x Cov er is NP -hard when restricted to graphs 𝐺 = ( 𝑉 , 𝐸 ) where each v er te x has maximum deg ree at most 3. 30 Our proof of F act 6.1 is a two-s tep reduction from Theorem B.1. W e first show that MV C is hard on graphs where all vertices hav e degree 2 or 3 . W e then use this intermediate result to show that MV C is NP -hard on 3 -regular graphs. The basic idea f or both steps is the same: define a gadg et graph 𝐻 such that replacing each v er te x of a graph 𝐺 with degree 1 (or 2 ) with a cop y of 𝐻 results in a graph with no deg ree-1 (or degree-2) vertices such that a minimum verte x co ver of 𝐺 can be computed from a minimum v er tex co v er of the resulting graph 𝐺 ′ . Lemma B.2. MV C on graphs 𝐺 = ( 𝑉 , 𝐸 ) with maximum degree 3 reduces to MV C on graphs with maximum degree 3 and minimum degree 2. Pr oof. Let 𝐺 = ( 𝑉 , 𝐸 ) be a g raph with maximum degree 3 , and let 𝑣 ∈ 𝑉 . Define the gadg et graph 𝐻 𝑣 = ( { 𝑣 𝑛 , 𝑣 𝑠 , 𝑣 𝑒 , 𝑣 𝑤 } , 𝐸 𝑣 ) where the edg es form a 4 -cy cle 𝑣 𝑛 , 𝑣 𝑒 , 𝑣 𝑠 , 𝑣 𝑤 tog ether with a vertical edge { 𝑣 𝑛 , 𝑣 𝑠 } depicted here: 𝑣 𝑛 𝑣 𝑠 𝑣 𝑣 𝑤 Observe that 𝐻 𝑣 has maximum degree 3 and minimum degree 2. Let 𝐺 ′ = ( 𝑉 ′ , 𝐸 ′ ) be the graph obtained from 𝐺 b y replacing each v er tex 𝑣 with deg ( 𝑣 ) = 1 with a cop y of 𝐻 𝑣 . That is if 𝑣 ∈ 𝑉 with deg ( 𝑣 ) = 1 , and { 𝑣 , 𝑤 } ∈ 𝐸 , then 𝐺 ′ will contain the v er tices { 𝑣 𝑛 , 𝑣 𝑠 , 𝑣 , 𝑣 𝑤 } tog ether with the edge { 𝑣 , 𝑤 } : 𝑣 𝑤 − → 𝑣 𝑛 𝑣 𝑠 𝑣 𝑣 𝑤 𝑤 W e first obser v e that the resulting graph 𝐺 ′ has minimum deg ree 2 and maximum deg ree 3 . Suppose 𝐺 contained 𝑔 deg ree 1 v er tices, so that 𝐺 ′ contains 𝑔 cor responding gadg ets 𝐻 𝑣 . W e claim that 𝐺 has a v er te x co ver of size at most 𝑘 if and onl y if 𝐺 ′ has a v er te x co ver of size at most 𝑘 + 2 𝑔 . T o see this, first suppose 𝐺 has a v er te x cov er 𝐴 of size 𝑘 . Let 𝑉 1 ⊆ 𝑉 denote the vertices in 𝑉 with degree 1 in 𝐺 , so that each 𝑣 ∈ 𝑉 1 cor responds to a g adget 𝐻 𝑣 in 𝐺 ′ . Form the set 𝐴 ′ as 𝐴 ′ = 𝐴 ∪ { 𝑣 𝑛 , 𝑣 𝑠 | 𝑣 ∈ 𝑉 1 } . (6) It is clear that 𝐴 ′ is a v er tex co v er of size 𝑘 + 2 𝑔 . No w suppose 𝐴 ′ is a v er tex co v er of 𝐺 ′ of size 𝑘 + 2 𝑔 , and define 𝐴 = 𝐴 ′ ∩ 𝑉 . It is clear that 𝐴 is a v er te x co ver of 𝐺 . Further, | 𝐴 | ≤ 𝑘 , because an y v er tex cov er of a gadg et 𝐻 𝑣 must contain at leas t two of { 𝑣 𝑛 , 𝑣 𝑠 , 𝑣 𝑤 } . By the claim abov e, a minimum v er tex cov er 𝐴 ′ of 𝐺 ′ giv es a minimum v ertex cov er 𝑉 ∩ 𝐴 ′ of 𝐺 , and the lemma f ollo ws. □ Using Lemma B.2, w e can prov e F act 6.1. 31 Pr oof of F act 6.1. By Lemma B.2, it suffices to show that MV C on graphs with maximum degree 3 and minimum degree 2 reduces to MV C on 3 -regular graphs. T o this end, suppose 𝐺 = ( 𝑉 , 𝐸 ) is a graph with maximum degree 3 and minimum deg ree 2 . Let 𝑉 2 = { 𝑣 ∈ 𝑉 | deg ( 𝑣 ) = 2 } denote the set of v er tices with degree 2 . For eac h 𝑣 ∈ 𝑉 , define the gadg et 𝐻 𝑣 = ( { 𝑣 𝑛 , 𝑣 𝑠 , 𝑣 𝑒 , 𝑣 𝑤 } , 𝐸 𝑣 ) to be the 4 -cy cle with a v ertical edge as bef ore: 𝑣 𝑛 𝑣 𝑠 𝑣 𝑒 𝑣 𝑤 Form the graph 𝐺 ′ b y replacing each 𝑣 ∈ 𝑉 2 with 𝐻 𝑣 as f ollo ws: if 𝑣 has neighbors 𝑢 and 𝑤 , then replace 𝑣 with 𝑉 𝑣 , add the edg es 𝐸 𝑣 along with edg es { 𝑢 , 𝑣 𝑤 } and { 𝑣 𝑒 , 𝑤 } : 𝑢 𝑣 𝑤 − → 𝑢 𝑣 𝑛 𝑣 𝑠 𝑣 𝑒 𝑣 𝑤 𝑤 It is clear that 𝐺 ′ is a 3-regular graph. As bef ore, w ee claim that 𝐺 admits a v er te x co ver of size at mos t 𝑘 if and onl y if 𝐺 ′ admits a v er te x co ver of size at most 𝑘 + 2 𝑔 , where 𝑔 = | 𝑉 2 | is the number of gadg ets added to 𝐺 to f or m 𝐺 ′ . First, suppose 𝐴 ⊂ 𝑉 is a v er te x cov er of 𝐺 of size 𝑘 , and let 𝐴 2 = 𝐴 ∩ 𝑉 2 . No w f or m 𝐴 ′ as f ollo ws: 𝐴 ′ = ( 𝐴 \ 𝐴 2 ) ∪ { 𝑣 𝑤 , 𝑣 𝑛 , 𝑣 𝑒 | 𝑣 ∈ 𝐴 2 } ∪ { 𝑣 𝑛 , 𝑣 𝑠 | 𝑣 ∈ 𝑉 2 \ 𝐴 2 } . That is, f or each v er te x 𝑣 ∈ 𝐴 2 , w e add the three v er tices 𝑣 𝑤 , 𝑣 𝑛 , 𝑣 𝑒 to 𝐴 ′ , and f or each v er te x 𝑣 ∈ 𝑉 2 \ 𝐴 2 , w e add the v er tices 𝑣 𝑛 , 𝑣 𝑠 to 𝐴 ′ . Note that | 𝐴 ′ | = | 𝐴 | + 2 𝑔 . Fur ther , 𝐴 ′ is a v er te x cov er: if 𝑣 ∈ 𝐴 2 , then adding 𝑣 𝑤 and 𝑣 𝑒 to 𝐴 ′ ensures that the edg es { 𝑢 , 𝑣 𝑤 } and { 𝑣 𝑒 , 𝑤 } are co v ered, while if 𝑣 ∈ 𝑉 2 \ 𝐴 2 , then these edges are already co vered in 𝐴 b y 𝑢 and 𝑤 , respectivel y . Con versel y , suppose 𝐺 ′ admits a v er te x cov er 𝐶 ′ of size 𝑘 + 2 𝑔 . Form the set 𝐴 as f ollo ws: 𝐴 = ( 𝐴 ′ ∩ 𝑉 ) ∪ { 𝑣 ∈ 𝑉 2 | 𝑣 𝑤 ∈ 𝐴 ′ or 𝑣 𝑒 ∈ 𝐴 ′ } . (7) That is, w e take 𝐴 to be 𝐴 ′ ’ s restriction to 𝑉 , union an y v er tices 𝑣 such that 𝑣 𝑤 or 𝑣 𝑒 is contained in 𝐴 ′ . T o see that 𝐴 is a v er te x co v er of 𝐺 , note that including { 𝑣 ∈ 𝑉 2 | 𝑣 𝑤 ∈ 𝐴 ′ or 𝑣 𝑒 ∈ 𝐴 ′ } in 𝐴 ensures that all edg es incident to v er tices 𝑣 ∈ 𝑉 2 are co vered, while all other edg es w ere cov ered because 𝐴 ′ w as a verte x co ver of 𝐺 ′ . W e note that | 𝐴 | ≤ | 𝐴 ′ | − 2 𝑔 . This is because any v er te x co v er 𝐴 ′ must contain at leas t 3 elements from 𝑉 𝑣 unless 𝐴 ′ ∩ 𝑉 𝑣 = { 𝑣 𝑛 , 𝑣 𝑠 } , in whic h case 𝑣 is not added to 𝐴 . Thus, each 𝐻 𝑣 cor responds to a net loss of at least 2 v ertices from 𝐴 ′ . Finall y , b y the claim, if 𝐴 ′ is a minimum v er te x co ver f or 𝐺 ′ , then the 𝐴 as in (7) is a minimum v er te x co ver f or 𝐺 . □ 32

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment