The Perfect Matching Reconfiguration Problem

We study the perfect matching reconfiguration problem: Given two perfect matchings of a graph, is there a sequence of ﬂip operations that transforms one into the other? Here, a ﬂip operation exchanges the edges in an alternating cycle of length four. We are interested in the complexity of this decision problem from the viewpoint of graph classes. We ﬁrst prove that the problem is PSPACE-complete even for split graphs and for bipartite graphs of bounded bandwidth with maximum degree ﬁve. We then investigate polynomial-time solvable cases. Speciﬁcally, we prove that the problem is solvable in polynomial time for strongly orderable graphs (that include interval graphs and strongly chordal graphs), for outerplanar graphs, and for cographs (also known as P 4 -free graphs). Furthermore, for each yes-instance from these graph classes, we show that a linear number of ﬂip operations is suﬃcient and we can exhibit a corresponding sequence of ﬂip operations in polynomial time

Figure 1: A transformation between perfect matchings M 0 and M 4 under the flip operation.For 1 ≤ i ≤ 4, the matching M i can be obtained from M i−1 by applying the flip operation to the cycle induced by the four painted (red) vertices in M i .

Introduction
Given an instance of some combinatorial search problem and two of its feasible solutions, a reconfiguration problem asks whether one solution can be transformed into the other in a step-by-step fashion, such that each intermediate solution is also feasible.Reconfiguration problems capture dynamic situations, where some solution is in place and we would like to move to a desired alternative solution without becoming infeasible.A systematic study of the complexity of reconfiguration problems was initiated in [22].Recently the topic has gained a lot of attention in the context of constraint satisfaction problems and graph problems, such as the independent set problem, the matching problem, and the dominating set problem.Reconfiguration problems naturally arise for operational research problems but also are closely related to uniform sampling (using Markov chains) or enumeration of solutions of a problem.For an overview of recent results on reconfiguration problems, the reader is referred to the surveys of van den Heuvel [18] and Nishimura [28].
In order to define valid step-by-step transformations, an adjacency relation on the set of feasible solutions is needed.Depending on the problem, there may be different natural choices of adjacency relations.For instance, we may assume that two matchings of a graph are adjacent if one can be obtained from the other by exchanging precisely one edge, i.e., there exists e ∈ M and f ∈ M such that M \ {e} = M \ {f }.The corresponding modification of a matching is usually referred to as token jumping (TJ).Here, the tokens are the edges of a matching and a token may be "moved" from an edge of the matching to another edge so that we obtain the another matching.On can similarly another adjacency relation, where two matchings are adjacent if one can be obtained from the other by moving a token to some incident edge.The adjacency relation is called token sliding (TS).Ito et al. [22] gave a polynomial-time algorithm that decides if there is a transformation between two given matchings under the TJ and TS operations.

The Perfect Matching Reconfiguration Problem
Recall that a matching of a graph is perfect if it covers each vertex.We study the complexity of deciding if there is a step-by-step transformation between two given perfect matchings of a graph.However, according to the adjacency relations given by the TS and TJ operations, there is no transformation between any two distinct perfect matchings of a graph.Since the symmetric difference of any two perfect matchings of a graph consists of even-length disjoint cycles, it is natural to consider a different adjacency relation for perfect matchings.We say that two perfect matchings of a graph differ by a flip (or swap) if their symmetric difference induces a cycle of length four.We consider two perfect matchings to be are adjacent if they differ by a flip.Intuitively, for two adjacent perfect matchings M and M , we think of a flip as an operation that exchanges edges in M \ M for edges in M \ M .A flip is in some sense a minimal modification of a perfect matching.
An example of a transformation between two perfect matchings of a graph is given in Figure 1.We formalize the task of deciding the existence of transformation between two given perfect matchings as follows.
Perfect Matching Reconfiguration input: Graph G, perfect matchings M s and M t of G. question: Is there a sequence of flips that transforms M s into M t ?
Note that if we do not restrict the length of a cycle in the definition of a flip, then for any two perfect matchings M s and M t of a graph, there is a sequence of flip operations that transforms M s into M t , since we can perform a flip on each cycle of the symmetric difference of M s and M t .As a compromise, we may extend the problem definition to flips on cycles of fixed constant length k, where k > 4 and k is even.We refer to the corresponding reconfiguration problem as k-Perfect Matching Reconfiguration.

Related Work
Transformations between matchings have been studied in various settings.Transformation of matchings using flips has been considered for generating random matchings.Numerous algorithms and hardness results are available for finding transformations between matchings -and more generally, independent sets -using the TS and TJ operations.Furthermore, the flip operation is well-known for stable matchings and some geometric matching problems related to finding transformations between triangulations.

Sampling Random Matchings
The problem of sampling or enumerating perfect matchings in a graph received a considerable attention (see e.g.[32]).Determining the connectivity, and the diameter of the solution space formed by perfect matchings under the flip operation provide some information on the ergodicity or the mixing time of the underlying Markov chain.Indeed, the connectivity of the chain ensures the irreducibility (and usually the ergodicity) of the underlying Markov chain.Additionally, the diameter of the reconfiguration graph provides a lower bound on the mixing time of the chain.
The use of flips for sampling random perfect matchings was first started in [9] where it is seen as a generalisation of transpositions for permutations.Their work was later improved and generalized in [13] and [14].The focus of these last two articles is to investigate the problem of sampling random perfect matchings using a Markov Chain called the switch chain.Starting from an arbitrary perfect matching, the chain proceeds by applying at each step a random flip (called switch in these papers).The aim of these papers is to characterize classes of graphs for which simulating this chain for a polynomial number of steps is enough to generate a perfect matching close to uniformly distributed.Some of their results can be reformulated in the reconfiguration terminology.In [13], it is proved that the largest hereditary class of bipartite graphs for which the reconfiguration graph of perfect matchings with flips is connected is the class of chordal bipartite graphs.This result is generalized in [14] where they characterize the hereditary class of general (non-bipartite) graphs for which the reconfiguration graph is connected.They call this class Switchable.Note that it is not clear whether graphs in this class can be recognized in polynomial time.The question of the complexity of perfect matching reconfiguration is also mentioned in [14].
Reconfiguration of Matchings and Independent Sets.Recall that matchings of a graph correspond to independent sets of its line graph.Although reconfiguration of independent sets received a considerable attention in the last decade (e.g., [5,6,8,17,23,24,34]), all the known results for reconfiguration of independent sets are based on the TJ or TS operations as adjacency relations.Thus, none of these results carry over to the Perfect Matching Reconfiguration problem.
A related problem can be found in a more general setting: The problem of determining, enumerating, or randomly generating graphs with a fixed degree sequence has received a considerable attention since the fifties (see e.g.[31,16,33]).Given two graphs with a fixed degree sequence, one might want to know if it is possible to transform the one into the other via a sequence of flip operations and if yes, how many steps are needed for such a transformation; note that the host graph (i.e., the graph G in our problem) is a clique in this setting.Hakimi [16] proved that such a transformation always exists.Will [33] proved that the problem of finding a shortest transformation is NP-complete, and Bereg and Ito [2] provide a 3 2 -approximation algorithm for this problem.
Stable Matchings.Suppose we are given a bipartite graph and for each vertex a linear preference order of its neighbors.A matching M is not stable if there is an edge uv not in M , such that u prefers v and v prefers u to their respective M -partners.The classical algorithm by Gale and Shapley [15] yields a stable matching in polynomial time.It is known that any two stable matchings cover the same vertices, so the stable matchings are perfect matchings of some subgraph.Furthermore, they form a distributive lattice under rotations (another word for flips) on preference-orienced cycles, see for example [15].Essentially, the symmetric difference of two stable matchings consists of disjoint cycles and we may flip edges on these cycles to obtain another stable matching.If we drop the preferences, then the question is simply if we can find a transformation between two perfect matchings by flipping edges on cycles in the symmetric difference.Clearly the answer is yes, for example by processing the cycles in the symmetric difference one-by-one.We consider a similar setting, but restrict the length of the cycles.

