Friends and Strangers Walking on Graphs

Given graphs $X$ and $Y$ with vertex sets $V(X)$ and $V(Y)$ of the same cardinality, we define a graph $\mathsf{FS}(X,Y)$ whose vertex set consists of all bijections $\sigma:V(X)\to V(Y)$, where two bijections $\sigma$ and $\sigma'$ are adjacent if they agree everywhere except for two adjacent vertices $a,b \in V(X)$ such that $\sigma(a)$ and $\sigma(b)$ are adjacent in $Y$. This setup, which has a natural interpretation in terms of friends and strangers walking on graphs, provides a common generalization of Cayley graphs of symmetric groups generated by transpositions, the famous $15$-puzzle, generalizations of the $15$-puzzle as studied by Wilson, and work of Stanley related to flag $h$-vectors. We derive several general results about the graphs $\mathsf{FS}(X,Y)$ before focusing our attention on some specific choices of $X$. When $X$ is a path graph, we show that the connected components of $\mathsf{FS}(X,Y)$ correspond to the acyclic orientations of the complement of $Y$. When $X$ is a cycle, we obtain a full description of the connected components of $\mathsf{FS}(X,Y)$ in terms of toric acyclic orientations of the complement of $Y$. We then derive various necessary and/or sufficient conditions on the graphs $X$ and $Y$ that guarantee the connectedness of $\mathsf{FS}(X,Y)$. Finally, we raise several promising further questions.


Introduction
Let X be a simple graph with n vertices.Imagine that n different people, any two of whom are either friends or strangers, are standing so that one person is at each vertex of X.At each point in time, two friends standing at adjacent vertices of X may swap places by simultaneously crossing the edge that connects their respective vertices; two strangers may not swap places in this way.Our goal is to understand which configurations of people can be reached from other configurations when we allow the people to swap places repeatedly in this manner.The resolution of this problem certainly depends on the graph X, as well as on the information about which people are friends with each other; this further information can be encoded in a graph Y whose vertex set is the set of people and where edges indicate friendship.
To formalize and refine this problem, we define the friends-and-strangers graph FS(X, Y ) whose vertex set is the set of bijections σ : V (X) → V (Y ).Two bijections σ, σ : V (X) → V (Y ) are adjacent in FS(X, Y ) if and only if we can find an edge {a, b} in X such that: • {σ(a), σ(b)} is an edge in Y ; • σ(a) = σ (b) and σ(b) = σ (a); • σ(c) = σ (c) for all c ∈ V (X) \ {a, b}.When this is the case, we refer to the operation that transforms σ into σ as an (X, Y )-friendly swap across {a, b}.Performing an (X, Y )-friendly swap corresponds to allowing two friends to swap places in the graph X.Notice that the isomorphism type of FS(X, Y ) depends only on the isomorphism types of X and Y .Since we will usually be concerned only with the graph-theoretic structure of FS(X, Y ) (such as the number and sizes of connected components), we will often specify the graphs X and Y only up to isomorphism.
It is sometimes convenient to assume that V (X) and V (Y ) are both the set [n] := {1, . . ., n}.In this case, the vertices of FS(X, Y ) are the elements of the symmetric group S n , which consists of all permutations of the numbers 1, . . ., n.For i, j ∈ [n], let (i j) be the transposition in S n that swaps the numbers i and j.If σ ∈ S n is such that {i, j} is an edge in X and {σ(i), σ(j)} is an edge in Y , then we can perform an (X, Y )-friendly swap across {i, j} to change σ into the permutation σ • (i j).If we write the permutation σ in one-line notation as σ = σ(1) • • • σ(n), then an (X, Y )-friendly swap transposes two entries of the permutation such that the positions of the entries are adjacent in X and the entries themselves are adjacent in Y .
Example 1.2.If X = and Y = , then FS(X, Y ) is the graph shown (without vertex labels) in Figure 1.Notice that FS(X, Y ) has 5 pairwise isomorphic connected components, each of which exhibits a highly symmetric structure; our results in Sections 2 and 4 will explain both of these properties.In this paper, we concern ourselves mainly with the problem of understanding the structure of FS(X, Y ) for various graphs X and Y .This is a very general setup, of which some previouslyconsidered problems are special cases.One motivation for phrasing the problem in terms of permutations is to encompass previous work on multiplication by restricted transpositions.To give some examples, we let K n denote the complete graph on the vertex set [n] and let Path n be the path graph on the vertex set [n] with edges {i, i + 1} for all i ∈ [n − 1].The graph FS(K n , K n ) is the Cayley graph of S n generated by all transpositions.The graph FS(K n , Path n ) is the weak Bruhat graph of S n , which is also the 1-skeleton of the standard (n − 1)-dimensional permutohedron.More generally, if Y is connected, then FS(K n , Y ) is the Cayley graph of S n generated by the transpositions corresponding to the edges of Y .Letting Y denote the complement of Y , we find that FS(Path n , Y ) is the same as the update graph introduced by Barrett and Reidys in their work [2] on sequential dynamical systems.Stanley's article [22] focuses on the connected components of FS(Path n , Path n ).
Another special case of our setup has previously been phrased in terms of sliding tiles on graphs.Analyzing the famous 15-puzzle is equivalent to analyzing the connected components of FS(Grid 4×4 , Star 16 ), where Grid 4×4 is a 4×4 grid graph and Star n denotes the star graph with vertex set [n] and edges {i, n} for all i ∈ [n − 1].The purpose of Wilson's article [23] is to generalize the 15-puzzle by computing the number of connected components of FS(X, Star n ) for arbitrary graphs X. Conway, Elkies, and Martin [9] investigated a "projective" variant of the 15-puzzle problem and its connections to the Mathieu groups.More recently, Yang [24] considered a similar problem in this spirit.See also [4,13].
A simple but useful observation is that for any n-vertex simple graphs X and Y , the graph FS(X, Y ) is isomorphic to FS(Y, X).Indeed, the map σ → σ −1 provides the necessary isomorphism.For example, Section 3 concerns the graphs of the form FS(Path n , Y ); by taking inverses of permutations, one could easily rewrite the results in that section in terms of graphs of the form FS(X, Path n ).
In Section 2, we prove several general properties of the graphs FS(X, Y ).For example, we show how the decomposition of X into connected components translates into a decomposition of FS(X, Y ) into a disjoint union of Cartesian products.We prove that FS(X, Y ) is disconnected whenever X and Y both have cut vertices, and we provide a lower bound for the number of connected components.We also show that FS(X, Y ) is disconnected whenever X and Y are both bipartite.
In Section 3, we investigate FS(Path n , Y ) for arbitrary graphs Y .This generalizes Stanley's work in [22].We will see that the connected components correspond bijectively to the acyclic orientations of the complement of Y and that the vertices in each connected component are the linear extensions of a poset naturally associated to the corresponding acyclic orientation.This result is closely related to a known result concerning Coxeter elements in Coxeter systems.We will also see that each connected component of FS(Path n , Y ) is isomorphic to the Hasse diagram of a convex subset of the weak order on S n .
The characterization of the connected components of FS(Path n , Y ) is also roughly equivalent to a simple yet useful fact about linear extensions of posets, which we state below as Proposition 1.3.Let P = ([n], ≤ P ) be a poset with underlying set [n].A linear extension of P is a permutation σ ∈ S n such that σ −1 (a) ≤ σ −1 (b) whenever a ≤ P b.Let L(P ) denote the set of linear extensions of P .For each i ∈ [n − 1], define the toggle operator t i : L(P ) → L(P ) by It is important to note that for each i ∈ [n] and σ ∈ L(P ), the permutation t i (σ) is in L(P ).Furthermore, the map t i : L(P ) → L(P ) is an involution.
Proposition 1.3.Let P = ([n], ≤ P ) be a poset.If σ, σ ∈ L(P ), then there exists a sequence i 1 , . . ., i of elements of Proposition 1.3 is not too difficult to prove by induction on n, but it is of fundamental importance in many different places in combinatorics.It is usually used to show that a definition involving a choice of a linear extension is well-defined in the sense that it does not depend on the choice of the linear extension.For example, it has been employed in order to understand Coxeter elements in Coxeter systems [10,Theorem 1.15], Jucys-Murphy elements and Gelfand-Tsetlin bases [17,Proposition 8.18], ⊕-diagrams and L-diagrams [15, Proposition 2.6], and the hook-length formula [19,Lemma 3].
In Section 4, we completely describe the connected components of FS(Cycle n , Y ), where Cycle n is the cycle graph with vertex set [n] and edge set {{i, i + 1} : 1 ≤ i ≤ n − 1} ∪ {{n, 1}}.This description is much more involved than (yet very similar in flavor to) the description of the connected components of FS(Path n , Y ); it makes use of toric acyclic orientations, which have appeared in many contexts and were formalized in [10].The connected components of FS(Cycle n , Y ) can be understood via a new equivalence relation on acyclic orientations of the complement of Y , which we call doubleflip equivalence.This new notion could be of independent interest; it turns out that our analysis of the graphs FS(Cycle n , Y ) not only requires an understanding of double-flip equivalence classes but also reciprocally yields interesting structural information about the double-flip equivalence classes.We will see that each toric acyclic orientation of the complement of Y corresponds to ν isomorphic connected components of FS(Cycle n , Y ), where ν is the greatest common divisor of the sizes of the connected components of the complement of Y .One corollary is that FS(Cycle n , Y ) is connected if and only if the complement of Y is a forest whose trees have (not necessarily pairwise) coprime sizes.Since Proposition 1.3 is equivalent to our characterization of the connected components of FS(Path n , Y ), one can view our characterization of the connected components of FS(Cycle n , Y ) as providing a toric analogue of Proposition 1.3.
Section 5 concerns a sufficient condition for FS(X, Y ) to be connected.We phrase this result in terms of hereditary classes and Hamiltonian paths.More precisely, we define a prolongation of a graph X to be a graph X with a Hamiltonian path that itself contains a Hamiltonian path of a subgraph X # of X such that X # is isomorphic to X.We will prove that if X has a Hamiltonian path and FS(X, Y ) is connected whenever Y belongs to a hereditary class H, then FS( X, Y ) is connected whenever X is a prolongation of X and Y is in H.As a corollary, we produce several infinite classes of pairs (X, Y ) such that FS(X, Y ) is connected.
In Section 6, we turn our attention to necessary conditions for FS(X, Y ) to be connected.We will prove that if X has an induced subgraph isomorphic to Path d such that the internal vertices of the path all have degree 2 in X and FS(X, Y ) is connected, then the minimum degree of Y is at least d + 1.By combining this with the main result from Section 5, we will see that FS(Lollipop n−3,3 , Y ) is connected if and only if Y has minimum degree at least n − 2, where Lollipop n−3,3 is a lollipop graph (which is obtained by identifying an endpoint of a path on n − 2 vertices with a vertex in the triangle K 3 ).We will also see that FS(Lollipop n−3,3 , Y ) is connected if and only if FS(D n , Y ) is connected, where D n is the Dynkin diagram of type D n (which is obtained from Path n−1 by adding the vertex n and the edge {n − 2, n}).
We end the paper with numerous suggestions for future work in Section 7. In particular, we define a generalization of friends-and-strangers graphs in which symmetric groups are replaced by arbitrary groups; this construction is given by the intersection of right and left Cayley graphs of the group.Let us also remark that it is very natural to ask probabilistic and extremal questions concerning friends-and-strangers graphs; along with Noga Alon, we address such questions in the article [1].
1.1.Notation and terminology.Throughout this article, we assume all graphs are simple.Let V (G) and E(G) denote the vertex set and edge set of a graph G.Some specific graphs with vertex set [n] that will play a large role for us are: and whose edge set is the disjoint union E(G 1 ) E(G 2 ).This definition readily extends to the disjoint union of a family of graphs G i for i in an index set I; we denote the resulting disjoint union by i∈I G i .The Cartesian product of the graphs G 1 , . . ., G r , written where the vertices (a 1 , . . ., a r ) and (b 1 , . . ., b r ) are adjacent if and only if there is an index Some additional terminology concerning a graph G is as follows: If such an isomorphism exists, we say G and • We say G is bipartite if there exists a partition of V (G) into two nonempty sets A and B such that every edge in E(G) has one endpoint in A and one endpoint in B; in this case, the pair {A, B} is called a bipartition of G.
v has more connected components than G.We say G is separable if it is disconnected or has a cut vertex.We say G is biconnected if it has at least 2 vertices and is not separable.