Flips of Triangulations.
A flip of a triangulation is similar to flipping an alternating cycle in the sense that we switch between two states of a quadrilateral.In the context of triangulations, a flip operation switches the diagonal of a quadrilateral.Transformations between triangulations of point sets and polygons using flips have been studied mostly in the plane.It is known that the flip graph of triangulations of point sets and polygons in the plane is connected and has diameter O(n 2 ), where n is the number of points [21,25].Recently, NP-completeness has been proved for deciding the flip-distance between triangulations of a point set in the plane [26] and triangulations of a simple polygon [1].Houle et al. have considered triangulations of point sets in the plane that admit a perfect matching [19].They show that any two such triangulations are connected under the flip operation.For this purpose they consider the graph of non-crossing perfect matchings, where two matchings are adjacent if they differ by a single non-crossing cycle (of arbitrary length).They show that the graph of non-crossing perfect matchings is connected and conclude from this that any two triangulations that admit a perfect matching must be connected.In contrast to their setting, we remove all geometric requirements, but restrict the length of the cycles allowed for the flip operation.

Our results
In this paper, we study the complexity of Perfect Matching Reconfiguration from the viewpoint of graph classes.Figure 2 summarizes our results.
Recall that reconfiguration of matchings under the TS and TJ operations can be solved in polynomial time for any graph [22].In contrast, we prove that Perfect Matching Reconfiguration is PSPACEcomplete, even for split graphs, and for bipartite graphs of bounded bandwidth and of maximum degree five.We extend our hardness result to a more general setting, namely the reconfiguration of k-factor subgraphs.Furthermore, by adjusting our gadgets appropriately, we show that k-Perfect Matching Reconfiguration is PSPACE-complete for any even k ≥ 4. Note that this result contrasts with TJ-Matching Reconfiguration problem that can be decided in polynomial time [22] and with geometric reconfiguration problems where the reconfiguration operation is a flip (e.g., flips of triangulations [26]) which usually belong to NP.
We additionally investigate polynomial-time solvable cases.We prove that Perfect Matching Reconfiguration admits a polynomial-time algorithm on strongly orderable graphs (these include interval graphs and strongly chordal graphs), outerplanar graphs, and cographs (also known as P 4 -free graphs).More specifically, we give the following results: • For strongly orderable graphs, a transformation between two perfect matchings always exists; hence the answer is always yes.Furthermore, there is a transformation of linear length (i.e., a linear number of flip operations) between any two matchings and such a transformation can be found in polynomial time.
• Perfect Matching Reconfiguration on outerplanar graphs can be solved in linear time, and we can find a transformation of linear length for a yes-instance in linear time.(Note that there are no-instance, e.g., long cycles).
• Perfect Matching Reconfiguration on cographs can be solved in polynomial time, and we can find a transformation of linear length for a yes-instance in polynomial time.(Again, there are no-instances).
Proofs of the claims marked with ( * ) and one figure have been moved to Appendices.

Notation
For standard definitions and notations on graphs, we refer the reader to [10].Let G = (V, E) be a simple graph.Two edges are independent if they share no endpoint.A matching M ⊆ E of G is a set of pairwise independent edges.For a vertex set V ⊆ V , we denote by Two matchings M and M of G are adjacent if their symmetric difference M M induces a cycle of length four.We write M G ↔ M if M and M are adjacent; we may omit G if no confusion is possible.A sequence M 0 , M 1 , . . ., M q of matchings in G is called a reconfiguration sequence between M and M if M 0 = M , M q = M , and for 1 ≤ i ≤ q, we have M i−1 G ↔ M i .We write M G M (or simply M M ) if there is a reconfiguration sequence between M and M .The Matching Reconfiguration problem under the flip operation is defined as follows: Input: A simple graph G, and two matchings M s and M t of G Question: Determine whether M s G M t or not.

PSPACE-completeness
In this section, we prove that perfect matching reconfiguration is PSPACE-complete.Interestingly, the problem remains intractable even for bipartite graphs, even though matchings in bipartite graphs satisfy several nice properties.
Theorem 1. Perfect matching reconfiguration is PSPACE-complete for bipartite graphs whose maximum degree is five and whose bandwidth is bounded by a fixed constant.
Proof.Observe that the problem can be solved in (most conveniently, nondeterministic [30]) polynomial space, and hence it is in PSPACE.As a proof of Theorem 1, we thus prove that the problem is PSPACEhard for such graphs, by giving a polynomial-time reduction from the Nondeterministic Constraint Logic problem (NCL for short) [17].Definition of nondeterministic constraint logic.An NCL "machine" is an undirected graph together with an assignment of weights from {1, 2} to each edge of the graph.An (NCL) configuration of this machine is an orientation (direction) of the edges such that the sum of weights of in-coming arcs at each vertex is at least two.Figure 3(a) illustrates a configuration of an NCL machine, where each weight-2 edge is depicted by a (blue) thick line and each weight-1 edge by a (red) thin line.Then, two NCL configurations are adjacent if they differ in a single edge direction.Given an NCL machine and its two configurations, it is known to be PSPACE-complete to determine whether there exists a sequence of adjacent NCL configurations which transforms one into the other [17].An NCL machine is called an and/or constraint graph if it consists of only two types of vertices, called "NCL and vertices" and "NCL or vertices" defined as follows: A vertex of degree three is called an NCL and vertex if its three incident edges have weights 1, 1, and 2. (See Figure 3(b).)An NCL and vertex u behaves as a logical and, in the following sense: the weight-2 edge can be directed outward for u only if both two weight-1 edges are directed inward for u.Note that, however, the weight-2 edge is not necessarily directed outward even when both weight-1 edges are directed inward.A vertex of degree three is called an NCL or vertex if its three incident edges have weights 2, 2, and 2. (See Figure 3(c).)An NCL or vertex v behaves as a logical or: one of the three edges can be directed outward for v if and only if at least one of the other two edges is directed inward for v.It should be noted that, although it is natural to think of NCL and/or vertices as having inputs and outputs, there is nothing enforcing this interpretation; especially for NCL or vertices, the choice of input and output is entirely arbitrary because an NCL or vertex is symmetric.For example, the NCL machine in Figure 3(a) is an and/or constraint graph.From now on, we call an and/or constraint graph simply an NCL machine, and call an edge in an NCL machine an NCL edge.NCL remains PSPACE-complete even if an input NCL machine is planar, bounded bandwidth, and of maximum degree three [35].
Gadgets.Suppose that we are given an instance of NCL, that is, an NCL machine and two configurations of the machine.We will replace each of NCL edges and NCL and/or vertices with its corresponding gadget; if an NCL edge e is incident to an NCL vertex v, then we connect the corresponding gadgets for e and v by a pair of vertices, called connectors (between v and e) or (v, e)-connectors, as illustrated in Figure 4(a) and (b).Thus, each edge gadget has two pairs of connectors, and each and/or gadget has three pairs of connectors.Our gadgets are all edge-disjoint, and share only connectors.
In our reduction, we construct the correspondence between orientations of an NCL machine and perfect matchings of the corresponding graph, as follows: We regard that the orientation of an NCL edge e = vw is inward direction for v if the two (v, e)-connectors are both covered by (edges in) the and/or gadget for v. On the other hand, we regard that the orientation of e = vw is outward direction for w if the two (w, e)-connectors are both covered by the edge gadget for e. Figure 5 shows our three types of gadgets which correspond to NCL edges and NCL and/or vertices.We below explain the behavior of each gadget.
Edge gadget.Recall that, in a given NCL machine, two incident NCL vertices v and w are joined by a single NCL edge e = vw.Therefore, the edge gadget for vw should be consistent with the orientations of the NCL edge vw, as follows (see also Figure 6): If (v, e)-connectors are both covered by the and/or gadget for v (i.e., the inward direction for v), then (w, e)-connectors must be covered by the edge gadget for e (i.e., the outward direction for w); conversely, the (v, e)-connectors must be covered by the edge gadget for e if (w, e)-connectors are covered by the and/or gadget for w.In particular, the edge gadget must forbid a configuration such that all (v, e)-and (w, e)-connectors are covered by the and/or gadgets  for v and w, respectively (i.e., the inward directions for both v and w), because such a configuration corresponds to the direction which illegally contributes to both v and w at the same time.On the other hand, covering all (v, e)-and (w, e)-connectors by the edge gadget at the same time (i.e., the outward directions for both v and w) corresponds to the neutral orientation [29] of the NCL edge e = vw which contributes to neither v nor w, and hence we simply do not care about such orientations.
Figure 5(a) illustrates our edge gadget for an NCL edge e = vw.Then, if all (v, e)-and (w, e)connectors are covered by the and/or gadgets for v and w, then no matching can cover all four vertices in the middle (in particular, we cannot cover the top and bottom vertices of the four).Thus, this edge gadget forbids the orientation of e which gives the inward directions for both v and w at the same time.
Figure 6(b) illustrates valid configurations of the edge gadget for e = vw together with two edges e v and e w from the and/or gadgets for v and w, respectively.Each (non-dotted) box represents a valid configuration, and two boxes are joined by an edge if their configurations are adjacent, that is, can be obtained by flipping a single cycle of length four.Furthermore, each large dotted box surrounds all configurations corresponding to the same orientation of an NCL edge e = vw.Then, the set of configurations (non-dotted boxes) in each large dotted box induces a connected component; this means that any configuration in the set can be transformed into any other without changing the orientation of the corresponding NCL edge; this condition is called the "internal connectedness" of the gadget [29].In addition, if we contract the configurations in the same large dotted box into a single vertex (and merge parallel edges into a single edge if necessary), then the resulting graph is exactly the graph depicted in Figure 6(a); this condition is called the "external adjacency" of the gadget [29].Therefore, we can conclude that our edge gadget correctly simulates the behavior of an NCL edge.
And and or gadgets.Figure 5(b) illustrates our and gadget for each NCL and vertex v, where e 1 and e 2 are two weight-1 NCL edges and e a is the weight-2 NCL edge. Figure 9(a) (in appendix) illustrates all valid orientations of the three edges incident to v, and Figure 9(b) illustrates valid configurations of the and gadget together with (images of) three edge gadgets for e 1 , e 2 , and e a .Then, as illustrated in Figure 9 (in the appendix), our and gadget satisfies both "internal connectedness" and "external adjacency", and hence it correctly simulates an NCL and vertex.
Figure 5(c) illustrates our or gadget for each NCL or vertex v, where e a , e b , and e c correspond to three NCL edges incident to v.For an NCL or vertex, we need to forbid only one type of orientations of the three NCL edges: all NCL edges e a , e b , and e c are directed outward for v at the same time, that is, all six connectors are covered by the edge gadgets for e a , e b and e c .Our or gadget forbids such a case, because otherwise we cannot cover the two (white) small vertices in the center.In addition, this or gadget satisfies both "internal connectedness" and "external adjacency", and correctly simulates an NCL or vertex.
Reduction.As illustrated in Figure 4, we replace each of NCL edges and NCL and/or vertices with its corresponding gadget; let G be the resulting graph.Notice that each of our three gadgets is of maximum configurations of the edge gadget.Note that two edges e v and e w joining connectors do not belong to the edge gadget, but to the and/or gadgets for v and w, respectively.The inside of each connector is painted (by red) if it is covered by the and/or gadget for v or w. degree three, and connectors in the edge gadget are of degree two; thus, G is of maximum degree five.In addition, each of our three gadgets is a bipartite graph such that two connectors in the same pair belong to different sides of the bipartition; therefore, G is bipartite.Furthermore, since NCL remains PSPACE-complete even if an input NCL machine is bounded bandwidth [35], the resulting graph G is also bounded bandwidth and of maximum degree five; notice that, since each gadget consists of only a constant number of edges, the bandwidth of G is also bounded.
We next construct two perfect matchings of G which correspond to two given NCL configurations C s and C t of the NCL machine.Note that there are (in general, exponentially) many perfect matchings which correspond to the same NCL configuration.However, by the construction of the three gadgets, no two distinct NCL configurations correspond to the same perfect matching of G.We arbitrarily choose two perfect matchings M s and M t of G which correspond to C s and C t , respectively.This completes the construction of our corresponding instance of perfect matching reconfiguration.The construction can be done in polynomial time.Furthermore, the following lemma gives the correctness of our reduction.

Lemma 2 ( * ).
There exists a desired sequence of NCL configurations between C s and C t if and only if there exists a reconfiguration sequence between M s and M t .
This completes the proof of Theorem 1.

Remarks.
We conclude this section by giving some remarks that can be obtained from Theorem 1.We first prove that the problem remains intractable even for split graphs.A graph is split if its vertex set can be partitioned into a clique and an independent set.Corollary 3. Perfect matching reconfiguration is PSPACE-complete for split graphs.
Proof.By Theorem 1 the problem remains PSPACE-complete for bipartite graphs.Consider the graph obtained by adding new edges so that one side of the bipartition forms a clique.The resulting graph is a split graph.These new edges can never be part of any perfect matching of the graph.Indeed, since the original graph was bipartite, there must be the same number of vertices on each side of the bipartition.In a perfect matching of the split graph, all the vertices from the independent set must be matched with vertices from the clique, and no vertex from the clique remains to be matched together.Thus, the corollary follows.
Let k be an integer.An edge-subgraph H of G is a k-factor if all the vertices of H have degree exactly k.Thus, a 1-factor is a perfect matching.Theorem 1 implies the following: Corollary 4 ( * ).Let G be a graph and H s , H t be two k-factors.Deciding if there is a sequence of flip operations transforming H s into H t is PSPACE-complete.
Finally, we show that it is PSPACE-complete to decide whether two perfect matchings are connected by a sequence of flip operations on alternating cycles of given fixed length.