General Properties of the Graphs FS(X, Y )
To initiate the investigation of the graphs FS(X, Y ), we list some general properties that hold when X and Y are taken from broad classes of graphs.Some of these properties are nicely illustrated by Wilson's results for the graphs of the form FS(Star n , Y ), so we will recall those results in this section as well.Several of the general results we prove here will be useful when we consider more specific families of graphs in subsequent sections.
Taking X = Y = K n in this proposition shows that FS(X, Y ) is isomorphic to a subgraph of FS(K n , K n ), the Cayley graph of S n generated by the set of all transpositions in S n .
Proof.We may assume that and that X and Y are subgraphs of X and Y , respectively.Let {σ, σ } be an edge in FS(X, Y ).This means there exists an edge {a, b} in X such that {σ(a), σ(b)} is an edge in Y , σ(a) = σ (b), σ(b) = σ (a), and σ(c) = σ (c) for all c ∈ [n] \ {a, b}.Since {a, b} is also an edge in X and {σ(a), σ(b)} is also an edge in Y , it follows that {σ, σ } is also an edge in FS( X, Y ).
For σ ∈ S n , we let sgn(σ) denote the sign of σ, which is 1 if σ is an even permutation (i.e., a product of an even number of transpositions) and −1 if σ is an odd permutation (i.e., a product of an odd number of transpositions).Proposition 2.2.If X and Y are graphs on n vertices, then FS(X, Y ) is bipartite.
The following simple proposition shows that in order to understand the connected components of graphs of the form FS(X, Y ), it suffices to understand what happens when X and Y are connected.Recall from Section 1.1 the definition of the graph Cartesian product Proposition 2.4.Let X and Y be graphs on n vertices, and let X 1 , . . ., X r be the connected components of X.
For each ρ ∈ OP n 1 ,...,nr (Y ), let G ρ be the induced subgraph of FS(X, Y ) whose vertex set consists of the bijections σ : X → Y such that ρ σ = ρ.If σ is obtained from σ by performing an (X, Y )-friendly swap (meaning {σ, σ } ∈ FS(X, Y )), then we must have To do this, choose some edge {σ, σ } of G ρ .We know that σ is obtained from σ by performing an (X, Y )friendly swap across {i, j} for some edge {i, j} ∈ E(X).Let X m be the connected component of X containing the edge {i, j}.Then ψ(σ ) is obtained from ψ(σ) by performing an (X m , Y m )friendly swap across {i, j} to the m-th coordinate of ψ(σ) and leaving all other coordinates of ψ(σ) unchanged.This means that {ψ(σ), ψ(σ We now show that when both X and Y are separable, the resulting FS(X, Y ) has a very large number of components; it is for this reason that Wilson [23] restricted his investigation of FS(Star n , Y ) to the case where Y is biconnected.By Proposition 2.4, it suffices to consider the case where X and Y are connected but separable.Proposition 2.6.Let X and Y be connected graphs, each on n ≥ 3 vertices.Suppose x 0 ∈ X and y 0 ∈ Y are cut vertices such that the connected components of X| V (X)\{x 0 } are X 1 , . . ., X r and the connected components of Y | V (Y )\{y 0 } are Y 1 , . . ., Y s .Let M = M(X, Y, x 0 , y 0 ) denote the set of r × s matrices with nonnegative integer entries in which the i-th row sums to |V (X i )| and the j-th column sums to |V (Y j )|.Then the number of connected components of FS(X, Y ) is at least |M|.
For more information about M (including size estimates), we direct the reader to [3,11] and the references therein.Note that we always have |M| ≥ 2 (so that FS(X, Y ) is disconnected) since r, s ≥ 2 by the definition of a cut vertex.We also remark that, as will be apparent in the proof, this lower bound on the number of connected components of FS(X, Y ) is an equality when the graphs X| V (X i )∪{x 0 } and Y | V (Y j )∪{y 0 } are all complete graphs.
It is immediate that every M ∈ M arises as M (σ) for some σ.Therefore, it suffices to show that M (σ) = M (σ ) whenever σ, σ ∈ Σ 0 are in the same connected component of FS(X, Y ).Fix some σ ∈ Σ 0 .We will actually prove the following stronger assertion for every τ ∈ V (FS(X, Y )) in the same connected component as σ: σ) for every i = i 0 .Let us assume that these conditions hold for some τ in the same connected component as σ.We will show that the claim also holds for every vertex τ that is adjacent to τ in FS(X, Y ), which will complete the proof.Let τ be obtained from τ by the application of an (X, Y )-friendly swap across the edge It is also straightforward to check that the claim holds if instead (without loss of generality) The only remaining case is (without loss of generality) where x 0 = x 1 and τ (x 2 ) = y 0 (where we know that x 2 ∈ X i 0 ).Here, the desired condition is again easy to check.
Part of Wilson's Theorem 2.5 says that FS(Star n , Y ) is disconnected whenever Y is bipartite.The following result generalizes this to all bipartite X and Y .As before, let sgn(σ) be 1 if σ is an even permutation and −1 if σ is an odd permutation.
Proposition 2.7.If X and Y are bipartite graphs, each on n ≥ 3 vertices, then FS(X, Y ) is disconnected.
Proof.We may assume We claim that if σ and σ are adjacent in FS(X, Y ), then p(σ) and p(σ ) have the same parity.Indeed, suppose σ is obtained from σ by performing an (X, Y )-friendly swap across {i, j}.This means that {i, j} ∈ E(X) and {σ(i), σ(j)} ∈ E(Y ).The numbers i and j belong to different sets in the bipartition {A X , B X }, and the numbers σ(i) and σ(j) belong to different sets in the bipartition Now suppose X is a graph with vertex set [n] such that Star n is a proper subgraph of X.This means that there exists an edge {i, j} ∈ E(X) with n / ∈ {i, j}.There exists σ ∈ S n such that σ(i) and σ(j) are adjacent in Y .The permutation σ = σ • (i j) is adjacent to σ in FS(X, Y ), and p(σ) ≡ p(σ ) (mod 2).This means that σ and σ are in different connected components of FS(Star n , Y ), but are in the same connected component of FS(X, Y ).Since each of the 2 connected components of FS(Star n , Y ) is contained in a connected component of FS(X, Y ), it follows that FS(X, Y ) is connected.This fact demonstrates a sense in which Wilson's result is sharp.

Paths
In this section, we describe the structure of FS(Path n , Y ).We will see that this characterization is closely related to a known result about Coxeter elements of Coxeter systems.
In what follows, we let G be a graph with vertex set [n].We obtain an orientation of G by choosing a direction for each of its edges.An orientation is acyclic if it does not contain a directed cycle.Let Acyc(G) denote the set of acyclic orientations of G.For every α ∈ Acyc(G), we obtain a poset ([n], ≤ α ) by declaring that i ≤ α j if and only if the directed graph α contains a directed path starting at the vertex i and ending at the vertex j. (When i = j, we can use the 1-vertex path with no edges.)We write L(α) for the set of linear extensions of ([n], ≤ α ), as defined in the introduction.For each permutation σ ∈ S n , there is a unique acyclic orientation α ).Notice that in the poset ([n], ≤ α ), the element σ(i + 1) either covers σ(i) or is incomparable to σ(i).This means that σ(i) and σ(i . This is equivalent to the statement of the theorem. It is well known that the number of acyclic orientations of a graph G is equal to the evaluation T G (2, 0) of the Tutte polynomial of G (see [6] for the definition of the Tutte polynomial).Furthermore, a graph with at least 1 edge has at least 2 acyclic orientations.Hence, we have the following corollary.
Recall that a Coxeter system is a pair (W, S), where W is a group with generating set S = {s 1 , . . ., s n } and presentation W = S : (s i s j ) m i,j = 1 .Here, the exponents m i,j are elements of {1, 2, 3, . ..} ∪ {∞} such that m ii = 1 for all i ∈ [n] and m i,j = m j,i ≥ 2 whenever i = j.Note that the elements s i and s j commute if and only if m i,j ≤ 2. The Coxeter graph1 associated to the Coxeter system (W, S) is the simple graph with vertex set S in which vertices s i and s j are adjacent if and only if m i,j ≥ 3 (i.e., s i s j = s j s i ).A Coxeter element (several authors say standard Coxeter element) of (W, S) is an element of W of the form s σ(1) • • • s σ(n) , where σ ∈ S n .Now let Y be a graph with vertex set [n].There exists a Coxeter system (W, S) whose Coxeter graph is Y , where we identify the vertex i ∈ [n] = V (Y ) with the element s i ∈ S. With this identification, every permutation σ ∈ S n gives rise to a word s σ(1) • • • s σ(n) , which represents a Coxeter element of (W, S).Two such words represent the same element of W if and only if one can be obtained from the other by repeatedly applying the commutation relations s i s j = s j s i , which hold when i and j are adjacent in Y .Applying such a commutation relation to a word s σ(1) • • • s σ(n) means that we swap the factors s σ(i) and s σ(i+1) for some i ∈ [n − 1] such that {σ(i), σ(i + 1)} is an edge in Y .This corresponds precisely to applying a (Path n , Y )-friendly swap to the permutation σ.Hence, the Coxeter elements are equal if and only if σ and σ are in the same connected component of FS(Path n , Y ).It follows that Theorem 3.1 is equivalent to the following standard theorem about Coxeter elements (see [7,10]).It is worth mentioning that Theorem 3.3, and hence Theorem 3.1, can also be interpreted outside of a Coxeter-theoretic framework using certain Cartier-Foata traces [7].
We end this section with a brief description of how the connected components of FS(Path n , Y ) inherit their structure from the graph FS(Path n , K n ).It is immediate that every edge in FS(Path n , Y ) is also an edge in FS(Path n , K n ).On the other hand, suppose σ, τ ∈ S n are in the same connected component of FS(Path n , Y ) and that they are adjacent in FS(Path n , K n ).There must exist i ∈ [n−1] such that τ = σ • (i i + 1).Since σ and τ are in the same connected component of FS(Path n , Y ), Theorem 3.1 tells us that α Y (σ) = α Y (τ ).This implies that σ(i) and σ(i + 1) are adjacent in Y , so τ is obtained from σ by performing a (Path n , Y )-friendly swap across {i, i + 1}.Hence, σ and τ are adjacent in FS(Path n , Y ).This yields the following corollary to Theorem 3.1.
Corollary 3.4.Let Y be a graph with vertex set [n].Let H α be as in Theorem 3.1, so that Remark 3.5.Note that FS(Path n , K n ) is the Hasse diagram of the weak order on S n .A subset A of a poset P is called convex if for all a, c ∈ A and all b ∈ P satisfying a < P b < P c, we have b ∈ A. Björner and Wachs [5] showed that a subset A ⊆ S n is a convex subset of the weak order on S n if and only if A is the set of linear extensions of a poset.It follows from Theorem 3.1 that the set of vertices of a connected component of FS(Path n , Y ) is a convex subset of the weak order on S n .

Cycles
In this section, we describe the structure of FS(Cycle n , Y ).We will see that many of the results in this section are similar in form to those in the previous section, with acyclic orientations and posets replaced by their appropriate toric analogues.One of the key components of the proof of Theorem 3.1 was the fundamental Proposition 1.3, which states that the group of bijections generated by the toggles t 1 , . . ., t n−1 acts transitively on the set of linear extensions of an n-element poset.Some new ideas will be needed to establish the theorems in this section.
Let G be a graph with vertex set [n].A source of an acyclic orientation α of G is a vertex of in-degree 0; a sink of α is a vertex of out-degree 0. If v is a source or a sink of α, then we can obtain a new acyclic orientation of G by reversing the directions of all edges incident to v. We call this operation a flip.Two acyclic orientations α, α ∈ Acyc(G) are torically equivalent, denoted α ∼ α , if α can be obtained from α via a sequence of flips.The equivalence classes in Acyc(G)/∼ are called toric acyclic orientations.We denote the toric acyclic orientation containing the acyclic orientation α by [α] ∼ .
Toric acyclic orientations have been studied in many different forms [8,12,16,18,20,21]; the article [10] formalizes a systematic framework for their investigation.One of the reasons for the use of the word "toric" stems from their connection with hyperplane arrangements.Indeed, consider the graphical arrangement of the graph G, which is the hyperplane arrangement A(G) in R n consisting of the hyperplanes of the form {x ∈ R n : , where π : R n → R n /Z n is the natural projection map.The toric chambers of A tor (G) are the connected components of (R n /Z n ) \ A tor (G).As shown in [10], there is a natural one-to-one correspondence between the toric chambers of A tor (G) and the toric acyclic orientations of G.This is analogous to the standard fact that the chambers of A(G) (the connected components of R n \ A(G)) are in bijection with Acyc(G).
Another (related) motivation for the term "toric" comes from observing that flips encode what happens to the acyclic orientation associated to a permutation when we cyclically shift the permutation.To make this more precise, we let ϕ : [n] → [n] be the cyclic permutation given by ϕ(i) = i + 1 (mod n) and consider the map ϕ * : S n → S n defined by ϕ * (σ) = σ • ϕ.Recall that α G (σ) denotes the unique acyclic orientation of G such that σ ∈ L(α G (σ)).The vertex σ(1) of G is a source of α G (σ).It is not hard to show that the acyclic orientation α G (ϕ * (σ)) is obtained from α G (σ) by flipping the vertex σ(1) from a source into a sink.Consequently, the acyclic orientations α G ((ϕ * ) k (σ)) for 0 ≤ k ≤ n − 1 are all torically equivalent.It is also helpful to keep in mind that the map ϕ * has order n and that the acyclic orientation α is obtained from α G (σ) by flipping the vertex σ(n) from a sink into a source.Note that ϕ is an automorphism of Cycle n .Proposition 2.3 tells us that for every graph Y with vertex set [n], the map ϕ * is an automorphism of FS(Cycle n , Y ).Given an induced subgraph H of FS(Cycle n , Y ), we write ϕ * (H) for the induced subgraph of FS(Cycle n , Y ) on the vertex set ϕ * (V (H)).
We define a linear extension2 of [α] ∼ to be a permutation σ such that there exists an acyclic orientation For every permutation σ, the unique toric acyclic orientation of G that has σ as a linear extension is [α G (σ)] ∼ .
We will also need a new equivalence relation on acyclic orientations of a graph.Suppose α ∈ Acyc(G) has a source u and a sink v such that u and v are not adjacent.We can simultaneously flip u into a sink and flip v into a source; we call this a double flip.We say two acyclic orientations α, α ∈ Acyc(G) are double-flip equivalent, denoted α ≈ α , if α can be obtained from α via a sequence of double flips.Let [α] ≈ denote the equivalence class in Acyc(G)/≈ that contains α.Note that every equivalence class in Acyc /∼ is a union of equivalence classes in Acyc /≈ because each double flip can be viewed as two individual flips performed one after the other; here, it is crucial that we require u and v to non-adjacent in the definition of a double flip.A linear extension of a double-flip equivalence class  is precisely why we forbid u and v from being adjacent in the definition of a double flip.One could also view each double-flip equivalence class as a cyclic version of a Cartier-Foata trace [7], where commutations are additionally allowed to wrap around the end of the word.Theorem 4.1 describes the connected components of FS(Cycle n , Y ), but it is possible to say even more.Namely, we will obtain a description of these connected components that relies on only the equivalence relation ∼, not the double-flip equivalence relation ≈.We first handle the case in which Y is connected, where we will see that each toric acyclic orientation of Y corresponds to a union of n pairwise isomorphic connected components of FS(Cycle n , Y ).We will then use this result to understand the connected components of FS(Cycle n , Y ) when Y is not necessarily connected.
are distinct, pairwise isomorphic connected components of FS(Cycle n , Y ).Moreover, Proof.The claim that the graphs J [α]∼ , ϕ * (J [α]∼ ), . . ., (ϕ * ) n−1 (J [α]∼ ) are pairwise isomorphic connected components of FS(Cycle n , Y ) follows immediately from the fact that ϕ * is an automorphism of FS(Cycle n , Y ) (by Proposition 2.3).Each equivalence class in Acyc(Y )/∼ is a union of equivalence classes in Acyc(Y )/≈, so it follows from Theorem 4.1 that Let us fix a toric acyclic orientation [α] ∼ ∈ Acyc(Y )/∼ and a linear extension We have seen that applying ϕ * to a linear extension of an acyclic orientation β ∈ Acyc(Y ) produces a new permutation whose corresponding acyclic orientation is obtained from β by applying a flip; it follows that (ϕ ) is a union of connected components of FS(Cycle n , Y ), we must have U ⊆ L([α] ∼ ).We need to show that the reverse inclusion L([α] ∼ ) ⊆ U holds and that the subgraphs Define a move to be an operation that changes a permutation τ into a permutation τ such that either {τ, τ } ∈ E(FS(Cycle n , Y )) or τ = ϕ * (τ ).Say two permutations are move-equivalent if there is a sequence of moves transforming the first permutation into the second.Using the fact that (ϕ * ) −1 = (ϕ * ) n−1 , we see that move-equivalence is a genuine equivalence relation.Applying a move to an element of U produces another element of U .Therefore, in order to prove that L([α] ∼ ) ⊆ U , it suffices to show that any two permutations in L([α] ∼ ) are move-equivalent.If two permutations in L([α] ∼ ) are linear extensions of the same acyclic orientation of Y , then they are certainly move-equivalent because they are in the same connected component of FS(Cycle n , Y ) by Theorem 4.1.Therefore, it suffices to show that for any two acyclic orientations α , α ∈ [α] ∼ , there exist linear extensions σ ∈ L(α ) and σ ∈ L(α ) that are move-equivalent.In order to prove this, it suffices to prove it in the case where α is obtained from α via a flip.Without loss of generality, we may assume α is obtained from α by flipping a source u into a sink (otherwise, switch the roles of α and α ).It is straightforward to see that there exists a linear extension σ of α such that σ (1) = u.The permutation σ = ϕ * (σ ) is a linear extension of α .By definition, σ and σ are move-equivalent.
It remains to prove that J [α]∼ , ϕ * (J [α]∼ ), . . ., (ϕ * ) n−1 (J [α]∼ ) are distinct.This will follow if we can show that for every σ ∈ S n and every k ∈ [n − 1], the vertices σ and (ϕ * ) k (σ) lie in different connected components of FS(Cycle n , Y ).To prove this, it is helpful to imagine the cycle graph as lying in the plane with the vertices 1, . . ., n listed clockwise in this order.As in the introduction, we imagine n people labeled with the numbers 1, . . ., n standing on the vertices of thecycle graph, with the person labeled σ(i) on the vertex i.Two people are friends with each other if and only if their labels are adjacent in Y , and two friends can swap places with each other whenever they are at adjacent positions in the cycle.Now suppose by way of contradiction that there is a sequence of (Cycle n , Y )-friendly swaps that changes the configuration of people given by σ to the configuration given by (ϕ * ) k (σ).The overall effect of this transformation is that each person moves k spaces counterclockwise.Imagine assigning a weight to each person so that a person's weight increases by 1 every time they move one space counterclockwise and decreases by 1 every time they move one space clockwise.Assume each person's weight starts at 0. After the sequence of (Cycle n , Y )-friendly swaps that has the effect of moving each person k spaces counterclockwise, each person's weight will be congruent to k modulo n.Since each swap increases one person's weight by 1 and decreases another person's weight by 1, the total weight of all people is always 0. Therefore, at least one person must have a positive weight in the end, and at least one person must have a negative weight in the end.Observe that no person has weight 0 at the end because k ≡ 0 (mod n).Let A + be the (nonempty) set of people whose weights are positive in the end, and let A − be the (nonempty) set of people whose weights are negative in the end.It is clear that if p + ∈ A + and p − ∈ A − , then at some point during the sequence of swaps, the person p + must have swapped places with p − .This means that every person in A + is friends with every person in A − .Using the labels to identify the people with vertices of Y , we see that every person in A + is adjacent in Y to every person in A − .Since A + ∪ A − = V (Y ), this contradicts the assumption that Y is connected.The following corollary tells us about an interesting relationship between the sets Acyc(G)/∼ and Acyc(G)/≈ for an arbitrary graph G.It is worth noting that the proof of this fact, which is not obvious a priori, passes through the analysis of the graph FS(Cycle n , Y ) with Y = G.Corollary 4.6.Let G be a connected graph on n vertices, and let Φ : Acyc(G)/≈ → Acyc(G)/≈ be the map from Corollary 4.2.For each α ∈ Acyc(G), the equivalence class [α] ∼ is the disjoint union Proof.Let Y = G.We saw in the proof of Corollary 4.2 that applying Φ to an equivalence class [β] ≈ corresponds to applying ϕ * to the linear extensions of β.Preserving the notation from Proposition 4.4, we can choose σ [α]∼ to be a linear extension of α so that [α] ≈ is the set of vertices of J [α]∼ .Therefore, the desired result is equivalent to the part of Proposition 4.4 stating that We can now proceed to describe the connected components of FS(Cycle n , Y ) without assuming that Y is connected.The reader may find it helpful to refer to Example 4.8 and Figure 5 while reading the following proof.
Proof.As in the proof of Proposition 4.4, the assertions that are immediate.Let us fix a toric acyclic orientation [α] ∼ ∈ Acyc(Y )/ ∼ and a linear extension σ [α]∼ ∈ L([α] ∼ ).We may assume that σ [α]∼ is actually a linear extension of the specific acyclic orientation α.The same argument used in the proof of Proposition 4.4 shows that the vertex sets of We need to show that the subgraphs (which is a linear extension of α), it follows from Theorem 4.1 that V (J [α]∼ ) = L([α] ≈ ).The proof of Corollary 4.2 tells us that the vertex set of (ϕ * ) k (J [α]∼ ) is the set of linear extensions of Φ k ([α] ≈ ).Therefore, we will be done if we can prove that [α] ∼ decomposes into the disjoint union Let Z 1 , . . ., Z r denote the connected components of Y , where each Z i has size n i .Let Every acyclic orientation β of Y restricts to an acyclic orientaion β (i) of Z i .This yields a map f : Acyc(Y ) → r i=1 Acyc(Z i ) given by f (β) = (β (1) , . . ., β (r) ), which induces the bijections and ( 4) In particular, the bijection f 1 maps our fixed toric acyclic orientation [α] ∼ to the tuple of toric acyclic orientations ([α (1) ] ∼ , . . ., [α (r) ] ∼ ).It follows from Corollary 4.6 that each toric acyclic orientation [α (i) ] ∼ on Z i consists of the disjoint union of n i equivalence classes in Acyc(Z i )/≈ and that there is a faithful transitive action of Z/n i Z on these n i equivalence classes given by Φ i .By combining these individual cyclic actions and using the bijection f 2 , we obtain a faithful transitive action of the (additive Let γ i denote the element of Γ that acts by applying Φ i to Acyc(Z i )/≈.Every time we apply a local double flip to an acyclic orientation of Y , we do not change the ≈ loc -equivalence class.Every time we apply a double flip that is not a local double flip, we must flip a source in some connected component Z i into a sink and simultaneously flip a sink in some different connected component Z j into a source.This non-local double flip has the effect of applying the action of γ i − γ j to the ≈ loc -equivalence class.Let ∆ be the subgroup of Γ generated by all elements of the form γ i − γ j ; we see that each element of Acyc(Y )/≈ contained in [α] ∼ is the union of a ∆-orbit of Acyc(Y )/≈ loc .Furthermore, for every element of Acyc(Y )/≈ loc contained in [α] ∼ , the union of the sets in its ∆-orbit is an element of Acyc(Y )/≈ contained in [α] ∼ .It is now straightforward to compute (using Bézout's Lemma, say) that ∆ has index ν in Γ and that the cosets in Γ/∆ are kγ 1 + ∆ for 0 ≤ k ≤ ν − 1.The element γ 1 acts by applying Φ 1 , which changes a source in Z 1 into a sink.If we have an equivalence class [β] ≈ contained in [α] ∼ , then changing a source of β in Z 1 into a sink (i.e., applying Φ 1 to [β (1) ] ≈ ) corresponds to applying Φ to [β] ≈ .Therefore, (2) follows from the Orbit-Stabilizer Theorem.
Proof.It is known [10] that T Y (1, 0) is the number of toric acyclic orientations of Y , so the enumeration of the connected components follows from Theorem 4.7.
Remark 4.11.If Y is connected, then the number of connected components of FS(Cycle n , Y ) is T Y (1, 0)n.It follows from a well-known theorem of Greene and Zaslavsky [14] that this is also the number of acyclic orientations of Y with exactly 1 source.
For an even more concrete application of Theorem 4.7, we consider the special case in which Y is a forest.Let H be one of the connected components of FS(Cycle n , Y ).By Theorem 4.7, the connected components of FS(Cycle n , Y ) are H, ϕ * (H), . . ., (ϕ * ) ν−1 (H).We want to show that each connected component (ϕ * ) i (H) has an automorphism of order 2; since these connected components are pairwise isomorphic, it suffices to prove that H has an automorphism of order 2. The automorphism group of Cycle n is the dihedral group of order 2n; let ψ be one of the reflections in this group.Let m ∈ {0, . . ., ν − 1} be such that ψ * (H) = (ϕ * ) m (H) (where, by abuse of notation, ψ * (H) denotes the connected component whose vertices form the set ψ * (V (H))).Then (ψ is a reflection in the dihedral group of order 2n, it has order 2. Our goal is to show that FS(Cycle n , Y ) is disconnected; by Proposition 2.1, it suffices to prove that FS(Cycle n , Q) is disconnected.By Theorem 4.7, it suffices to show that Q has at least 2 toric acyclic orientations.As mentioned above, the number of toric acyclic orientations of Q is T Q (1, 0), where T Q (x, y) is the Tutte polynomial of Q.It is well known (and easy to prove from definitions) that Recall that a graph on n vertices is called Hamiltonian if it has a subgraph isomorphic to Cycle n .By combining Corollary 4.14 with Proposition 2.1, we obtain a sufficient condition to guarantee that FS(X, Y ) is connected whenever X is Hamiltonian: if X and Y are graphs on n vertices such that X is Hamiltonian and Y is a forest consisting of trees T 1 , . . ., T r with gcd(|V (T 1 )|, . . ., |V (T r )|) = 1, then FS(X, Y ) is connected.

Sufficient Conditions for Connectivity
A hereditary class is a collection of (isomorphism types of) graphs that is closed under taking induced subgraphs.For example, for each fixed d ≥ 1, the set of all graphs with maximum degree at most d is hereditary.Another example of a hereditary class is the set of all bipartite graphs.Recall that if G is a graph on n vertices, then a Hamiltonian path in G is a subgraph of G isomorphic to Path n .Our goal in this section is to find sufficient conditions on the graphs X and Y that guarantee FS(X, Y ) being connected.Our general setup will involve some fixed hereditary class H.We will consider the case in which X contains a Hamiltonian path and Y belongs to H. We will state our main results in fairly general terms and then exhibit several specific applications.Our results rely heavily on Theorem 3.1, which tells us that the connected components of FS(Path n , Y ) correspond to acyclic orientations of Y .It will be convenient to assume that X has vertex set [n] and that Path n is a genuine subgraph of X (meaning {i, i + 1} ∈ E(X) for all i ∈ [n − 1]).This does not sacrifice any generality because the isomorphism type of FS(X, Y ) depends only on the isomorphism types of X and Y .Proposition In what follows, recall that if G is a graph with vertex set [n] and σ ∈ S n , then α G (σ) denotes the unique acyclic orientation of G that has σ as a linear extension.
Theorem 5.1.Let X and Y be graphs with V (X) = V (Y ) = [n], and suppose that Path n is a subgraph of X. Suppose also that each connected component B of FS(X, Y ) contains some permutation σ B such that n is a sink of α Y (σ B ). Then the number of connected components of FS(X, Y ) is at most the number of connected components of FS(X| Proof.Let B 1 , . . ., B r be the connected components of FS(X, Y ), and let C 1 , . . ., C s be the connected components of FS(X| we know by hypothesis that there is a permutation σ B i in the connected component B i such that n is a sink of α Y (σ B i ).Theorem 3.1 tells us that every linear extension of α Y (σ B i ) is in B i .By replacing σ B i with a different linear extension of α Y (σ B i ) that sends n to n (such a linear extension certainly exists), we may assume without loss of generality that ).We will show that the resulting map f : {B 1 , . . ., B r } → {C 1 , . . ., C s } is injective.
Suppose f ) and α Y (σ B j ) both have n as a sink, and L(β B i ) and L(β B j ) are both subsets of V (C k ).Because σ B i and σ B j send n to n, their restrictions are linear extensions of β B i and β B j (respectively) and hence are both vertices in C k .Thus, there is a sequence of (X| )-friendly swaps can be viewed as a sequence of (X, Y )-friendly swaps that transforms σ B i into σ B j , which implies that B i = B j , as desired.
We now investigate more carefully the conditions under which FS(X, Y ) is connected.Theorem 5.2.Let X and Y be graphs with V (X) = V (Y ) = [n], and suppose that Path n is a subgraph of X. Suppose that Y is connected and that for every Proof.The theorem will follow from Theorem 5.1 if we can show that each connected component of FS(X, Y ) contains a permutation such that the vertex n is a sink in the associated acyclic orientation of Y .Fix a connected component B i of FS(X, Y ); we say a vertex v of Y is a Y -sink relative to B i if there exists a permutation in V (B i ) whose associated acyclic orientation of Y has v as a sink.Our goal is to prove that n is a Y -sink relative to B i ; we will actually prove the stronger fact that every vertex in Y is a Y -sink relative to B i .First, note that at least one vertex of Y must be a Y -sink relative to Assume {y, z} ∈ E(Y ) and y is a Y -sink relative to B i .There is a permutation σ ∈ V (B i ) such that y is a sink of α Y (σ).Theorem 3.1 tells us that every linear extension of α Y (σ) is a vertex in B i , and one such linear extension must send n to y.Therefore, we may assume without loss of generality that σ(n) = y.Let Y be the induced subgraph of Y on [n] \ {y}.The vertices in FS(X| [n−1] , Y ) are the bijections from [n − 1] to [n] \ {y}, which are just the restrictions to [n − 1] of the bijections in S n that send n to y.The hypothesis that FS(X| [n−1] , Y ) is connected tells us that there is a sequence of (X| [n−1] , Y )-friendly swaps that transforms the vertex σ = σ| [n−1] into a permutation τ satisfying τ (n − 1) = z.Let τ be the vertex in FS(X, Y ) that agrees with τ on [n − 1] and satisfies τ (n) = y.In particular, τ (n − 1) = z.Since {y, z} is not an edge in Y , it follows that z must be a sink in α Y (τ ).Finally, the same sequence of (X| [n−1] , Y )-friendly swaps that transforms σ into τ can be interpreted as a sequence of (X, Y )-friendly swaps that transforms σ into τ .This proves that τ ∈ V (B i ), so z is a Y -sink relative to B i , as desired.
It will be helpful to have a notion that captures the idea of extending a Hamiltonian path of a graph X and then adding additional edges.Thus, if X is a graph with a Hamiltonian path, then we define a prolongation of X to be a graph X such that: • X contains a (not necessarily induced) subgraph X # that is isomorphic to X; • X contains a Hamiltonian path that itself contains a Hamiltonian path of X # .Theorem 5.2 has an immediate corollary in the language of hereditary classes and prolongations.
Corollary 5.3.Let H be a hereditary class.Let X be a graph on n 0 vertices with a Hamiltonian path, and suppose that FS(X, Y ) is connected for every Y ∈ H on n 0 vertices.If X is a prolongation of X with n vertices, then FS( X, Y ) is connected for every Y ∈ H on n vertices.
Proof.The proof is by induction on n.The case n = n 0 is obvious, so suppose n > n 0 .By assumption, X contains a subgraph X # that is isomorphic to X and a Hamiltonian path P that contains a Hamiltonian path of X # .Since n > n 0 , we can find an endpoint p of the path P such that X| V ( X)\{p} is a prolongation of X on n − 1 vertices.Let us identify V ( X) with [n] in such a way that p is identified with n and P is identified with Path n .Then X| [n−1] is a prolongation of X.Since Y is in the hereditary class H, every (n − 1)-vertex induced subgraph of Y | V ( Y )\{y} is in H.

By our induction hypothesis, the graph FS(X|
we identify V ( Y ) with [n] in an arbitrary way, then it follows from Theorem 5.2 that FS( X, Y ) is connected.
The set of all graphs Y such that Y has maximum degree at most d forms a natural hereditary class.Equivalently, this hereditary class consists of all graphs Y with minimum degree at least |V (Y )| − d − 1.Given some d ≥ 1 and a graph X on n 0 vertices, it requires only a finite search to determine whether or not FS(X, Y ) is connected for every graph Y on n 0 vertices with minimum degree at least n 0 − d − 1. Carrying out this finite computation for various d's and X's (with computer assistance) gives corollaries for infinite families of graphs.Each of these results would presumably require significant work to prove independently in an ad hoc way; Corollary 5.3 provides a unified framework for understanding them.Corollary 5.6.Let X be the graph .For every prolongation X of X and for every graph Y on |V ( X)| vertices with minimum degree at least |V ( X)| − 3, the graph FS( X, Y ) is connected.
Our motivation for investigating the phenomena of this section began with an attempt to understand FS(X, Y ) when X is the graph .
More specifically, we are interested in characterizing the graphs Y such that FS(X, Y ) is connected.It follows from Corollary 5.4 that requiring Y to have minimum degree at least n − 2 is a sufficient condition to guarantee that FS(X, Y ) is connected.We will see in the next section that this condition is also necessary.

Necessary Conditions for Connectivity
We begin by describing a fairly general necessary condition for FS(X, Y ) to be connected in the case where X has a long path consisting of cut vertices and Y has a vertex of low degree.This result can be understood as an extension of Proposition 2.6.Theorem 6.1.Let X and Y be graphs on n vertices.Suppose where x 1 and x d are cut vertices and each of x 2 , . . ., x d−1 has degree exactly 2. If the minimum degree of Y is at most d, then FS(X, Y ) is disconnected.
Proof.Proposition 2.1 tells us that adding edges to Y cannot make FS(X, Y ) become disconnected, so we may assume that the minimum degree of Y is exactly d; let y 0 ∈ V (Y ) be a vertex of degree d, and denote its neighbors by y 1 , . . ., y d .We now identify special vertices x 0 , x d+1 ∈ V (X) as follows.First, suppose d = 1.Since x 1 is a cut vertex of X, it has neighbors in multiple connected components of X| V (X)\{x 1 } ; let x 0 and x 2 be neighbors of x 1 in different connected components of X| V (X)\{x 1 } .Second, suppose d > 1.Since x 1 is a cut vertex of X, it has a neighbor in a connected component of X| V (X)\{x 1 } that does not contain x 2 ; fix x 0 to be any such neighbor of x 1 .Similarly, since x d is a cut vertex of X, it has a neighbor in a connected component of X| V (X)\{x d } that does not contain x d−1 ; fix x d+1 to be any such neighbor of x d .Note that any path from x 0 to x d+1 must traverse x 1 • • • x d .Note also that each of the vertices x 1 , . . ., x d is a cut vertex of X.Finally, let R denote the vertex set of the connected component of X| V (X)\{x 1 } that contains x 0 .See Figure 6.
(c) Suppose τ satisfies condition (ii) for some i and neither u nor v equals τ −1 (y 0 ).Then u and v are contained in the same connected component of X| V (X)\{x i } .In particular, we see that which shows that τ satisfies condition (ii).(d) Suppose τ satisfies condition (ii) for some 2 ≤ i ≤ d − 1 and τ −1 (y 0 ) ∈ {u, v}.Without loss of generality, assume u = τ −1 (y 0 ) = x i .Since the only neighbors of x i are x i−1 and x i+1 , we conclude that v is one of these two vertices.Note (as before) that τ (v) = y j for some 1 ≤ j ≤ d and that (τ The assumption on τ implies that this set has size at least i − 1, so τ satisfies condition (ii).
Recall that x 1 is adjacent to only x 2 and some vertices in R, so these are the only possible vertices that v can be.
Without loss of generality, assume u = τ −1 (y 0 ) = x d .Note that we have v = τ −1 (y j ) for some 1 ≤ j ≤ d.All vertices y 1 , . . ., y d are contained in τ (R ∪ {x 1 , . . ., x d−1 }) by assumption, so we see that The assumption on τ implies that this set has size at least d − 2, so τ satisfies condition (ii).This analysis exhausts the possible cases and completes the proof.We now derive some consequences of Theorem 6.1 regarding specific families of graphs.The lollipop graph Lollipop k,m is the graph with vertex set [k + m] and edge set In other words, Lollipop k,m is obtained by identifying the vertex k + 1 in the path graph Path k+1 with the vertex k + 1 in the complete graph on the vertex set {k + 1, . . ., k + m}.The following corollary is immediate from Theorem 6.1.Before proving this result, we establish a simple lemma.Recall that α Y (λ) denotes the acyclic orientation of Y associated to the permutation λ, where an edge {y, z} is oriented from y to z if and only if λ −1 (y) < λ −1 (z).
), so it follows immediately from Theorem 3.1 that there is a sequence of (Path n−1 , Y )-friendly swaps transforming λ| Now assume Y has minimum degree at least n − 2. This means that Y has maximum degree at most 1.In other words, Y is a disjoint union of copies of K 1 and K 2 .Choose a permutation σ ∈ S n , and let B be the connected component of FS(D n , Y ) containing σ.We are going to show that the identity permutation in S n is also in B. Since σ was arbitrary, this will imply that FS(D n , Y ) is connected.Consider the acyclic orientation α Y (σ) of Y associated to σ. Suppose {u, v} is an edge of Y with σ −1 (u) < σ −1 (v).This means that in α Y (σ), the edge {u, v} is oriented from u to v. Since {u, v} is an isolated edge in Y , the vertex v must be a sink of α Y (σ).We claim that there is a permutation σ in B such that α Y ( σ) is the same as α Y (σ) except with the orientation of {u, v} reversed.First, suppose σ(n) = v.Let r be such that σ(n − r) = u.We can apply (D n , Y )-friendly swaps across {n − r, n − r + 1}, {n − r + 1, n − r + 2}, . . ., {n − 2, n − 1} (in this order) and then another (D n , Y )-friendly swap across {n − 2, n} so as to obtain the permutation It is straightforward to check that σ is in B and that α Y ( σ) is obtained from α Y (σ) by reversing the orientation of {u, v}.Next, assume that σ and σ (n − 2) = u.Applying Lemma 6.6 with λ = σ and λ = σ , we find that σ is in B. If we apply a (D n , Y )-friendly swap across {n − 2, n} to σ , we obtain a permutation σ in B such that the acyclic orientations α Y (σ) and α Y ( σ) agree except in the orientation of {u, v}, as desired.
We have shown that we can use a sequence of (D n , Y )-friendly swaps to reverse the orientation of a single edge in the acyclic orientation of Y associated to a permutation.By repeating this argument, we can eventually construct a permutation τ in B such that α Y (τ ) is any prescribed acyclic orientation of Y .In particular, we can choose τ in B so that each edge {a, b} in Y with a < b is oriented from a to b in α Y (τ ).In other words, α Y (τ ) = β, where β is the acyclic orientation of Y associated to the identity permutation in S n .
We are going to show that there is a permutation τ in B with α Y (τ ) = β and τ (n) = n.If we can do this, then it will follow from Lemma 6.6 (with λ = τ and λ the identity permutation) that the identity permutation is also in B, as claimed.If τ (n) = n, then we can simply set τ = τ .Thus, let us assume that τ (n) = n.Using the fact that n ≥ 4, it is not difficult to check that there exists a linear extension τ of β such that τ (n) = τ (n) and τ (n − 2) = n.Invoking Lemma 6.6 with λ = τ and λ = τ , we see that τ is in B. Note that n is a sink of β by the definition of β.Since τ is a linear extension of β, the vertex τ (n) must also be a sink of β.The vertices τ (n) and n are distinct sinks of β, so they are not adjacent in Y .Therefore, we can perform a (D n , Y )-friendly swap across {n − 2, n} in order to transform τ into a different linear extension τ of β with τ (n) = n.This permutation τ is in B, as desired.

Concluding Remarks and Open Problems
We conclude with several open problems and suggestions for future inquiries along the lines of the present paper.7.1.Other graphs.In Sections 3 and 4, we gained a full understanding of the connected components of FS(Path n , Y ) and FS(Cycle n , Y ).It could be interesting consider complements of paths and cycles by investigating the connected components of FS(Path n , Y ) and FS(Cycle n , Y ).Another natural direction would be the exploration of graphs of the form FS(K k,n−k , Y ), where K k,n−k is the complete bipartite graph with partite sets of sizes k and n − k.Note that K 1,n−1 is isomorphic to Star n , which was studied thoroughly by Wilson [23].It might be interesting to consider just the specific complete bipartite graphs K 2,n−2 , or possibly K r,r .It would also be interesting to obtain more general results about the graphs FS(X, Y ) when X is a tree (or even a specific type of tree).Let us also recall Remark 6.4, which asks for a characterization of the graphs Y such that FS(Lollipop n−5,5 , Y ) is connected.Of course, several other nice families of graphs that we have not mentioned could also give rise to interesting results.7.2.Making FS(X, Y ) connected for all reasonable graphs Y .One might naturally ask for the sparsest graph Y on n vertices such that FS(X, Y ) is connected whenever X is a connected graph on n vertices.For FS(Path n , Y ) to be connected, Y must be a complete graph.A less trivial variant of this problem asks for the sparsest graph Y on n vertices such that FS(X, Y ) is connected whenever X is a biconnected graph on n vertices.In this case, FS(Cycle n , Y ) must be connected, so it follows from Corollary 4.14 that Y must be a forest consisting of trees of coprime sizes.This implies that Y must have at least n 2 − (n − 2) edges.This bound of n 2 − (n − 2) is tight.Indeed, suppose Y is a graph such that Y is the disjoint union of a tree on n − 1 vertices and an isolated vertex v * .Then Y contains a subgraph isomorphic to Star n (with v * as the center of the star).Suppose X is biconnected.We want to show that FS(X, Y ) is connected.If X is isomorphic to Cycle n , then the connectedness of FS(X, Y ) follows from Corollary 4.14.If n = 7 and X is isomorphic to the graph θ 0 from Theorem 2.5, then one can check by computer that FS(X, Y ) is connected.Now assume X is not isomorphic to θ 0 or a cycle graph.If X is not bipartite, then FS(X, Y ) is connected because FS(X, Star n ) is connected by Wilson's theorem (FS(X, Star n ) and FS(Star n , X) are isomorphic).If X is bipartite, then the connectedness of FS(X, Y ) follows from Remark 2.8 because Star n is isomorphic to a proper subgraph of Y .
We have shown that if FS(X, Y ) is connected for all biconnected graphs X, then Y must a forest consisting of trees of coprime sizes.We have seen that some of these choices for Y do indeed make FS(X, Y ) connected for all biconnected X.The following conjecture states that all such choices of Y satisfy this property.7.3.Diameter and girth.In a different direction, one might ask about the diameter and girth of the graph FS(X, Y ) or its connected components.Recall that if X and Y are graphs on n vertices, then FS(X, Y ) has n! vertices.Must the diameter of a connected component of FS(X, Y ) be polynomially bounded in n? What changes if we restrict our attention to X and Y such that FS(X, Y ) is connected?For the girth of FS(X, Y ), we can say somewhat more.Since FS(X, Y ) is bipartite (by Proposition 2.2), its girth is either even (and greater than or equal to 4) or infinite.It is easy to see that if X and Y each have 2 pairwise disjoint edges, then the girth of FS(X, Y ) is exactly 4. The behavior in the remaining case (which can be reduced to the setting where X is a star and Y is connected) remains unknown.
It would also be interesting to understand the diameters of connected components of some specific graphs that we have studied already, such as FS(Path n , Y ) and FS(Cycle n , Y ).For example, Proposition 1.3 states that for every n-element poset P , the group of bijections generated by the toggle operators t 1 , . . ., t n−1 acts transitively on the set L(P ) of linear extensions of P .It is natural to ask for the maximum distance between two linear extensions of P , where the distance is measured by the number of toggle operators needed to change the first linear extension into the second.To state this problem in the language we have been using throughout this article, let Z be the Hasse diagram of P (viewed as a graph), and let Y = Z.Consider the acyclic orientation α of Y = Z given by orienting each edge {x, y} from x to y whenever y covers x in P .Then we are asking for the diameter of the connected component H α of FS(Path n , Y ) as defined in Theorem 3.1.7.4.New equivalence relations for acyclic orientations.Equivalences of acyclic orientations under various flips played a major role in our analysis in Section 4. Fix nonnegative integers a and b and a graph G, and consider the set Acyc(G) of acyclic orientations of G. Suppose that in an acyclic orientation α ∈ Acyc(G), there are pairwise non-adjacent vertices u 1 , . . ., u a and v 1 , . . ., v b such that every u i is a source and every v i is a sink.Then we can obtain a new acyclic orientation by instance, following the referee's suggestion, hyperoctahedral groups).Even when Γ = S n , the above definition still vastly generalizes friends-and-strangers graphs because we do not require the elements of S R and S L to be transpositions.It could be fruitful to investigate whether these graphs have interesting structural properties when Γ = S n and the sets S R and S L are chosen very specifically.

Remark 2 . 8 .
by exactly 1 and that (sgn(σ) + 1)/2 and (sgn(σ ) + 1)/2 differ by exactly 1.This proves the claim that p(σ) ≡ p(σ ) (mod 2).It follows that p(τ ) ≡ p(τ ) (mod 2) whenever τ and τ are in the same connected component of FS(X, Y ).Now fix τ ∈ S n .Since n ≥ 3, there exist elements a and b of [n] that lie in the same set in the bipartition {A X , B X }.Let τ = τ • (a b).Then p(τ ) and p(τ ) differ by 1, so τ and τ must lie in different connected components of FS(X, Y ).Note that Star n is bipartite with bipartition {[n − 1], {n}}.Suppose that n ≥ 3 and that Y is a biconnected graph on the vertex set [n] that is not isomorphic to Cycle n or θ 0 .If Y is bipartite with bipartition {A Y , B Y }, then it follows from Theorem 2.5 that FS(Star n , Y ) has exactly 2 connected components.Appealing to the proof of Proposition 2.7, we find that the connected components of FS(Star n , Y ) must be precisely {σ ∈ S n : p(n) ≡ 0 (mod 2)} and {σ ∈ S n : p(n) ≡ 1 (mod 2)}, where

Figure 2 .
Figure2.A graph G labeled according to the permutation σ = 53142.Each vertex i is labeled with a plain black label i and a circled red label σ −1 (i).The edges are oriented so as to form the acyclic orientation α G (σ).

Figure 3 .
Figure 3.Each red box encompasses a toric acyclic orientation of K 3 .Each blue box encompasses a double-flip equivalence class of K 3 .Note that each double-flip equivalence class contains a single acyclic orientation; it is impossible to perform a double flip on an acyclic orientation of a complete graph because sources and sinks are all adjacent.We have colored sinks purple and sources green.

Figure 4 .
Figure 4.This graph has only 1 toric acyclic orientation, which is the union of the 5 double-flip equivalence classes encompassed in the blue boxes.We have colored sinks purple and sources green.

Proof.
The theorem is equivalent to the statement that two permutations σ, σ ∈ S n are in the same connected component of FS(Cycle n , Y ) if and only if α Y (σ) ≈ α Y (σ ).First, suppose σ and σ are adjacent in FS(Cycle n , Y ).This means that σ is obtained from σ by performing a (Cycle n , Y )friendly swap across an edge {i, j} ∈ E(Cycle n ).If i ≤ n − 1 and j = i + 1, then this (Cycle n , Y )friendly swap is also a (Path n , Y )-friendly swap, so σ and σ are adjacent in FS(Path n , Y ).By Theorem 3.1, this implies that α Y (σ) = α Y (σ ).Now suppose {i, j} = {n, 1}.The vertices σ(1) and σ(n) are adjacent in Y , so they are not adjacent in Y .The former vertex is a source in α Y (σ), and the latter is a sink in α Y (σ).It is straightforward to see that α Y (σ ) is obtained from α Y (σ) by performing a double flip that simultaneously flips σ(1) from a source to a sink and flips σ(n) from a sink to a source.Consequently, α Y (σ) ≈ α Y (σ ).This shows that α Y (σ) ≈ α Y (σ ) whenever σ and σ are adjacent in FS(Cycle n , Y ), which implies that α Y (σ) ≈ α Y (σ ) whenever σ and σ are in the same connected component of FS(Cycle n , Y ).To prove the converse, notice that the vertex set of a connected component of FS(Cycle n , Y ) is a union of vertex sets of connected components of FS(Path n , Y ).By Theorem 3.1, the vertex set of each connected component of FS(Path n , Y ) is the set of linear extensions of some acyclic orientation of Y .Therefore, we need only show that if α, α ∈ Acyc(Y ) satisfy α ≈ α , then there exist τ ∈ L(α) and τ ∈ L(α ) such that τ and τ are in the same connected component of FS(Cycle n , Y ).To prove this, it suffices to consider the case in which α is obtained from α by performing a double flip.Thus, let us assume that there exist a source u of α and a sink v of α (with {u, v} ∈ E(Y )) such that α is obtained from α by flipping u into a sink and flipping v into a source.It is straightforward to see that there is a linear extension τ of α such that τ (1) = u and τ (n) = v.The vertices u and v are adjacent in Y (since they are not adjacent in Y ), so the operation that changes τ into τ := τ • (1 n) is a (Cycle n , Y )-friendly swap.Observe that τ is a linear extension of α .Since τ and τ are adjacent in FS(Cycle n , Y ), they are certainly in the same connected component.

Corollary 4 . 2 .
Let G be a graph on n vertices.Given α ∈ Acyc(G), let α be an acyclic orientation obtained from α by flipping a source into a sink.The equivalence class [ α] ≈ depends on only the equivalence class [α] ≈ , not the specific representative α or the source in α that is flipped to obtain α.Therefore, the mapΦ : Acyc(G)/≈ → Acyc(G)/≈ defined by Φ([α] ≈ ) = [ α] ≈ is well-defined.Proof.Let Y be a graph with vertex set [n] such that Y is isomorphic to G. Choose α, α ∈ Acyc(Y )such that α ≈ α .Let u and u be sources of α and α , respectively.Let α (respectively, α ) be the acyclic orientation obtained from α (respectively, α ) by flipping u (respectively, u ) into a sink.There exist σ ∈ L(α) and σ ∈ L(α ) such that σ(1) = u and σ (1) = u .Because α ≈ α , it follows from Theorem 4.1 that σ and σ are in the same connected component of FS(Cycle n , Y ).Because ϕ * is an automorphism of FS(Cycle n , Y ), the permutations ϕ * (σ) and ϕ * (σ ) are in the same connected component of FS(Cycle n , Y ).We now check that ϕ * (σ) ∈ L( α) and ϕ * (σ ) ∈ L( α ).Using Theorem 4.1 once again, we find that α ≈ α .This proves that the map Φ is well-defined.Example 4.3.Figures 3 and 4 show toric acyclic orientations in red boxes and double-flip equivalence classes in blue boxes.In each case, the double-flip equivalence classes within each toric acyclic orientation are cyclically ordered from left to right.The map Φ sends each double-flip equivalence class to the next double-flip equivalence class in this cyclic order.

Example 4 . 8 .
Suppose Y = so that Y is the graph .Let Z 1 be the connected component of Y with 2 vertices, and let Z 2 be the connected component with 3 vertices.Each green box in Figure 5 encompasses a local-double-flip equivalence class of acyclic orientations of Y ; this figure shows how Φ 1 and Φ 2 act on these equivalence classes.In this case, the group Γ is (Z/2Z) × (Z/3Z).The element γ 1 = (1, 0) acts on the double-flip equivalence classes via Φ 1 , and γ 2 = (0, 1) acts via Φ 2 .The graph Y has only 1 toric acyclic orientation.Because gcd(2, 3) = 1, it follows from Theorem 4.7 that FS(Cycle 5 , Y ) has only 1 connected component; according to Theorem 4.1, this implies that there is only 1 double-flip equivalence class of acyclic orientations of Y .Indeed, this is because Γ is generated by the element γ 1 − γ 2 = (1, −1).We can reach any local-double-flip equivalence class from any other by repeatedly applying γ 1 − γ 2 , and each application of γ 1 − γ 2 corresponds to applying a non-local double flip.

Corollary 4 . 12 .
Let Y be a graph with n ≥ 3 vertices such that Y is a forest consisting of trees T 1 , . . ., T r , and let ν = gcd(|V (T 1 )|, . . ., |V (T r )|).Then FS(Cycle n , Y ) has ν connected components.These connected components are pairwise isomorphic, and they each contain n!/ν vertices.Moreover, each connected component of FS(Cycle n , Y ) has an automorphism of order 2. Proof.We may assume V (Y ) = [n].It is known that T Y (1, 0) = |Acyc(Y )/∼| = 1 because Y is a forest.Consequently, the statements about the enumeration and sizes of the connected components of FS(Cycle n , Y ) follow directly from Theorem 4.7.

Example 4 . 13 .
Let us revisit Example 1.2, which concerns the graph FS(Cycle 5 , Y ) where Y = .Notice that the complement of Y is the tree Y = ; Corollary 4.12 now explains why FS(Cycle 5 , Y ) has 5 pairwise isomorphic connected components, each with an automorphism of order 2. Corollary 4.14.Let Y be a graph with n ≥ 3 vertices.The graph FS(Cycle n , Y ) is connected if and only if Y is a forest consisting of trees T 1 , . . ., T r such that gcd(|V (T 1 )|, . . ., |V (T r )|) = 1.Proof.If Y is a forest consisting of trees T 1 , . . ., T r , then Corollary 4.12 tells us that FS(Cycle n , Y ) is connected if and only if gcd(|V (T 1 )|, . . ., |V (T r )|) = 1.Now suppose Y is not a forest, meaning it contains a cycle of some length m with 3 ≤ m ≤ n.Let Q be the graph consisting of n − m isolated vertices and one cycle of length m.Since Q is a subgraph of Y , the graph Y must be a subgraph of Q.
2.1 tells us that the vertex set of each connected component of FS(X, Y ) is a union of vertex sets of connected components of FS(Path n , Y ); Theorem 3.1 tells us that the vertex set of a connected component of FS(Path n , Y ) is the set of linear extensions of the corresponding acyclic orientation of Y .

Corollary 5 . 4 .
Let X be the triangle K 3 .For every prolongation X of X and for every graph Y on |V ( X)| vertices with minimum degree at least |V ( X)| − 2, the graph FS( X, Y ) is connected.Corollary 5.5.Let X be the graph .For every prolongation X of X and for every graph Y on |V ( X)| vertices with minimum degree at least |V ( X)| − 3, the graph FS( X, Y ) is connected.

Figure 6 .
Figure 6.A schematic illustration of the proof of Theorem 6.1 (with d = 3).

Corollary 6 . 2 .
Let X be a subgraph of Lollipop n−m,m .If Y is a graph on n vertices such that FS(X, Y ) is connected, then the minimum degree of Y is at least n − m + 1.The graph Lollipop n−3,3 is a prolongation of K 3 .Therefore, Corollary 5.4 guarantees that FS(Lollipop n−3,3 , Y ) is connected whenever Y is a graph on n vertices with minimum degree at least n − 2. Consequently, we can appeal to Corollary 6.2 to obtain a complete classification of the graphs Y such that FS(Lollipop n−3,3 ) is connected.Corollary 6.3.Let Y be a graph on n vertices.The graph FS(Lollipop n−3,3 , Y ) is connected if and only if the minimum degree of Y is at least n − 2.Remark 6.4.The graph Lollipop n−5,5 is a prolongation of the graph X in Corollary 5.5, so it follows from that corollary that FS(Lollipop n−5,5 , Y ) is connected whenever Y is a graph on n vertices with minimum degree at least n − 3. On the other hand, Corollary 6.2 tells us that FS(Lollipop n−5,5 , Y ) is disconnected whenever Y is a graph on n vertices with minimum degree at most n − 5. We leave open the characterization of graphs Y such that FS(Lollipop n−5,5 , Y ) is connected; in order to finish the characterization, it suffices to consider only the graphs Y with minimum degree n − 4.We end this section with a discussion of one additional nice family of graphs.For n ≥ 3, let D n be the graph with vertex set [n] and edge set {{i, i+ 1} : 1 ≤ i ≤ n − 2} ∪ {{n − 2, n}}.The notation D n is chosen because this graph is the Dynkin diagram of type D n .We will show that for n ≥ 4, the characterization of the graphs Y such that FS(D n , Y ) is connected is precisely the same as the characterization of the graphs Y such that FS(Lollipop n−3,3 , Y ) is connected.Hence, the edge {n − 1, n} in Lollipop n−3,3 has no influence on whether or not FS(Lollipop n−3,3 , Y ) is connected.Theorem 6.5.Let Y be a graph on n ≥ 4 vertices.The graph FS(D n , Y ) is connected if and only if the minimum degree of Y is at least n − 2.

Lemma 6 . 6 .
Let Y be a graph with vertex set [n].If λ and λ are two permutations in S n such that λ(n) = λ (n) and α Y (λ) = α Y (λ ), then λ and λ are in the same connected component of FS(D n , Y ).
[n−1] into λ | [n−1] .Because Path n−1 is a subgraph of D n and Y is a subgraph of Y , this same sequence of friendly swaps can be viewed as a sequence of (D n , Y )-friendly swaps that transforms λ into λ .Proof of Theorem 6.5.We may assume V (Y ) = [n].The graph D n is a subgraph of Lollipop n−3,3 .Therefore, if the minimum degree of Y is at most n − 3, then it follows from Proposition 2.1 and Corollary 6.3 that FS(D n , Y ) is disconnected.

Conjecture 7 . 1 .
Let Y be a graph on n vertices such that Y is a forest consisting of trees T 1 , . . ., T r such that gcd(|V (T 1 )|, . . ., |V (T r )|) = 1.If X is a biconnected graph on n vertices, then FS(X, Y ) is connected.

is not difficult to show that the graph FS(Star n , Cycle n ) has (n−2)! connected components, each of which contains exactly n(n − 1) vertices. The connected components of FS(Star n , Cycle n ) correspond to cyclic orderings of [n − 1]: indeed, by repeatedly swapping the vertex labeled n with its clockwise neighbor, one can obtain any other labeling of Cycle n that witnesses the same cyclic
and only if {σ, σ } in an edge in G ρ .
1) are adjacent in Y (i.e., nonadjacent in Y ) if and only if they are incomparable in ([n], ≤ α ).Letting t 1 , . . ., t n−1 be the toggle operators from Proposition 1.3 (with respect to the poset ([n], ≤ α )), we see that σ and σ are adjacent if and only if σ = t i (σ) for some i ∈ [n − 1].It follows that if σ and σ are adjacent in FS(Path n , Y ), then α Y (σ) = α Y (σ ).Using Proposition 1.3, we see that σ and σ are in the same connected component of FS(Path n , Y ) if and only if α Y be the map that flips a source of an acyclic orientation of Z i into a sink, which is well-defined by Corollary 4.2.We now define yet another equivalence relation on Acyc(Y ).Say that a double flip is a local double flip if the flipped source and sink are in the same connected component of Y .We say that two acyclic orientations β, β ∈ Acyc(Y ) are local-double-flip equivalent, denoted β ≈ loc β , if β can be obtained from β by a sequence of local double flips.Note that every equivalence class in Acyc(Y )/≈ is a union of equivalence classes in Acyc(Y )/≈ loc .