Polynomial-time algorithms
In this section, we investigate the polynomial-time solvability of perfect matching reconfiguration from the viewpoint of graph classes.

Strongly orderable graphs
Interval graphs form easy instances for many NP-hard problems, and the situation is no different here.In fact, we prove that any instance on an interval graph is a yes-instance.Our argument also yields a linear-time algorithm to compute a reconfiguration sequence of a linear number of flip operations between any two perfect matchings.
For the sake of generality, we consider a wider class of graphs, called strongly orderable graphs.A graph G = (V, E) is strongly orderable if there is a strong ordering on its vertices, defined as follows: an order (v 1 , v 2 , . . ., v n ) of V such that for every i, j, k, with i < j and k < , if all of v i v k , v i v and v j v k are edges, then v j v is an edge.Note that the class of strongly orderable graphs is hereditary: every induced subgraph of a strongly orderable graph is strongly orderable.
Our proof strategy for the following theorem is to show that every perfect matching N of a strongly orderable graph G can be transformed into some particular perfect matching M of G, called the canonical perfect matching; then, any two perfect matchings N and N of G admit a reconfiguration sequence between them via M .The canonical perfect matching of a graph G with respect to an order O = (v 1 , v 2 , . . ., v n ) is a perfect matching of G (if any) greedily obtained by selecting, among the available edges, the one with endpoints of smallest indices.Note that any strongly orderable graph that admits a perfect matching, also admits a canonical perfect matching with respect to a corresponding order on the vertices, see e.g.[11].We give the following theorem in this subsection.
Theorem 6 ( * ).Let G be a strongly orderable graph.Then, there is a reconfiguration sequence of linear length between any two perfect matchings of G. Furthermore, such a reconfiguration sequence can be found in linear time if we are given a strong ordering on the vertices of G as a part of the input.
The natural question regarding Theorem 6 is whether a strong ordering can be computed efficiently.In general, Dragan [12] proved that strongly orderable graphs G = (V, E) can be recognized in O(|V | • (|V | + |E|)) time, and if so we can obtain its strong ordering in the same running time.However, when restricted to interval graphs, we can obtain a strong ordering in linear time [20].We thus have the following corollary.
Corollary 7. Let G be an interval graph.Then, there is a reconfiguration sequence of linear length between any two perfect matchings of G. Furthermore, such a reconfiguration sequence can be found in linear time.

Outerplanar graphs
In this subsection, we consider outerplanar graphs.Note that there are no-instances for outerplanar graphs, e.g., induced cycles of length more than four.Nonetheless, we give the following theorem.Theorem 8. Perfect Matching Reconfiguration can be decided in linear time for outerplanar graphs.Furthermore, if a reconfiguration sequence exists, it can be found in linear time.
Moreover, for a yes-instance, a reconfiguration sequence of linear length can be output in linear time.
We give such an algorithm as a proof of Theorem 8. Suppose we are given a simple outerplanar graph G = (V, E), and two perfect matchings M s and M t in G.We may assume that G is connected as we can consider each connected component separately.
If |V | = 2, then M s = M t = E, and hence the instance is trivially a yes-instance.Suppose that G is not 2-connected and has a cut vertex v ∈ V , that is, G − {v} consists of more than one connected component.Since |V | is even, there exists a vertex subset X ⊆ V \ {v} inducing a connected component of G − {v} such that |X| is odd.Then, any perfect matching in G contains an edge connecting v and X.This shows that we can consider two subgraphs , where E i is the edge set of G i , and output "no" otherwise.Thus, in what follows, we may assume that G is 2-connected.
Since G is outerplanar and 2-connected, all the vertices are on the outer boundary cycle.Suppose that the vertices v 1 , v 2 , . . ., v n appear in this order along the cycle.For simplicity, we denote v n+1 = v 1 , v n+2 = v 2 , and v 0 = v n .If there exists a pair of indices i, j ∈ {1, 2, . . ., n} such that |i − j| is even and v i v j ∈ E, then we can remove v i v j from G, because it cannot be contained in any perfect matching of G. Indeed, the subgraph induced by v i+1 , . . ., v j−1 is disconnected from the rest of the graph if v i , v j are deleted and contains an odd number of vertices.In particular, after this change, v i v i+2 ∈ E for any i ∈ {1, 2, . . ., n}.
We now show the following lemma.
Let k be an index such that both v k and v k+1 have degree two, and let e = v k v k+1 .We consider the following two cases separately.
Case 1: We first consider the case with v k−1 v k+2 ∈ E. In this case, we can see that e is not contained in any cycles of length four, and hence e does not appear in the transformation.Thus, if then we remove e from the instance and repeat the procedure.If v k v k+1 ∈ M s ∩ M t , then we remove v k and v k+1 together with their incident edges from the instance and repeat the procedure.
Case 2: We next consider the case with v k−1 v k+2 ∈ E. Note that if a perfect matching in G does not contain e, then it has to contain both v k−1 v k and v k+1 v k+2 , because v k and v k+1 have degree two.In this case, define Then, we solve a new smaller instance (G , M s , M t ).
In either case, we reduce the original instance to a smaller instance, which shows that our algorithm runs in polynomial time.The correctness of Case 1 is obvious.The correctness of Case 2 is guaranteed by the following lemma.
By the above arguments, we obtain a polynomial-time algorithm for Perfect Matching Reconfiguration in outerplanar graphs.A pseudocode of our algorithm is shown in Algorithm 1, which we denote PMROG (that stands for Perfect Matching Reconfiguration in Outerplanar Graphs).In the pseudocode, let PMROG(G, M s , M t ) denote the output of PMROG when the input consists of G, M s , and M t .Although this pseudocode simply outputs yes or no, it can be modified so that it actually finds a reconfiguration sequence.
To make the running time linear, we implement each step carefully and give the following lemma.
Lemma 11 ( * ).PMROG can be implemented so that it runs in linear time.
This completes the proof of Theorem 8.
Algorithm 1: PMROG Input : A simple outerplanar graph G = (V, E), and two perfect matchings M s and M t in G.
Output : "yes" if M s G M t , and "no" otherwise.
Return "yes" if PMROG(G i , M s ∩ E i , M t ∩ E i )=yes for i = 1, 2, and return "no" otherwise.
7 end 8 Suppose that the vertices v 1 , v 2 , . . ., v n appear in this order on the boundary cycle.9 while There exists an edge v i v j ∈ E such that |i − j| is even do 10 Remove the edge v i v j from G.
11 end 12 Find an edge e = v k v k+1 such that both v k and v k+1 have degree two.

Cographs
We now consider the complexity of perfect matching reconfiguration when the input graph is a cograph.Cograph are graphs without a path on four vertices as an induced subgraph.
As examples concerning reconfiguration on this class of graphs, it is known that the problems independent set reconfiguration and Steiner tree reconfiguration can be decided efficiently on cographs [3,4,27], while they are PSPACE-complete for general graphs [22,27].Theorem 1 together with the following result show that the situation is similar for perfect matching reconfiguration.
Theorem 12. perfect matching reconfiguration on cographs can be decided in polynomial time.Moreover, for a yes-instance, a reconfiguration sequence of linear length can be output in polynomial time.
We will use the following recursive characterization of cographs.
• A graph consisting of a single vertex is a cograph.
• If G and H are cographs, then their disjoint union is a cograph, that is, the graph with the vertex set V (G) ∪ V (H) and the edge set E(G) ∪ E(H) is a cograph.
• If G and H are cographs, then their complete join is a cograph, that is, the graph with the vertex set V (G) ∪ V (H) and the edge set From this characterization of cographs, we can naturally represent a cograph G by a binary tree, called a cotree of G, defined as follows: a cotree T of a cograph G is a binary tree such that each leaf of T is labeled with a single vertex in G, and each internal node of T has exactly two children and is labeled with either "union" or "join" labels.Such a cotree of a given cograph G can be constructed in linear time [7].Each node of T corresponds to a subgraph of G which is induced by all vertices corresponding to all the leaves of T that are the descendants of the node in T ; thus, the root of T corresponds to the whole graph G.The cotree of G is not necessarily unique but the following two properties do not depend on the choice of a cotree T .First, a non-trivial cograph is connected if and only if the root of T is a join-node.Furthermore, two vertices of a cograph are joined by an edge if and only if their first common ancestor in T is a join-node.
The main idea of the theorem is to decompose the graph, and apply the algorithm recursively on each of the components.In order to get a transformation of linear length using this method, we need to extend our problem to non-perfect matchings.Since the set of vertices matched by a matching does not change when performing a flip, we need to add some other operation.We will consider in this section that two matchings are adjacent if their symmetric difference is either a cycle of length four, or a path of length 3. Note that this second type of transition we added corresponds to the token sliding model: we are allowed to replace an edge of the matching by any other incident edge.We will call this operation a sliding move.We consider reconfiguration in this more general setting.

general matching reconfiguration
Input: Graph G, two matchings M s and M t of G. Question: Is there a sequence of flips and sliding moves that transforms M s into M t ?
Note that the answer to the problem is clearly no when the two matchings do not have the same size.We can also remark that when the two input matchings are perfect, sliding moves become useless (since sliding requires at least one non-matched vertex), and we get back the original problem.In particular, Theorem 12 is a special case of the following more general result.
Theorem 13. general matching reconfiguration on cographs can be decided in polynomial time.Moreover, for a yes-instance, a reconfiguration sequence of linear length can be output in polynomial time.
We start by considering certain base cases for which a transformation of linear length always exists and can be computed efficiently.Let M s and M t be two matchings of a cograph G, and let T be a cotree of G.For the purpose of transforming M s to M t , we may assume that G is connected, so the root of T is a join-node (otherwise we can simply apply the algorithm to each connected component of G).We will call root partition the partition of the vertices of G into A and B corresponding to all the leaves in respectively the left and right subtrees of the root of T .All along this section, unless otherwise specified, A and B will denote the root partition of G, and k denotes the size of the matchings we are considering, i.e., k = |M s | = |M t |.Note that A is complete to B, because the root of T is a join-node.Without loss of generality we may assume that |A| ≥ |B|.For a vertex subset X of G and an edge e of G, we say that G[X] contains e if both endpoints of e are in X.
Given a connected cograph G with root partition A, B, we will consider the two following conditions: (C1) There exists a matching M of G of size k such that G[B] contains an edge of M .
(C2) There exists a matching M of G of size k such that at least one vertex of B is not matched in M .
When one of these two conditions holds, then we will be able to show directly that the reconfiguration graph on matchings of size k is connected, and has linear diameter.On the other hand, if none of the two condition holds, we will apply induction on G[A] in order to conclude.The case where condition (C1) holds is treated in Lemma 15 and condition (C2) is handled in Lemma 16.The case where none of the two properties hold is treated in Lemma 17.
Note that it is possible to check in polynomial time whether one of the two conditions holds since computing a maximum matching in a graph can be done in polynomial time.Indeed, a simple algorithm to check condition (C1) consists in trying all possible edges in G[B], removing both endpoints from the graph, and search for a matching of size k − 1 in the remaining graph.Similarly, for condition (C2), we can try to remove every possible vertex from B, and search for a matching of size k in the remaining graph.
Remark that the connected components of M s M t can be of three types: single edges, paths of length at least 3, and even cycles.If M s and M t are perfect matchings, then only even cycles can occur in the symmetric difference.We start with the following observation that finding a reconfiguration sequence is easy if the symmetric difference contains no cycle.Lemma 14.Let G be a cograph, and M s and M t be two matchings of size k such that M s M t contains no cycle.Then there is a transformation of length at most 2|M s M t | from M s to M t .
Proof.The result is proved by induction on the size of the symmetric difference M s M t .If the symmetric difference is zero, then M s = M t and the result trivially holds.Otherwise, we only need to show that we can reduce the symmetric difference by 2 in at most 4 steps.First assume that M s M t contains a path of length t ≥ 3. Let x 1 , . . .x t be the vertices of this path, and assume without loss of generality that x 1 x 2 is an edge in M s and x 2 x 3 an edge in M t .By definition, x 1 is not matched in M t .Consequently, starting from M t we can slide the edge x 2 x 3 to x 1 x 2 , and reduce the symmetric difference by 2 in one step.Now assume that the symmetric difference does not contain any path of length at least 3. Since by assumption it does not contain any cycles either, then it must be a disjoint union of edges.Let e s = u s v s be an edge in M s \ M t , and e t = u t v t an edge in M t \ M s (none of these sets is empty since M t and M s have the same size).First assume that there is an edge incident to both e s and e t .Without loss of generality, we can assume that this edge is u s u t .In this case, we can simply slide u s v s to u s u t and then to u t v t , giving a transformation of length at most 2. Otherwise, since G is a cograph, the two edges must be at distance at most 2. Hence, we can assume that there is a vertex w adjacent to both u s and u t .We consider the two following cases: • w is not matched in M s .In this case, starting from M s , we can simply slide u s v s to u s w and then to wu t and finally to u t v t ; • w is matched to w in M s .In this case, we start by sliding ww to wu t and then to u t v t .Then, we can slide u s v s to u s w and finally ww .
In any case, we can reduce the symmetric difference by 2 in at most 4 steps, which proves the result.
The following lemma provides a way to construct a transformation sequence of linear length when condition (C1) holds.Note that the proof is constructive and can be easily turned into a polynomial time algorithm computing this sequence.
Lemma 15.Let G be a connected cograph with n vertices, and k ≥ 0 such that condition (C1) holds.Then, there is a reconfiguration sequence of length O(n) between any two matchings of size k in G.
Proof.Assume that G has a perfect matching M such that G[B] contains at least on edge M , and let e be such an edge.To prove the lemma, we only need to show that for any matching M s of size k, there is a transformation sequence of linear length from M s to M .
We first claim the following: we can assume without loss of generality that e is the only edge of M contained in B. To see this, assume that there is another edge e = ab with a, b ∈ B. Since |A| ≥ |B|, either M also contain an edge e = cd with both endpoints in A, or there is at least one vertex x in A not matched in M .In the first case, the edge e can be removed from the matching by flipping ab and cd with ac and bd.In the second case, we can slide e = ab into ax.
We now prove that for every matching M s of G of size k, there is a reconfiguration sequence of length O(|M M s |) from M to M s .We start by proving the following claim.See Figure 7 for an illustration of some of the cases.
Claim 1.After a transformation of at most O(|M M s |) steps in M and M s , we can assume 1 that M still contains an edge in G[B] and M and M s also satisfy the following statements: 1. no edge of M s is contained in B.

M M s contains no cycle on A.
3. M M s contains no three edges uv, vw, wx, such that u ∈ B and v, w, x ∈ A.
4. M M s contains no three edges uv, vw, wx, each between A and B. 1 The resulting matchings are still denoted by M and Ms for simplicity.Proof of Claim 1.We prove all the points in the increasing order.Let e be the edge of M contained in G[B], and let x e and y e be its two endpoints.
Assumption 1.Let ab be an edge of M s contained in B. Since |A| ≥ |B|, there is either an edge cd of M s with both endpoints in A or a vertex x in A not matched by M s .In the first case, starting from M s , we flip ab and cd with bc and ad.In the second case, we make a sliding move from ab to ax.Since every edge in M s contained in B is in the symmetric difference M s M (except if ab = e), this operation will be repeated at most |M s M | + 1 times.Each time, the symmetric difference increases by at most 1 (by 2 in the case e = ab).
The other edges of M are not modified.Let u 1 , u 2 , . . ., u 2 be the vertices of C, all in A. We assume without loss of generality that u 2 u 3 , u 4 u 5 , . . ., u 2 u 1 ∈ M .We first flip x e y e and u 2 u 1 to create x e u 1 and y e u 2 .Then we flip x e u 1 and u 2 u 3 for u 1 u 2 and x e u 3 .We proceed with u 4 u 5 and uu 3 and so on (reducing the length of the cycle in the symmetric difference), until x e u 2 −1 and y e u 2 remains.After flipping these two edges for x e y e and u 2 −1 u 2 , the resulting matching still contains the edge x e y e with both endpoints in B and we have reconfigured M ∩ E(C) to M s ∩ E(C), i.e., the size of the symmetric difference has decreased.The other edges in M were not modified; in particular Assumption 1 still holds.Note that number of flips performed in this sequence is at most |E(C)| and the symmetric difference decreased by |E(C)|.Assumption 3. We can assume without loss of generality that uv and wx are in M and vw is in M s .Then, we can flip uv and wx for vw and ux and reduce the size of the symmetric difference by 2.Moreover, Assumption 1 still holds in the resulting perfect matching.Assumption 4. We can assume without loss of generality that uv and wx are in M and vw is in M s .Then, in M we can flip uv and wx for vw and ux and reduce the size of the symmetric difference.Note moreover that Assumption 1 still holds in the resulting perfect matching.Assumption 5.By assumption, uv, wx and yz are edges of M .Note that x e and y e are distinct from {u, v, w, x, y, z} since u and x are incident to edges of M between A and B (and the other vertices are in A).We will perform a sequence of flips decreasing the symmetric difference, and preserving e at the end of the transformation (see Figure 8).Now, in the matching M , flip x e y e and yz for x e y and y e z.Then flip xw and x e y for xy and x e w.Note that at this point, the size of the symmetric difference with M s decreased by one.Then we flip y e z and uv for y e v and uz.Finally, we flip x e w and y e v for x e y e and vw.After applying Claim 1, let us still denote by M and M s the resulting matchings.The number of steps needed to reach this point is at most O(|M M s |).Recall that e is the edge of M contained in B. We will show that the only cycle that can be in the symmetric difference is a cycle of length 4 containing the edge e. Assume by contradiction that this is not the case, and let C be a cycle in the symmetric difference M M s .
Suppose first that C does not contain e.By Assumption 2, there exists a vertex u ∈ C ∩ B. Let v, w and x the vertices following u on the cycle C and such that uv ∈ M .We must also have wx ∈ M and vw ∈ M s .Since C does not contain e, we know that v ∈ A. By Assumptions 3 and 4, we have w ∈ A, and x ∈ B. Since both u and x are on the side B, and using Assumption 1, we have xu ∈ C. In particular |C| > 4, and since C has even length this implies |C| ≥ 6.Let y and z be the two vertices following x on the cycle C.By Assumption 1, and since wx ∈ M , we have y ∈ A. Moreover, by Assumption 4, we have z ∈ A. However, in this case the configuration of the vertices u, v, w, x, y, z contradicts Assumption 5.
Consequently, there is only one cycle C in the symmetric difference, and C must contain e. Assume by contradiction that |C| ≥ 6.Let x 1 , x 2 , x 3 , u, v, w be consecutive vertices on the cycle C such that x 1 is incident to e, and x 2 is not.Then x 1 x 2 ∈ M s , which implies that x 2 ∈ A. Using the Assumptions 1, 3, and 4, we also have x 3 , v, w ∈ A, and u ∈ B. In particular, w is not incident to e. Let x 0 be the other endpoint of e.Since the cycle C must have even length, w and x 0 are not consecutive in C. Let x be the vertex consecutive to w in C.Then, by Assumption 3 we must have x ∈ B. Since M s does not contain any edge in B, this implies that x and x 0 are not consecutive in C. Let y be the vertex consecutive to x in C, and z consecutive to y.Since C has even length, we known that z = x 0 .By Assumption 1 we must have y ∈ A, and by Assumption 4, we have z ∈ A. However, in this case the configuration of the vertices u, v, w, x, y, z contradicts Assumption 5.
Hence, the only possible cycle in the symmetric difference is a cycle of length 4 containing e.After flipping this cycle, the symmetric difference contains only paths and isolated edges.By Lemma 14, we can finish transforming M s into M using an additional O(M ∆M s ) steps.
We now handle the case where condition (C2) holds.As for the previous case, when this condition holds a transformation sequence can be easily found between any two matchings.
Lemma 16.Let G be a cograph, and k ≥ 0 such that condition (C2) holds.Then, there is a transformation sequence of length O(n) between any two matchings of size k.
Proof.Without loss of generality, we can assume that condition (C1) does not hold since otherwise we can conclude directly using Lemma 15.Consequently, no matching of size k of G uses any of the edges in G[B].Hence, these edges can be removed without changing in any way the reconfiguration graph, and we can assume that G[B] is an independent set.
Let M be a matching of G of size k such that there exists a vertex v in B not matched in M .Let M s be any matching of G of size k.We will show that there is a transformation from M to M s of length at most O(|M M s |).If the symmetric difference is zero, then the result is trivial.If the symmetric difference contains no cycle, then the result follows from Lemma 14.
Let C be a cycle in the symmetric difference M M s .Since G[B] is an independent set, C must contain at least one vertex in A. Let x 1 , . . ., x 2t be the vertices in C, with x 1 ∈ A, and x 1 x 2 ∈ M .We consider the following transformation starting from the matching M : This operation progressively reconfigure M such that M and M s agree on C. Note that the edges of M outside of C are not modified by the transformation.Moreover, if M 2 is the matching obtained after the transformation, then the symmetric difference with M s has decreased by |C| = 2t.Additionally, the vertex v is still not matched in M 2 .Since the number of steps performed by this transformation is t + 1 ≤ |C|, the result follows by applying induction with M 2 and M s .
In case none of the two conditions (C1) and (C2) holds, the following lemma states that we only need to consider what happens on the subgraph induced by A. Given a matching M , we will note M A the matching of G[A] induced by the edges of M .Remark that even if M is a perfect matching of G, M A might not be a perfect matching of G[A] since some of the vertices in A can be matched to vertices in B by M .This is the main reason we had to extend the problem to non-perfect matchings.We have the following.
Lemma 17.Let G be a connected cograph with root partition A, B with |A| ≥ |B|, and k ≥ 0 such that conditions (C1) and (C2) do not hold.Let M s and M t be two matchings of G of size k.Then: • there is a transformation sequence from M s to M t in G if and only if there is a transformation sequence from then there is a transformation from M s to M t of length at most t + O(|B|).
Proof.Let M s and M t be two matchings of size k of G. First assume that there is a transformation sequence S from We will build a transformation sequence from M s to M t in G. First, observe that any flip in S on the subgraph G[A] is also a valid flip on the whole graph G.For sliding moves, there are two possibilities.Let u, v, w be three vertices in A, and consider the sliding move in G[A] which replaces uv by vw.Either w is not matched to a vertex in B, and in this case this move is also a valid sliding move on the whole graph.Or w is matched to a vertex x ∈ B. In this case, consider the operation of flipping uv and wx for vw and xu.Then this transformation acts exactly as the original sliding move on A.
Hence, by eventually replacing some of the sliding moves by flips as explained above, we obtain a transformation sequence S which transforms M s into a matching M such that M A and M A t are equal.To finalize the transformation, from M to M t , we only need the two following observation.
• We can make M and M t agree on the vertices a ∈ A which are matched to vertices in B. Indeed, if there is a vertex a ∈ A which is matched to b ∈ B in M but not in M t , then there must be a vertex a ∈ A which is matched in M t but not in M (since |M | = |M t |).Then, we can simply slide ab to a b.
• Let A the set of vertices in A which are matched to vertices in B in M s (and by the point above, also in M t ), and G the complete bipartite graph between A and B. Note that G is a subgraph of G.The edges in M s (and M t ) in G form a perfect matching of G .These perfect matchings can be seen as a permutation on the vertices of B. A flip in this graph consists in applying a transposition to the permutation.Hence, transforming M into M t is equivalent to transforming one permutation into an other using transposition.It is well known that this is always possible using at most |B| transpositions.
Hence, if there is a transformation of length t from M A s to M A t , then there is a transformation of length t + O(|B|) from M s to M t .
Conversely, assume that there is a transformation sequence from M s to M t .We want to show that there is a transformation sequence from M A s to M A t .For this, we only need to show that if there is a one step transformation between M s and M t , there is a one step transformation between M A s and M A t .We consider the symmetric difference D = M s ∆M t .If D contains no edge in G[A], then M A s and M A t are equal, and there is nothing to prove.Similarly, if D ⊂ G[A], then M A s and M A t are adjacent by definition.Thus, we can assume in the following that none of these two cases happen.
If D is a path of length 3 (i.e., the transformation is a sliding move).By the remarks above, we can assume that D contains one edge in G[A], but not the other.Let u, v, w be the vertices of D, with u, v ∈ A and w ∈ B. Then w is not matched in one of M s or M t .This contradicts the assumption that G does not satisfy condition (C2).
If D is a cycle of length 4.There are two possible sub-cases: • Hence, in any case, if there is a transformation from M s to M t , there is also a transformation from M A s to M A t .This shows the reverse implication and ends the proof of the lemma.
Proof of Theorem 13.Given a cograph G and two matchings M s and M t of G, the algorithm proceeds as follows: 1 3.If G satisfies one of the conditions (C1) and (C2), output yes, and produce a transformation sequence using either Lemma 15 or Lemma 16.
4. If G does not satisfy any of these conditions, call recursively the algorithm on A, and decide the instance (and produce a transformation if it exists) using Lemma 17.
Let us show that this algorithm is correct, runs in polynomial time and produces a transformation sequence of linear length.
Correctness.Whenever the algorithm answers yes, it also provides a certificate (i.e., a transformation sequence).Hence, the only case where the algorithm might be incorrect is when it answers no.Let us show by induction on G that if the algorithm returns no on a cograph G given two matchings M s and M t as input, then no transformation exists between the two matchings.If the algorithm returns no in step 1, then there is clearly no transformation.If one of the recursive calls returns no in step 2, then there is trivially no transformation either.Finally, if one of the recursive calls returns no in step 4, then there is also no transformation sequence by Lemma 17.
Running-time.At each recursive call, the algorithm only performs a polynomial number of steps.Indeed, checking whether G is connected, and comparing the size of M s and M t can be done in polynomial time.Additionally, computing cotree of a cograph can be done in polynomial time, and as we mentioned before, the two conditions (C1) and (C2) can be verified in polynomial time.Finally, all the recursive calls are made on vertex disjoint subgraphs.Consequently, it follows immediately that the algorithm runs in polynomial time.
Length of transformation.Let G be a cograph, and M s and M t two matchings of G such that there is a transformation from M s to M t .Let us show by induction on G that the algorithm produces a transformation of length at most Cn for some constant C.
If the algorithm returns at step 2, then by induction it produces a transformation of length at most Cn i on each component G i of G, with n i = |G i |.By combining the transformations on each component, we obtain a transformation for the whole graph of length at most C( n i ) = Cn.
If the algorithm returns yes during step 3, then the induction step directly follows from Lemmas 15 and 16, provided C is chosen large enough.
Finally, if the algorithm outputs yes at step 4, then using the induction hypothesis on A, it produces a transformation of length at most . By Lemma 17, the total sequence produced by the algorithm has length at most C|A| + C |B| ≤ Cn where C is the constant in the big-Oh notation of Lemma 17 and assuming C ≥ C .

Conclusion
We introduced the perfect matching reconfiguration problem and analyzed its complexity from the viewpoint of graph classes.We showed that this problem is PSPACE-complete on split graphs and bipartite graphs of bounded bandwidth and maximum degree five.Furthermore, we gave polynomial-time algorithms for strongly orderable graphs, outerplanar graphs, and cographs.Each of the algorithm outputs a reconfiguration sequence of linear length in polynomial time.
A natural open question is on which graph classes a shortest reconfiguration sequence can be found in polynomial time.Furthermore, it would be interesting to investigate if the flip operation can be used in order to sample perfect matchings uniformly.
A A figure and Proofs omitted from Section 2 A.1 Proof of Lemma 2 Proof.We first prove the only-if direction.Suppose that there exists a desired sequence of NCL configurations between C s and C t , and consider any two adjacent NCL configurations C i−1 and C i in the sequence.Then, only one NCL edge vw changes its orientation between C i−1 and C i .Notice that, since both C i−1 and C i are valid NCL configurations, the NCL and/or vertices v and w have enough in-coming arcs even without vw.Therefore, we can simulate this reversal by the reconfiguration sequence of perfect matchings in Figure 6(b) which passes through the neutral orientation of vw as illustrated in Figure 6(a).Recall that both and and or gadgets are internally connected, and preserve the external adjacency.Therefore, any reversal of an NCL edge can be simulated by a reconfiguration sequence of perfect matchings of G, and hence there exists a reconfiguration sequence between M s and M t .We now prove the if direction.It is important to notice that any cycle of length four in G belongs to exactly one gadget and the edge joining two connectors; recall the edges e v and e w in Figure 6(b).Therefore, even in a whole graph G, a flip of edges along a cycle of length four can happen only inside of each gadget (and edges joining two connectors).Suppose that there exists a reconfiguration sequence M 0 , M 1 , . . ., M from M 0 = M s to M = M t .Notice that, by the construction of gadgets, any perfect matching of G corresponds to a valid NCL configuration such that some NCL edges may take the neutral orientation.In addition, M s and M t correspond to valid NCL configurations without any neutral orientation.Pick the first index i in the reconfiguration sequence M 0 , M 1 , . . ., M which corresponds to changing the direction of an NCL edge vw to the neutral orientation.Then, since the neutral orientation contributes to neither v nor w, we can simply ignore the change of the NCL edge vw and keep the direction of vw as the same as the previous direction.By repeating this process and deleting redundant orientations if needed, we can obtain a sequence of valid adjacent orientations between C s and C t such that no NCL edge takes the neutral orientation.

A.2 Proof of Corollary 4
Proof.We have a simple polynomial-time reduction from Perfect Matching Reconfiguration.Let G, M s , M t be an instance of Perfect Matching Reconfiguration.We create a new graph G as follows.First G contains a copy of G, and then we add to it (k − 1)|V (G)| new vertices x j i with i ≤ n and j ≤ k − 1.We create the edge between x j i and x i for every i, j and create the edges between x j i and x j i for every i and every j = j .Note that every vertex x j i has degree exactly k.Now consider the following k-factors H s and H t .H s contains all the edges incident to x j i for every i, j and the edges of the perfect matching M s .H t contains all the edges incident to x j i for every i, j and the edges of the perfect matching M t .Since all the edges incident to x j i have to be in every k-factor, there exists a sequence of flip operations transforming H s into H t if and only if there is a reconfiguration sequence transforming M s into M t .

A.3 Proof Corollary 5 (sketch)
Proof.Consider the gadgets shown in Figure 5.We replace each orange edge of each gadget by a path on k − 3 edges.Observe that this does not alter the number of perfect matchings on each gadget.Using these gadgets, we construct from an NCL instance a graph and two perfect matchings as in the proof of Theorem 1.
It is readily verified that any two perfect matchings on each gadget are connected by a sequence of flip operations on cycles of length k.Note that by the selection of the orange edges, each alternating cycle of length k in the graph that passes through an edge gadget contains an orange edge.Therefore, no alternating cycle of length k involves more than one gadget.The PSPACE-completeness of k-Perfect Matching Reconfiguration follows from the proof of Theorem 1 and the observation that each flip involves precisely an orange edge.
B A Proof omitted from Section 3.1 Proof of Theorem 6. Suppose we are given a strongly orderable graph G together with a corresponding ordering (v 1 , v 2 , . . ., v n ) of its vertices.We will argue that every perfect matching of G can be reconfigured in a linear number of steps into any other.We proceed by induction on the number of vertices.We may assume that G is connected and non-empty.In particular, we have n ≥ 2. Let M be the canonical perfect matching of G with respect to (v 1 , v 2 , . . ., v n ).Let N be an arbitrary perfect matching of G.There is an edge v 1 v p in M , and an edge v 1 v q in N .If p = q, we delete both vertices from the graph and apply induction.Assume now that p = q.By choice of a canonical perfect matching, p < q.There is an edge v p v r in N .From the definition of a strong ordering (with i = 1, k = p, = q and j = r), it follows that the edge v q v r belongs to the graph.Therefore, from N we can swap the two edges v 1 v q and v p v r for v 1 v p and v q v r .We can then delete the two vertices v 1 and v q and apply induction.

Figure 2 :
Figure 2: Our results, where each arrow represents the inclusion relationship between graph classes: A → B represents that the graph class B is properly included in the graph class A.

Figure 3 :Figure 4 :
Figure 3: (a) A configuration of an NCL machine, (b) an NCL and vertex u, and (c) an NCL or vertex v.

Figure 5 :
Figure5: Illustrations of the three gadgets.In the and/or gadget, the three light blue parts represent the edge gadgets corresponding to the edges incident to the NCL vertex; e 1 and e 2 in the and gadget correspond to weight-1 edges.The orange edges may be subdivided in order to make the gadgets work for swaps on longer cycles.

Figure 6 :
Figure6: (a) A reversal of the orientation of an NCL edge vw via its neutral orientation, and (b) all configurations of the edge gadget.Note that two edges e v and e w joining connectors do not belong to the edge gadget, but to the and/or gadgets for v and w, respectively.The inside of each connector is painted (by red) if it is covered by the and/or gadget for v or w.

Figure 7 :
Figure 7: Representation of some of the cases of Claim 1.Note that all edges between A and B are present in the graph, but were removed for clarity.The edges drawn are the edges in the symmetric difference M M s .(a) corresponds to Assumption 3, (b) is Assumption 4, and (c) is Assumption 5.For the last case, the red wavy edges are edges in M , the other ones are edges in M s .

Figure 8 :
Figure 8: Reconfiguration sequence to reduce the symmetric difference in the case of Assumption 5.All the edges between A and B are present in the graph but were removed for clarity.The edges drawn are the edges in M .At each step, the two edges in red are the ones which are flipped to obtain the next transition.
D contains exactly on edge in G[A].In this case D must also contain one edge in G[B], and this implies that one of G s or G t contains an edge in G[B], a contradiction of the assumption that G does not satisfy the condition (C1).• D contains exactly two edges in G[A].These two edges must be incident since otherwise D ⊂ G[A].Then, this means that M A s ∆M A t is a path of length 3 and the two matchings are adjacent in the reconfiguration graph.If D has three edges in G[A], then we must have D ⊆ G[A], and this case was already handled above.
recursively the algorithm on each connected component.Otherwise let A, B be the root partition of G, with |A| ≥ |B|.

2 Figure 9 :
Figure 9: (a) All valid orientations of three edges incident to an NCL and vertex v, and (b) all configurations of the and gadget together with three incident edge gadgets, where the inside of each connector is painted (by red) if it is matched by the and gadget.