Combinatorial Gray codes-an updated survey

A combinatorial Gray code for a class of objects is a listing that contains each object from the class exactly once such that any two consecutive objects in the list differ only by a `small change'. Such listings are known for many different combinatorial objects, including bitstrings, combinations, permutations, partitions, triangulations, but also for objects defined with respect to a fixed graph, such as spanning trees, perfect matchings or vertex colorings. This survey provides a comprehensive picture of the state-of-the-art of the research on combinatorial Gray codes. In particular, it gives an update on Savage's influential survey [C. D. Savage. A survey of combinatorial Gray codes. SIAM Rev., 39(4):605--629, 1997.], incorporating many more recent developments. We also emphasize the connections to closely related problems in graph theory, algebra, order theory, geometry and algorithms, which embeds this research area into a broader context. Lastly, we collect and propose a number of challenging research problems, thus stimulating new research endeavors.


Introduction
In computer science and discrete mathematics, we frequently encounter different classes of combinatorial objects. For example, we may be interested in all subsets or all permutations of some ground set, all strings over some alphabet, all binary trees on a certain number of nodes, or all spanning trees of a graph, to mention just a few examples. A combinatorial Gray code is a listing of the combinatorial objects in the class of interest that contains each object exactly once such that any two consecutive objects in the list differ only by a 'small change'. This concept is named after Frank Gray, a physicist and researcher at Bell Labs, whose patent [Gra53] from 1953 describes a method for listing all bitstrings of length n such that any two consecutive strings differ in exactly one bit. Combinatorial Gray codes have a large number of real-world applications, and we shall see that this research area has ramifications into graph theory, algebra, order theory, geometry and algorithms.
De Bruijn sequences and universal cycles are closely related to Gray codes, but beyond the scope of this survey. We refer to the papers [Fre82,CDG92] and to the online resource [dB] for readers interested in this subject.

Outline of this paper
In Section 2 we introduce some terminology that is used throughout this paper, and we collect a few general observations that are valid for any Gray code problem. We also show how Gray codes relate to several other research areas in mathematics and computer science. Sections 3-10 describe the literature on combinatorial Gray codes, sorted by objects and sometimes by methods. Some objects generalize multiple other objects, and assigning them to one particular section is somewhat arbitrary. For example, multiset permutations generalize combinations and permutations, and they are treated in Section 5 on permutations. This survey contains numerous figures of different Gray codes, which facilitate comparison between the different constructions, thus also stimulating new research questions. Moreover, the figures convey the wealth and aesthetic appeal of the subject.

Flip graphs
Nearly every Gray code problem can be described by considering the corresponding flip graph. The vertices of this graph are the combinatorial objects to be listed in the Gray code, and the graph has an edge connecting any two objects that differ by the desired 'small change' operation, sometimes generically referred to as a flip. If the flip operation is not an involution, then the edges of the flip graph are directed. In this way, we obtain a huge family of interesting graphs; see Figure 1. For example, the flip graph of bitstrings of length n under flipping a single bit is the n-dimensional hypercube Q n , or n-cube for short (Figure 1 (a)). The flip graph of subsets of [n] := {1, 2, . . . , n} of fixed size k under exchanging a single element is the Johnson graph J(n, k) (Figure 1 (b)). The flip graph of subsets of [n] of fixed size k under disjointness is the Kneser graph K(n, k) (Figure 1 (c)). The flip graph of permutations of [n] under adjacent transpositions is the permutahedron (Figure 1 (d)). The flip graph of binary trees with n nodes under tree rotations is the associahedron (Figure 1 (f)). Clearly, finding a Gray code is equivalent to finding a Hamilton path or cycle in the corresponding flip graph. The term 'Gray code' can refer to both a Hamilton path or cycle, and we call a Gray code cyclic to mean a Hamilton cycle, i.e., the last and first object in the Gray code listing also differ by a flip.
In some of these examples we see that a flip operation can change many, possibly all, entries of the string representation of an object, so the question of what constitutes a 'small change' is up to debate. For example, the directed edges in Figure 1  often lead to very interesting Gray codes. Insisting that a Gray code may only change a constant number of positions in the string, which is prevalent in many papers, is a misguided paradigm. One reason is that the amount of change is entirely dependent on the representation of the object. For example, we will encounter Gray codes for permutations that use cyclic shifts of substrings, and while these shifts may change many entries of the permutation, they change only a single entry in the corresponding inversion vector. Another reason is that depending on the available hardware, these 'not-so-small' changes may actually be implemented faster.
Flip graphs allow us to apply graph-theoretic tools to tackle the Gray code problem. Moreover, they call for investigating all kinds of other interesting graph-theoretic parameters beyond Hamiltonicity, such as girth, diameter, connectivity, colorability, independence number etc.
In some Gray code problems, the admissible flip operations depend on the recent history of previous flips, and in this case there is no underlying 'static' flip graph, which typically makes these problems hard. Examples of this are the order-preserving paths of Felsner and Trotter and Beckett-Gray codes (see Sections 3.3 and 3.8).

Necessary conditions
There are a few simple graph-theoretic conditions that a graph G has to satisfy in order to have a Hamilton path or cycle. Trivially, G needs to be connected. Furthermore, if G has vertices of degree 1, then a Hamilton cycle cannot exist, and if G has more than two vertices of degree 1, then a Hamilton path cannot exist. Also, if G has precisely two vertices of degree 1, then any Hamilton path in G must start and end at these two vertices. Moreover, if G is bipartite with partition classes of different sizes, then a Hamilton cycle cannot exist, and if the size difference between the partition classes is more than 1, than a Hamilton path cannot exist. This condition generalizes straightforwardly to k-partite graphs G for k ⩾ 2, where one compares the size of one partition class against the sum of the sizes of all others. We refer to this condition on G as balancedness constraint. As we shall see, for most interesting flip graphs G, the aforementioned connectivity, minimum degree and balancedness constraints are the only obstacles for Hamiltonicity, i.e., once G satisfies these three constraints, then it does have a Hamilton path or cycle. This could be considered a 'meta-conjecture' for most interesting flip graphs (a notable counterexample is mentioned in [Naa01]).

Stronger Hamiltonicity notions
For constructing Gray codes, it is often helpful to establish stronger Hamiltonicity properties of the corresponding flip graph. Specifically, a graph is called Hamilton-connected, if it admits a Hamilton path between every pair of vertices. Moreover, a bipartite graph is called Hamilton-laceable, if it admits a Hamilton path between every pair of vertices from the two partition classes. For example, the hypercube and the permutahedron for n ⩾ 4 are Hamilton-laceable (see [Sim78] and [Tch82], respectively), and the Johnson graph is Hamilton-connected [JR94,Kno94]. There are many more strengthened Hamiltonicity properties in addition to the aforementioned two, some of which we will encounter in Section 9; see also [XM09]. Establishing these stronger properties yields more information about the flip graph, and maybe counter-intuitively, it often makes the proof of Hamiltonicity easier, and not harder. This is because the inductive statements involving these stronger notions are more powerful and flexible.

General Gray code results
As mentioned before, a Gray code corresponds to a Hamilton path or cycle in the corresponding flip graph G. More generally, a k-Gray code is a sequence of vertices of G that contains every vertex exactly once, such that any two consecutive vertices in the sequence have distance at most k in G. Given a graph G, the kth power of G, denoted G k , is the graph with the same vertex set as G, connecting any two vertices that have distance at most k in G with an edge. With this definition, a k-Gray code corresponds to a Hamilton path in G k , and a cyclic k-Gray code corresponds to a Hamilton cycle in G k .
Sekanina [Sek60] proved that the cube G 3 of any connected graph G has a Hamilton cycle. Equivalently, his result asserts that any connected graph G admits a cyclic 3-Gray code. If a flip graph is not just connected, but 2-connected, even more can be said. Specifically, Fleischner [Fle74] proved that the square G 2 of any 2-connected graph G has a Hamilton cycle. Equivalently, any 2-connected graph G admits a cyclic 2-Gray code. Karaganis [Kar68] strenthened Sekanina's result, by showing that for any connected graph G, the cube G 3 is Hamilton-connected. Similarly, Chartrand, Hobbs, Jung, Kapoor, and Nash-Williams [CHJ + 74] strengthened Fleischner's theorem, by showing that for 2-connected G, the square G 2 is Hamilton-connected. Alstrup, Georgakopoulos, Rotenberg and Thomassen [AGRT18] developed an algorithm for computing such Hamilton cycles and paths in G 2 , running in time and space O(|E|), where |E| is the number of edges of G. Sekanina's aforementioned result about G 3 is also algorithmic, with the same bounds, and a cycle can be obtained by traversing any spanning tree of G in prepostorder; see [Knu11, Sec. 7.2.1.6]. To complement these results, it is known that if G is not 2-connected, then the Hamiltonicity problem for G 2 is NP-complete [Und78].
These results, which deserve to be better known in the Gray code community, impose some criteria against which we should compare any Gray code results obtained for particular combinatorial objects. Put differently, as soon as the flip graph of a Gray code problem is connected or 2-connected, we are immediately guaranteed a 3-Gray code or 2-Gray code, respectively, by the results from before, so any further work on the problem should either focus on obtaining 2-or 1-Gray codes, or on conceptual simplicity or algorithmic efficiency for the particular problem.

Algorithmic questions
Of course, the linear bound O(|E|) in the algorithms discussed in the previous section is not very satisfying in the context of Gray codes. This is because the size of a flip graph for a particular Gray code problem is often exponential in the size of the parameter that specifies the objects. For example, the n-cube has 2 n vertices and 2 n−1 n edges, or the permutahedron for [n] has n! vertices and n!(n − 1)/2 edges. In those situations, we will much prefer Gray code algorithms that work in time and space that are polynomial in n. The word 'time' here refers to the time per generated object, or equivalently, to the delay between two consecutive objects. The ultimate goal from an algorithmic point of view is to develop a Gray code algorithm with constant delay, i.e., each new object is produced in constant time. Such algorithms are sometimes called loopless or loop-free, a term coined by Ehrlich [Ehr73b]. Another interesting class are constant amortized-delay or constant amortized-time (CAT) algorithms, which produce each new object in constant time on average (not necessarily in the worst case). In addition to being fast, a Gray code algorithm ideally requires only linear space to store the current object and possibly some auxiliary data structures. Information-theoretic trade-offs concerning the space-and memory-efficient computation of Gray codes are explored in the literature under the term quasi-Gray codes, a direction initiated by Fredman [Fre78].
Apart from generating a Gray code listing, there are two closely related algorithmic tasks of interest, namely ranking and unranking. Ranking means to compute, for a given combinatorial object, its position in the Gray code listing. On the other hand, unranking means to compute, for a given position, the object at this position in the Gray code listing. Clearly, efficient unranking can be used for efficient random generation of the objects.
In this survey, we comment on the aforementioned algorithmic issues for several Gray codes problems, but we do not delve into low-level implementation details. Knuth covers a large number of these algorithms in his book [Knu11], which also contains numerous challenging research problems and interesting background information; see also [Knu20]. Furthermore, Arndt's book [Arn11] contains a vast number of recent C++ implementations and experimental comparisons of many of the Gray code algorithms discussed here. Lastly, many of these algorithms are available on the Combinatorial Object Server [cos] for experimentation and download, an online project that was first launched by Frank Ruskey.

Posets and polytopes
Interestingly, many flip graphs can be equipped with a poset structure. For example, the hypercube is the cover graph of the Boolean lattice, the permutahedron is the cover graph of the weak Bruhat order of the symmetric group S n , and the associahedron is the cover graph of the Tamari lattice (recall Figure 1 (a)+(d)+(f)). Moreover, many flip graphs are skeleta of high-dimensional polytopes, including the aforementioned hypercube, permutahedron and associahedron. These observations link the Gray code problem to order theory and geometry, enabling us to apply tools and insights from those areas. Most importantly, this allows broad generalization of the classes of flip graphs under investigation, and unification of several known Gray code results through a common lens: • The hypercube, permutahedron and associahedron arise as cover graphs of quotients of lattice congruences of the symmetric group S n [Rea12], and the corresponding polytopes are known as quotientopes [PS19,PPR21]. This is a family of 2 2 n(1+o(1)) many flip graphs, and there is a simple greedy algorithm for computing a Hamilton path in each of them [HM21], which yields a unified description of several known Gray codes for bitstrings, permutations, binary trees, set partitions, rectangulations etc. [HHMW22]. • Graph associahedra, introduced by Carr and Devadoss [CD06,Dev09] and Postnikov [Pos09], are another large class of polytopes that generalize hypercube, permutahedron and associahedron. They yield a family of 2 n 2 /2(1+o(1)) many flip graphs, most of which have a Hamilton cycle [MP16,CMM22]. • The Johnson graph and the flip graph of spanning trees of a graph under edge exchanges (recall Figure 1 (b)+(g)) arise as skeleta of matroid base polytopes [NP81], and a Hamilton path on all of those can be computed by a simple greedy algorithm (see Section 9.1). • Flip graphs on acyclic orientations of a graph induced by flipping the orientation of a directed cycle or a directed cut can be equipped with a distributive lattice structure [Pro21], and they are realized by distributive polytopes that are part of the large family of alcoved polytopes [LP07,FK11]. • Flip graphs on acyclic orientations of a graph induced by flipping the orientation of a single arc also have a poset structure, and they can be realized as polytopes [SZ98]. These posets sometimes form a lattice and admit lattice congruences that can also be realized as polytopes [Pil21], generalizing the aforementioned quotientopes.

P1
The question when Hamilton paths or cycles exist for the latter two classes of flip graphs is still very much open in general.

Lovász' conjecture and Cayley graphs
Many natural Gray code problems yield flip graphs that are highly symmetric. Specifically, many are vertex-transitive, such as the hypercube, permutahedron, Johnson graphs or Kneser graphs, and others are regular, such as the associahedron, or more generally, all graph associahedra. P2 This connects the Gray code problem to a well-known and long-standing conjecture due to Lovász [Lov70], which asserts that every connected vertex-transitive graph has a Hamilton path. A stronger version of the conjecture asserts that such a graph admits a Hamilton cycle, unless it is one of following five exceptional graphs: a single edge, the Petersen graph, the Coxeter graph, and the graphs obtained from the latter two by replacing every vertex by a triangle. Thomassen conjectured that there are only finitely many such counterexamples (see [Ber78]). Note that by a theorem of Mader [Mad70], every vertex-transitive graph with degree k is k-connected, provided that it does not contain a clique of size 4, which can be seen as evidence for Lovász' conjecture. In stark contrast, Babai [Bab95] conjectured that for some ε > 0, there are infinitely many connected vertex-transitive graphs with n vertices (even Cayley graphs) without cycles of length at least (1 − ε)n.
There are several results establishing Lovász' conjecture subject to conditions on n, the number of vertices of the graph. For example, vertex-transitive graphs with prime n are circulant graphs [Tur67], and therefore a Hamilton cycle can be traced by following vertices with a fixed step size (modulo n) along the circulant vertex ordering. Similarly, the conjecture has been confirmed if n equals one of the following expressions, where p and q denote prime numbers: 2p [Als79], 3p [Mar88], 4p [KM08], 5p [MP82], 6p [KŠ09], 10p [KMZ12] (with some additional assumptions), p 2 and p 3 [Mar85], p 4 [Che98], p 5 [Zha15], 2p 2 [Mar87], and pq [DKM21], in some cases in the stronger Hamilton cycle version. Christofides, Hladký and Máthé [CHM14] proved that for every ε > 0 there is an n 0 such that every vertex-transitive graph with n ⩾ n 0 vertices and degree at least εn has a Hamilton cycle. For more results on Lovász' conjecture, we refer to the survey [KM09] by Kutnar and Marušič. P3 Cayley graphs are a major class of vertex-transitive graphs, and are thus also an important special case of Lovász' conjecture. The question for Hamilton cycles in Cayley graphs was first raised by Rapaport-Strasser [RS59]. For a finite group G and a set of generators X, the Cayley graph Γ(G, X) has vertex set G and edges (g, gx), (g, gx −1 ) for all g ∈ G and x ∈ X. Every two vertices in this graph that are connected by an edge also have an edge in the opposite direction, so it can be considered as an undirected graph. The Cayley digraph #" Γ (G, X) has the vertex set G and directed edges (g, gx) for all g ∈ G and x ∈ X (i.e., inverse operations must not be used). Note that if X −1 := {x −1 | x ∈ X} = X, then the distinction between these two graphs is irrelevant. This happens for example if X is a set of involutions, i.e., x 2 = 1 for all x ∈ X. Also note that if G = S n is the symmetric group and x = σ k ∈ X is the operation that cyclically left-shifts the first k entries of the permutation, then for every directed edge (π, πx) =: (π, π ′ ), π ∈ S n , of #" Γ (G, X), we have π ′ (i) = π(x(i)) = π(σ k (i)) for all i = 1, . . . , n, i.e., the permutation π ′ is obtained from π by cyclically right-shifting the first k entries. In this case, it is maybe more intuitive to consider the Cayley graph #" Γ (G, X −1 ), which is obtained from #" Γ (G, X) by reversing the orientation of all edges; see Figure 1 There is a substantial number of cases for G and X for which Γ(G, X) or #" Γ (G, X) are known to have a Hamilton cycle. One instance is the Chen-Quimpo theorem [CQ81], which asserts that if G is an abelian group such that the Cayley graph Γ(G, X) is connected and has degree at least 3, then it is Hamilton-connected if it is not bipartite and Hamilton-laceable if it is bipartite. Conway, Sloane and Wilks [CSW89] showed that if G is a direct product G = G 1 × · · · × G k of irreducible Coxeter groups, and if X i is the canonical basis for G i for all i = 1, . . . , k, then the Cayley graph Γ(G, X) for the basis X = X 1 × · · · × X k has a Hamilton cycle. For more results on the Hamiltonicity of Cayley graphs, see Sections 5.2 and 5.3 and the surveys [Als81, WG84, CG96, PR09, LPR + 19] (see also [GKMM12] for another relevant result on 3-regular Cayley graphs).

Genlex ordering
As mentioned before, this survey focuses on Gray codes and not on the broader topic of efficient combinatorial generation. For this reason, we never discuss lexicographic or colexicographic orderings. Put differently, for those orderings there is no corresponding flip operation and hence no flip graph. Nevertheless, there is a generalization of lexicographic and colexicographic orderings that is very relevant in the context of Gray codes, namely genlex ordering, a term coined by Walsh [Wal03]. A listing of strings over some alphabet is in genlex order, if all strings with the same prefix (or suffix) appear consecutively. Such listings are also sometimes referred to as prefix-partitioned (or suffix-partitioned) [VW06].
This generalizes graylex order introduced by Chase [Cha89], in which the symbols after the common prefixes (or before the common suffixes) appear in monotonic order, i.e., increasingly or decreasingly. Note that in lexicographic or colexicographic order, they always appear in increasing order. We shall see that many different classes of objects admit genlex Gray codes. This is significant, as any genlex listing can be constructed by a simple greedy algorithm; see Section 10.

Binary strings
In this section we discuss Gray codes for listing all 2 n bitstrings of length n, subject to various additional conditions. We also discuss Gray codes for subsets of bitstrings that arise from structural constraints in the hypercube Q n , from forbidding certain substrings, or from considering equivalence classes of strings. Most Gray codes in this section flip a single bit in each step, i.e., they correspond to paths or cycles in Q n or subgraphs of it. In Sections 3.16, 3.17 and 3.18 we also encounter 2-and 3-Gray codes, which flip at most 2 or 3 bits in each step, which corresponds to paths or cycles in Q 2 n or Q 3 n . Another exception is Section 3.14, where we consider Gray codes that use cyclic shifts or transpositions of bits. Note that bitstrings of length n can be interpreted as characteristic vectors of subsets of [n], so the Gray codes discussed in this section can be seen as listings of subsets of the ground set [n]. Flipping a single bit in a bitstring corresponds to adding or removing a single element in the corresponding subsets.
For any string x and any integer ℓ ⩾ 0, we write x ℓ for the ℓ-fold repetition of x.

The binary reflected Gray code
The binary reflected Gray code (BRGC) [Gra53] lists all bitstrings of length n such that any two consecutive strings differ in a single bit, including the last and first bitstring. The BRGC is defined inductively as Γ 0 := ε and Γ n+1 := 0Γ n , 1 rev(Γ n ) for n ⩾ 0, where ε denotes the empty sequence and rev() denotes sequence reversal; see Figure 2 (a). In words, the listing for strings of length n + 1 is obtained by prepending 0 to all strings in the listing for n, followed by the reversed listing in which all strings are prepended 1.  [TL73] showed that in the sublist of the BRGC induced by bitstrings with a fixed number of 1s, any two consecutive bitstrings differ in two bits (a transposition of 0 and 1); see Section 4.1. Also, it was shown by Yuen [Yue74] and Cavior [Cav75] that if any two n-bit strings differ in t > 0 bits, then they are at least ⌈2 t /3⌉ steps and at most 2 n − ⌈2 t /3⌉ steps apart in the BRGC. More interesting properties of the BRGC are established in the papers by Conder [Con99], and by Agrell, Lassing, Ström, and Ottosson [ALSO04]. Bitner, Ehrlich and Reingold [BER76] describe a loopless algorithm for generating the BRGC. For many of the Gray codes with additional constraints discussed in the following sections, no such efficient algorithms are known, and it would be very interesting to devise them.

Transition counts
Since the discovery of the BRGC, there has been continued interest in constructing Gray codes with additional desirable properties that the BRGC does not have. A problem that has received a lot of attention is to construct a Gray code where the number of flips are distributed as equally as possible over the n bit positions; see Figure 2 (b). Specifically, let c i denote the number of times that bit i is flipped along a given Gray cycle, where we number bits from right to left with i = 1, . . . , n. Clearly, each transition count c i must be an even number, and they sum up to 2 n , so we require that each c i is approximately equal to 2 n /n. Formally, in a balanced Gray code, we require that |c i − 2 n /n| < 2 for i = 1, . . . , n. In particular, if n is a power of 2, then c 1 = · · · = c n = 2 n /n. Note that in the BRGC, we have c i = 2 n−i for i = 1, . . . , n − 1 and c n = 2, i.e., it is very unbalanced. A variant of balanced Gray codes are exponentially balanced Gray codes, in which each transition count c i is one of two consecutive powers of 2. Note that if n is a power of 2, then this is the same problem as before. Van Zanten and Suparta [vZS04] constructed exponentially balanced Gray codes for any n ⩾ 1, answering a conjecture posed in the aforementioned paper by Wagner and West, and a simplified construction was later given by Suparta [Sup05].
The most general version of this problem is to ask for an n-bit Gray code with arbitrary prescribed transition counts c 1 , . . . , c n . Clearly, we may assume without loss of generality that c 1 ⩽ c 2 ⩽ · · · ⩽ c n , and we have to require that each c i is even, that n i=1 c i = 2 n , and that k i=1 c i ⩾ 2 k for each 1 ⩽ k ⩽ n. P5 The problem is whether every sequence c 1 , . . . , c n of integers satisfying those necessary conditions allows constructing a cyclic n-bit Gray code with exactly these transition counts. Observe that solving this problem for one particular value of n also solves it for all smaller values. On the other hand, Potapov [Pot12] positively resolved the problem for all n > N := ⌈2 2 µ/2 (4+log 2 µ) ⌉ where µ := 4(2 35 − 2 4 )/31, conditional on the assumption that it has a positive solution for n = N (and therefore also for all n < N ). Consequently, settling the base case n = N for his inductive argument is a very interesting open problem, but is infeasible to tackle solely with computer help. Already Gilbert [Gil58, Thm. IV], using a lemma of Shannon [Sha49], showed how to construct a Gray path with prescribed transition counts of the form 1, c 2 , . . . , c n (i.e., the first bit flips exactly once), if they satisfy the corresponding obvious necessary conditions.

Weight-monotonicity
The weight of a bitstring is defined as the number of 1s in it. Savage and Winkler [SW95] considered Gray codes for which the weight of bitstrings increases (almost) monotonically along the code. Specifically, a monotone Gray path starts at 0 n and once it has visited a bitstring of weight k, it never returns to a bitstring of weight k − 2. The last bitstring on the path will either have weight n if n is odd or weight n − 1 if n is even. Savage and Winkler constructed such a monotone path for any n ⩾ 1, and their solution is shown in Figure 2 (c). An even stronger requirement was proposed by Felsner and Trotter [FT95]; see also [JSH09,Problem 483]. They ask for an order-preserving Gray path x 1 , . . . , x N with N = 2 n , which starts at 0 n and if x i is obtained from x j by a flip 1 → 0, then i ⩽ j + 1. It is easy to check that any order-preserving path must also be monotone. However, the Savage-Winkler paths are not order-preserving, and for n = 8 the bitstrings violating the order-preserving property are marked in Figure 2 (c) with a small dot on the left. Computer experiments show that for n = 1, . . . , 7, the number of order-preserving Gray paths is 1, 1, 1, 1, 10, 123, 1 492 723 [OEIS A259839], and solutions have also been found for n ∈ {8, 9, 10} (by Trotter and Mütze, independently), one of which is shown in Figure 2 (c'). For comparison, the number of monotone paths for n = 1, . . . , 6 is 1, 1, 1, 1, 14, 46 935. In all those counts, paths that differ only in renaming the coordinate directions are factored out and not counted separately. P6 It is a challenging open problem whether order-preserving paths exist for n ⩾ 11. As a partial result, Felsner and Trotter [FT95] constructed an order-preserving Gray path of length N = 2 n−1 (1 + o(1)). Moreover, it was shown by Biró and Howard [BH09a] that for all n ⩾ 11, there is an order-preserving path that traverses all bitstrings with weights 0, 1, 2, 3 (and some bitstrings with weight 4, but no other weights), so it has length N = Θ(n 3 ).

Antipodal Gray codes
In a t-antipodal Gray code, we require that the complement of any bitstring is visited either exactly t steps before or later. In principle, t can be any integer in the interval [n, 2 n−1 ], but t and n must have the same parity. Killian and Savage [KS04] attribute this problem to Snevily, and they consider the case when t = n. Specifically, they proved that no solution exists for any odd n ⩾ 5 or for n = 6, and presented a constructive solution when n is a power of 2, which is shown in Figure 2 (e). They mention as an open problem the question whether an n-antipodal n-bit Gray code exists for even n ⩾ 10. Chang, Eu, and Yeh [CEY07] showed that a t-antipodal n-bit code for odd n ⩾ 3 exists if and only if t = 2 n−1 − 1. Moreover, for even n ⩾ 6 they constructed t-antipodal codes for all t = 2 n−1 − 2 k with k odd and 1 ⩽ k ⩽ n − 3, and for t = 2 n−k with 1 ⩽ k ⩽ 3. Knuth [Knu11,Ex. 49 in Sec. 7.2.1.1] describes a simple solution for even n ⩾ 2 and t = 2 n−1 ; see Figure 2 (e'). In Figures 2 (e) and (e'), any bitstring whose complement appears t steps earlier is drawn shaded.

Run lengths
Another property of interest are run lengths of a Gray code, i.e., the number of bitstrings visited between two flips of the same coordinate. In Figure 2, the run lengths are the heights of maximal vertical blocks of either black or white squares. We let r(n) denote the maximum value r such that an n-bit Gray code with all run lengths at least r exists.
P8 The exact value of r(n) for n = 1, . . . , 7 is r(n) = 1, 2, 2, 2, 4, 4, 5, and it is unknown for n ⩾ 8 [Knu11, Sec. 7.2.1.1]. An 8-bit Gray code with all run lengths at least 5 is shown in Figure 2 (d) (it is the same as in [Knu11, Fig. 34 in Sec. 7.2.1.1]). Clearly, we have r(n) ⩽ n, and Goddyn and Gvozdjak [GG03] proved the remarkable fact that r(n) ⩾ ⌈n−2.001 log 2 (n)⌉ ⩾ n−3 log 2 (n) = n−O(log n) for n ⩾ 2, improving upon earlier results due to Evdokimov [Evd80] and Goddyn, Lawrence and Nemeth [GLN88]. Note that in an n-antipodal n-bit Gray code, the run lengths within every pair of a block and its subsequent complemented block are equal to n, but not necessarily across the boundaries of these pairs. Codes with long run lengths have applications in image detectors [LM96] and for structured light [KRL08].

Non-locality
In a non-local Gray code, we require that among any 2 t consecutive bitstrings, strictly more than t bit positions change, for any 2 ⩽ t ⩽ n − 1; see Figure 2 (f). This is impossible for n = 2, 3, 4, but can be achieved for any n ⩾ 5, as was first shown by Mills [Mil63]. A simpler construction was later given by Ramras [Ram90].

Trend-freeness
In a trend-free Gray code, the center of mass of 1-bits in each coordinate position is in the middle. Equivalently, we require that 2 n i=1 i(−1) x i,k = 0 for all k = 1, . . . , n, where x i,k denotes the kth bit in the ith bitstring. Such codes are useful for experiment design [Dic74,VS80,Che85]. Note that the BRGC satisfies the trend-freeness conditions for all bit positions except the leftmost one (k = n). Knuth [Knu11, Ex. 75 and 76 in Sec. 7.2.1.1] gives a simple construction of trend-free Gray codes for all n ⩾ 5; see Figure 2 (g), improving upon an earlier result due to Cheng [Che85].

Beckett-Gray codes
Beckett-Gray codes are named after the Irish playwright Samuel Beckett, whose play 'Quad' consists of a series of arrivals and departures of characters who appear on stage together in different combinations. Whenever a character leaves, it is the one who has been on stage longest among all characters present. Formally, the problem is to find an n-bit Gray code with the property that on every transition 1 → 0, the 1-bit that disappears is the one that appeared first among all 1-bits. There is no constraint with regards to the other transitions 0 → 1. We can think of the positions of 1s as being stored in a queue that operates on a first-in first-out basis. Cooke, North, Dewar and Stevens [CNDS16] found such codes with the help of computers for n = 2, 5, 6, 7, 8, see Figure 2 (h), and showed that none exist for n = 3, 4. Sawada and Wong [SW07] report on some computational advances and additional solutions found with computer help. It is an open problem whether Beckett-Gray codes exist for n ⩾ 9. This problem has a 'dynamic' flavor, i.e., the way that the cycle can move through the n-cube depends on the recent history, similarly to the aforementioned order-preserving path problem by Felsner and Trotter, which makes both problems hard.

Transition graphs
We let P n , C n , K n and K k,n−k denote the path, cycle, complete graph and complete bipartite graph on the vertex set [n], where the partition classes of K k,n−k have size k and n − k. We consider the transition sequence of a Gray code, i.e., the cyclic sequence δ 1 , . . . , δ 2 n of bit positions that change along the code. For instance, starting at 0000 the BRGC Γ 4 shown in Figure 1 (a) has the transition sequence 1213121412131214 (the rightmost bit flips in every second step, and the leftmost bit flips only twice). Such a transition sequence defines a graph G on the vertex set [n], by adding all edges {δ i , δ i+1 } for i = 1, . . . , 2 n , where indices are taken modulo 2 n . We refer to a Gray code yielding a particular graph G as a G-code. Note that G is always a connected graph, and the BRGC is a K 1,n−1 -code. The problem of which n-vertex graphs G admit a G-code was first raised by Slater [Sla79] for the case when G = P n . P10 There is a P n -code for n = 2, 3, 5, but none for n = 4, 6, 7 [Sla89], and it is open whether there is one for n ⩾ 8. Similarly, it is open whether there is a C n -code for n ⩾ 8 (there is one for n = 4 and none for n = 3, 6, 7, and none is known for n = 5). The papers [BR96] and [WE02] catalogue all trees G on up to n = 7 vertices that do not admit a G-code. Moreover, Bultena and Ruskey [BR96] proved that if G is a tree with diameter 4, then there is a G-code, and if G is a tree with diameter 3, then there is no G-code. They also constructed G-codes such that G is a subgraph of any multipartite graph. Wilmer and Ernst [WE02] answered several open problems from the Bultena-Ruskey paper, by showing that there are G-codes such that G is a tree with arbitrarily large diameter, and that there are G-codes such that G is a subgraph of any two-dimensional grid. Suparta and van Zanten [SvZ08] constructed a K n -code for any n ⩾ 3; see Figure 2 (i). Moreover, Suparta [Sup17] describes a K k,n−k -code for any 1 ⩽ k ⩽ n − 1. Dimitrov, Dvořák, Gregor, and Škrekovski [DDGŠ13] constructed an n-bit G-code such that G is an induced subgraph of the ⌈log 2 (n)⌉-cube. In particular, if n is a power of 2, then this is a Q log 2 (n) -code; see Figure 2 (i').

Avoiding and including other structures
If we consider a Gray code as a Hamilton cycle in Q n for n ⩾ 2, we may ask for cycles that avoid or include certain other structures.
In this direction, Chan and Lee [CL91] showed that Q n , n ⩾ 3, has a Hamilton cycle that avoids a given set F of at most 2n − 5 edges, provided that each vertex is incident to at least two edges not in F , and the bound 2n − 5 is best possible. Moreover, Dimitrov, Dvořák, Gregor and Škrekovski [DDGŠ09] showed that Q n has a Hamilton cycle that avoids a given perfect matching M if and only if Q n \ M is connected.
Dvořák [Dvo05] showed that any set of at most 2n − 3 edges that together form disjoint paths in Q n can be extended to a Hamilton cycle, and this bound is best possible. Note that any Hamilton cycle in Q n can be partitioned into two perfect matchings. Conversely, Kreweras [Kre96] conjectured that every perfect matching in Q n can be extended to a Hamilton cycle (via a second perfect matching). More generally, Ruskey and Savage [RS93] asked whether any matching (not necessarily perfect) extends to a Hamilton cycle; see also [JSH09,Problem 487]. Kreweras' conjecture was answered affirmatively by Fink [Fin07], and his beautiful and concise proof was later refined by Gregor [Gre09]. More recently, Fink [Fin19] proved that every (not necessarily perfect) matching of Q n extends to a cycle factor, i.e., to a collection of disjoint cycles that together visit all vertices. The original Ruskey-Savage conjecture is still open, and constitutes one of the most intriguing problems in this area.
A symmetric chain in Q n is a path x k , . . . , x n−k where x i has weight i for all i = k, . . . , n − k, and a symmetric chain decomposition is a partition of all vertices of Q n into symmetric chains. This concept was pioneered by Greene and Kleitman [GK76] (see also [dBvETK51,Kat66,Aig73,WW77]). Streib and Trotter [ST14] constructed a Hamilton cycle in Q n that contains a symmetric chain decomposition; see Figure 2 (j), where the chains are highlighted on the side. Gregor, Mička and Mütze [GMM20] showed that the aforementioned symmetric chain decomposition due to Greene and Kleitman can be extended to a Hamilton cycle of Q n ; see Figure 2 (j'). A Hamilton cycle that extends a symmetric chain decomposition has the minimum number of peaks and valleys, which are triples of consecutive vertices x i , x i+1 , x i+2 where x i and x i+2 have the same weight. It is interesting to contrast this with the aforementioned monotone path due to Savage and Winkler, which has the maximum number of peaks and valleys. The authors of [GMM20] also conjectured that every symmetric chain decomposition of Q n can be extended to a Hamilton cycle, but a counterexample in Q 6 can be constructed easily: We start with the Greene-Kleitman decomposition, and we consider the chains C 1 = −−−−−−, C 2 = −−01−−, C 3 = −0011− and C 4 = 000111 of lengths 6, 4, 2, and 0, respectively, where 0s and 1s represent fixed bits, and − represents a bit that changes from 0 to 1 when moving up the chain, with the flips occurring from left to right. We remove the middle vertex of C i and reconnect the remaining two pieces of the chain C i via the middle vertex of C i+1 for i = 1, 2, 3. This yields a modified symmetric chain decomposition of Q 6 in which the former middle vertex of C 1 , namely 111000, is a chain of length 0, with the additional property that all of its neighbors are inner vertices of another chain, i.e., this length 0 chain cannot be connected to any other chain along a Hamilton cycle.
The results of Aubert and Schneider [AS82] imply that all edges of Q n can be partitioned into Hamilton cycles and possibly a perfect matching (see [ABS90]). Saad and Schultz [SS88] proved that Q n contains a cycle of length ℓ for every even number ℓ from 4 to 2 n . Simmons [Sim78] first proved that Q n has a Hamilton path between any two prescribed vertices of opposite parity, i.e., it is Hamilton-laceable. This was later generalized by Dvořák and Gregor [DG07], who showed that any two prescribed vertices u and v of opposite parity can be joined by a Hamilton path containing at most 2n − 4 prescribed edges that together form disjoint paths, if none of the paths contains u or v internally or joins u and v. The bound 2n − 4 is again best possible. More results about cycles in the n-cube satisfying various additional constraints are surveyed by Xu and Ma [XM09]. For some older results about the n-cube, we refer the reader to the survey [HHW88] by Harary, Hayes and Wu.

The number of Gray codes
Let H(n) denote the number of Hamilton cycles in the n-cube, where we do not distinguish the starting vertex or direction of the cycle, but the names of the n coordinate directions matter (factoring them out one needs to divide by n!/2).

Single-track Gray codes
Single-track Gray codes were discovered by Hiltgen, Paterson, and Brandestini [HPB96]. In such a code, any two of the n columns of bits differ only in a cyclic shift. As before, any two consecutive rows/bitstrings differ in a single bit. Clearly, the single-track property implies that the Gray code is balanced, i.e., each bit is flipped the same number of times. Single-track Gray codes are useful for measuring angular positions, using only a single column of bits to encode the different positions, and n appropriately rotated reading heads along this column; see Figure 2 (k), where the shifted columns are shaded and the shifts are indicated by horizontal bars. In this example, 16 bitstrings are missing from the code. Indeed, for n ⩾ 3 the single-track property does not allow to visit all 2 n bitstrings, but only a subset of size N < 2 n . In the aforementioned paper, Hiltgen, Paterson, and Brandestini show that 2n must divide N for such a code to exist. Moreover, they provide constructions of single-track Gray codes of length N = kn, for all n ⩾ 4 and every even 2 ⩽ k ⩽ 2 n−1−⌈ √ 2(n−3)⌉ . Etzion and Paterson [EP96] constructed single-track Gray codes of length N = 2 n − 2n for the special case when n is a power of 2. Later, Schwartz and Etzion [SE99] proved that this is the maximum length of a cycle one can achieve under these conditions. Their result shows that the single-track cycle of length 2 8 − 2 · 8 = 240 shown in Figure 2 (k) is in fact longest possible. P13 Etzion [Etz07] gives a short survey on the state-of-the art on single-track Gray codes, and mentions as the most interesting open problem the question whether for prime n ⩾ 3 there is a single-track Gray code of length N = 2 n − 2, which would be optimal. This has been tested and confirmed for all prime n ⩽ 19. A natural approach to construct such a Gray code is to find a Gray cycle through all n-bit necklaces except 0 n and 1 n , which are aperiodic as n is prime, so the number of such necklaces is N/n, selecting one representative from each necklace arbitrarily, in such a way that from the last representative a single flip leads to a shifted version of the first representative. Applying the transition sequence of such a Gray cycle n times, each time shifted appropriately, produces the desired single-track Gray code. The open problem mentioned in Section 3.17 seeks a very similar Gray path through all n-bit necklaces (starting and ending in 0 n and 1 n , respectively).
More generally, in a t-track Gray code, the n columns of bits can be partitioned into t groups such that the columns in each group differ only in a cyclic shift. Gregor, Merino, and Mütze [GMM22a] constructed a t-track Gray code of all 2 n bitstrings of length n (no bitstring is missed) for every n that is a sum of t ⩾ 2 powers of 2. In particular, if n is a sum of two powers of 2, then this is a 2-track Gray code; see Figure 2 (k'). Furthermore, these results also show that for every dimension n ⩾ 5 there is a t-track Gray code with t ⩽ ⌊log 2 (n + 1)⌋, i.e., at most logarithmically many tracks.

Symmetric Gray codes
In other words, when arranging the vertices in the order of the Hamilton cycle equidistantly on a circle and drawing the edges of Q n as straight lines, then the resulting drawing has k-fold rotational symmetry. Gregor, Merino, and Mütze [GMM22a] constructed a ksymmetric Hamilton cycle of Q n for k := 2 ⌈log 2 n⌉ , and they showed that this factor k is largest possible. Clearly, if n is a power of 2, then this optimum factor equals k = n. Such an 8-symmetric Hamilton cycle for n = 8 is shown in Figure 2

Shifts and transpositions
Feldmann and Mysliewietz [FM96] constructed a Gray code for all bitstrings of length n which in every step either flips the leftmost bit or shifts all bits cyclically one position to the left or right.
Savage, Shields and West [SSW03] consider a Gray code for all bitstrings of length n which in every step either flips the leftmost bit or transposes two adjacent bits 01 ↔ 10. Such a Gray code corresponds to a Hamilton path in the cover graph of a poset introduced by Stanley, and it must start and end at 0 n and 1 n , respectively, as these two only admit flipping the leftmost bit. The authors constructed such a Gray code for all n > 5 for which n+1 2 is odd, and showed that it does not exist otherwise due to balancedness problems. Figure 2 (l) shows their construction for n = 6.

Coils and snakes
A coil-in-the-box is an induced cycle in the n-cube, i.e., a cycle without chords. Clearly, such a cycle cannot visit all 2 n vertices, and the problem is to determine the maximum length c(n) of a coil-in-the-box for each dimension n. For n = 1, . . . , 8, the exact values of c(n) are known to be 0, 4, 6, 8, 14, 26, 48, 96 [OEIS A000937], and an optimal solution for n = 8 is shown in Figure 3 (a). In the literature one also encounters induced paths in the n-cube, which we call snakes-in-the-box (in some papers, the term snake is used to refer to an induced cycle, not to an induced path). The maximum length of a snake is denoted s(n) and for n = 1, . . . , 8 the exact values of s(n) are 1, 2, 4, 7, 13, 26, 50, 98 P14 Clearly, we have s(n) ⩾ c(n) − 2, but this leaves open whether s(n) dominates c(n) or vice versa for larger values of n. Kautz [Kau58] discovered coil-in-the-box and snake-in-the-box codes for single bit error detection in digital circuits, and he established simple lower and upper bounds for c(n). He also determined the exact values of c(n) for n ⩽ 5. Subsequently, Davies [Dav65], Kochut [Koc96], and Östergård and Pettersson [ÖP14] established the optimality of various coils for n = 6, 7, 8, respectively, by exhaustive search. The candidate of length 96 for n = 8 shown in Figure 3 (a) had already been found by Paterson and Tuliani [PT98]. There was also much effort towards proving good asymptotic bounds for c(n) as n grows. The best known upper bound is due to Zémor [Zém97], who showed that for all n ⩾ 1. This bound improves upon earlier results due to Douglas [Dou69], Deimer [Dei85], and Snevily [Sne94]. As far as lower bounds are concerned, Evdokimov [Evd69] first established that c(n) ⩾ λ2 n−1 for λ := c(8)/256 = 0.375, i.e., there are coils that miss only a constant fraction of all vertices of the n-cube, a fact that is maybe not apparent from the first few values of c(n). Wojciechowski [Woj89] independently proved a similar bound, but with a slightly worse (i.e., smaller) constant. The best known lower bound is due to Abbott and Katchalski [AK91], who showed that one can take λ := 77/128 > 0.601 for n ⩾ 2, following up on their earlier paper [AK88]. P15 Consequently, the most interesting open problem is whether c(n) ⩽ λ2 n−1 for some constant λ < 1 (and large n). Evdokimov summarizes many of these results in his survey [Evd14] (in Russian).

Factor-avoiding strings
For any fixed bitstring τ , we consider all bitstrings of length n that avoid τ as a factor, i.e., that do not contain τ as a contiguous substring.
We say that a string τ is bifix-free if none of its proper prefixes equals one of its proper suffixes. Squire [Squ96] showed that if τ is bifix-free, or if τ = σσ · · · σ for some bifix-free string σ, then for all n ⩾ 1 there is a Gray code for all bitstrings of length n that avoid τ . If τ does not satisfy these conditions, then for infinitely many n ⩾ 1 there are balancedness problems that prevent the existence of a Gray code. Liu, Hsu and Chung [LHC94] constructed Gray codes for Fibonacci words, i.e., bitstrings that avoid the factor τ = 1 ℓ for some fixed integer ℓ ⩾ 2. Subsequently, Vajnovszki [Vaj01] presented a simple genlex Gray code for Fibonacci words; see Figure 3 (b) and also [MS05]. Chinburg, Savage and Wilf [CSW99] consider bitstrings in which any two 1s are at least d ⩾ 2 positions apart. For d = 2 these are precisely Fibonacci words (with ℓ = 2), and the paper describes the same genlex Gray code as Vajnovszki for this case. For d ⩾ 3, they showed that balancedness problems rule out the existence of a (1-)Gray code, and they construct a 2-Gray code that uses single bitflips or transpositions of a 0 and 1; see also [BMdS09]. Baril, Kirgizov and Vajnovszki [BKV22] consider bitstrings in which every maximal run of b consecutive 1s that is not a suffix is followed by a run of strictly more than b/q consecutive 0s, where q ⩾ 1 is some integer parameter. They call these strings q-decreasing words, and show that they are in bijection to Fibonacci words with ℓ = q + 1. Furthermore, they present a 3-Gray code for any q ⩾ 1, shown in Figure 3 (e11') for n = 8 and q = 1, and a 1-Gray code for q = 1. They also conjecture that a 1-Gray code exists for all q ⩾ 1 and n ⩾ 1.
Baril and Vajnovszki [BV05] constructed a genlex Gray code for Lucas words, i.e., bitstrings that avoid the factor τ = 1 ℓ for some ℓ ⩾ 2, where factors that cyclically wrap around the boundary are also avoided; see Figure 3 (b'). It is a 1-Gray code if ℓ + 1 does not divide n, and a 2-Gray code otherwise. In the latter case, a 1-Gray code does not exist because of balancedness problems.
The subgraph of the n-cube induced by Fibonacci words or Lucas words for ℓ = 2 is known as Fibonacci cube [Hsu93] or Lucas cube [MPCZS01], respectively, and the number of those words are given by the Fibonacci numbers [OEIS A000045] or Lucas numbers [OEIS A000204].
Bernini et al. [BBP + 15] showed that for 'almost all' factors τ , the sublist of the BRGC induced by all τ -avoiding words is a 3-Gray code for all n ⩾ 1; see Figure 3 (c). Specifically, this holds for every τ that is not a suffix of · · · (110 ℓ )(110 ℓ )0 with at least two 1s for some ℓ ⩾ 0. This is a surprisingly general result, given that for every possible length ℓ of the forbidden factor, all but ℓ − 2 factors τ ∈ {0, 1} ℓ satisfy this condition. These Gray codes are all cyclic, except if τ = 0 ℓ for ℓ ⩾ 2 or τ = 10 ℓ for ℓ ⩾ 1, in which case they are non-cyclic 1-Gray codes. For τ = 0 ℓ these are complements of Fibonacci words, so we recover Vajnovszki's aforementioned result. Moreover, for τ ∈ {0 ℓ 1 | ℓ ⩾ 1} they are (cyclic) 2-Gray codes. As the BRGC is genlex, all these sublist Gray codes are also genlex.
Note that any factor τ that ends with 1 trivially satisfies the aforementioned condition of Bernini et al. On the other hand, if τ ends with 0, then we may simply consider the complemented factor τ , which does ends with 1. Consequently, we get a 3-Gray code for τ , and complementing all of its bitstrings we obtain a 3-Gray code for τ ; see Figure 3 (c'). Combining these observations we see every factor τ admits a 3-Gray code for all τ -avoiding bitstrings.
Many of these results were later generalized substantially via flip languages discussed in Section 3.18. In that section, we will consider the BRGC with each bitstring reversed, which corresponds to factors starting (and not ending) with a particular symbol.

Necklaces and relatives
In this section we consider equivalence classes of bitstrings under shifts, reversal and/or complementation; see Figure 4. A necklace is an equivalence class of bitstrings under cyclic shifts. A necklace of n-bit strings is called aperiodic if it has size n, i.e., all n cyclic shifts are distinct strings. The lexicographically smallest representatives of aperiodic necklaces are called Lyndon words. A necktie is an equivalence class of bitstrings under reversal, and a bracelet is an equivalence class under cyclic shifts and reversal. The goal is to find a Gray code that visits each equivalence class exactly once, where we may also impose restrictions on the choice of representatives, such as for example the lexicographically smallest one from each class.
Vajnovszki [Vaj07] showed that the sublists of the BRGC given by lexicographically largest representatives of necklaces, aperiodic necklaces or bracelets form a cyclic 3-Gray code; see Figure 3 (d1)-(d3). If we are interested in the lexicographically smallest representatives, we can apply complementation to the strings in those Gray codes. Weston and Vajnovszki [WV06] generalized these results for necklaces and aperiodic necklaces to larger alphabets. It turns out we can do even better by reversing each string in the BRGC. While this does not change the order of the (reversed) strings among each other, we will change the choice of representatives, which results in a different sublist. Specifically, Vajnovszki [Vaj08] showed that the sublist approach applied to the BRGC with reversed strings gives a cyclic 2-Gray code for lexicographically smallest representatives of necklaces and aperiodic necklaces, in particular for Lyndon words; see Figure 3 (e1)+(e2). He also obtains a cyclic 3-Gray code for subsets of these two classes, namely for strings that are lexicographically smallest under cyclic shifts and complementation, which he calls unlabeled necklaces and unlabeled Lyndon words; see Figure 3 (e1')+(e2'). As all of these Gray codes are sublists of the BRGC, they are clearly genlex. Sawada, Williams and Wong [SWW17] gave a constant amortized-time algorithm for Vajnovszki's Gray codes. The aforementioned results for necklaces, Lyndon words and their unlabeled variants can be generalized substantially via flip languages and flip-swap languages discussed in the next section.
For even values of n, a 1-Gray code for necklaces does not exist due balancedness problems (regardless of the choice of representatives); see [WS96]. However, for odd values of n this problem is still open: P17 Is there a 1-Gray code for necklaces of length n for odd n? Note that 0 n and 1 n must be the first and last necklaces in such a Gray code, so the code cannot be cyclic. The choice of representatives in this problem is arbitrary, ideally of course they are the lexicographically smallest ones. Savage conjectured [Sav97] that the answer to this question is 'yes' (even in the more general setting of necklaces of b-ary strings for any b ⩾ 2, when the flip operation is to change one entry by ±1).  Figure 3 (f) shows this 1-Gray code for n = 7. Note that for prime n, all necklaces except 0 n and 1 n are aperiodic. As explained in Section 3.12, certain cyclic 1-Gray codes for all necklaces except 0 n and 1 n would yield optimal single-track Gray codes for prime n.
Wang [Wan93] proved that there is a Gray code for the lexicographically smallest representatives of neckties if and only if n ⩾ 3 is odd. A simple inductive construction of a necktie Gray code N n for odd n is given by N 1 := 0, 1 and N n := 0N n−2 0, 0 rev(M n−2 )1, 1N n−2 1, where M n is any Gray code for all bitstrings of length n starting with 0 n and ending with 1 n , for example the aforementioned monotone Gray code due to Savage and Winkler; see Figure 3 (g). P18 No 2-or 1-Gray code is known for bracelets; see [Sav97]. Balancedness problems rule out a 1-Gray code for even n.
Is there a Gray code for unlabeled neckties, i.e., strings under reversal and complementation, or for unlabeled bracelets, i.e., strings under cyclic shifts, reversal and complementation?

Flip-swap languages
A flip-swap language is a subset S of bitstrings of length n such that S is closed under the following two operations (when applicable): (i) flipping the leftmost 1; (ii) transposing the leftmost 1 with the bit to its right. If operation (ii) is omitted, we call S a flip language.
Examples of flip-swap languages include all bitstrings, necklaces (lex. smallest representatives) and Lyndon words, strings with weight ⩽ ℓ, strings that avoid the factor 10 ℓ for some fixed integer ℓ ⩾ 1, strings with ⩽ ℓ inversions w.r.t. 0 * 1 * , strings with ⩽ ℓ transpositions w.r.t. 0 * 1 * , strings that are lexicographically ⩽ some fixed string, and strings that are < or ⩽ their reversal (in particular, lex. smallest neckties). The number of inversions w.r.t. 0 * 1 * of a bitstring is the number of pairs of bits ( 0), and the number of transpositions w.r.t. 0 * 1 * is the minimum number of exchanges of a 1 and 0 so that all 0s are left of all 1s.
Clearly, every flip-swap language is also a flip language. Examples of flip languages that are not already mentioned before are unlabeled necklaces (lex. smallest representatives) and unlabeled Lyndon words, strings that avoid any factor τ starting with 1, and q-decreasing words discussed in Section 3.16 for any q ⩾ 1. Vajnovszki [Vaj07] proved that for the BRGC with reversed bitstrings, the sublist induced by the strings of any flip language forms a cyclic 3-Gray code; see Figure 3 (e1'), (e2') and (e9')-(e11'). Sawada, Williams and Wong [SWW21] strengthened this by showing that the sublist induced by the strings of any flip-swap language forms a cyclic 2-Gray code; see Figure 3 (e1)-(e8).
Note that complementing a flip-swap language 2-Gray code yields a 2-Gray code for the complemented flip-swap language, for example strings with weight ⩾ ℓ, necklaces and aperiodic necklaces with lexicographically largest representatives, strings that avoid 01 ℓ , strings that are ⩾ some fixed string, and strings that are > or ⩾ their reversal (in particular, lex. largest neckties). Similarly, complementing a flip language 3-Gray code yields a 3-Gray code for the complemented flip language, for example unlabeled necklaces and aperiodic necklaces with lexicographically largest representatives, and strings that avoid any factor τ starting with 0.
Observe furthermore that for any two flip(-swap) languages S and S ′ , the intersection S∩ S ′ and the union S ∪ S ′ are also flip(-swap) languages. For example, Lyndon words that are ⩽ their reversal are a flip-swap language. Similarly, words avoiding any number of distinct factors all starting with 1 are a flip language. As an application, recall that Chinburg, Savage and Wilf [CSW99] considered bitstrings in which any two 1s are at least d ⩾ 2 positions apart. Those are characterized by avoiding the factors {11, 101, 1001, . . . , 10 d−2 1}, which is a flip language, so we immediately obtain a 3-Gray code for this problem, shown in Figure 3 (e9') for d = 2 (as mentioned before, this can be improved by a 2-Gray code tailored to this problem).
Taking intersections of flip languages enables us to consider avoidance of factors that contain wildcard symbols * , which can match both 0 or 1, also known partial words. For example, the factor 10 * stands for '10 followed by another arbitrary symbol', and it can be modelled by avoiding both {100, 101}; see Figure 3 (e10').

Larger alphabets
The definition of BRGC can be generalized straightforwardly to larger alphabets, which yields a listings of all b-ary strings of length n where only one of the entries changes by ±1 at a time: Γ 0 := ε and Γ n+1 := 0Γ n , 1 rev(Γ n ), 2Γ n , 3 rev(Γ n ), . . . , Recently, Herter and Rote [HR18] devised loopless algorithms for generating b-ary Gray codes based on generalizations of the Tower of Hanoi puzzle. Flahive [Fla08] describes a construction of balanced b-ary Gray codes with transitions counts that differ by at most 2 from the average b n /n, improving upon the earlier paper by Flahive and Bose [FB07]. P20 Many other of the properties discussed before for the binary case (weight-monotonicity, runs lengths, trend-freeness, single-track etc.) are still unexplored for the general b-ary case.
A signed binary representation (SBR) of an integer N is a string (a n−1 , . . . , a 1 , a 0 ) over the alphabet {−1, 0, 1} such that N = n−1 i=0 a i 2 i . An SBR is said to be minimal if the number of nonzero digits is minimum. Some values of N have only a single minimal SBR, whereas other values admit an exponential (in n) number of minimal SBRs. Sawada [Saw07] developed a genlex 3-Gray code for listing all minimal SBRs of an integer N .

Combinations
Combinations are the subsets of the ground set [n] of fixed size k, where 0 ⩽ k ⩽ n. We sometimes refer to them as (n, k)-combinations, and their number is n k . In a computer an (n, k)-combination can be conveniently represented by its characteristic vector x = (x 1 , . . . , x n ), i.e., x i = 1 if i is in the set and x i = 0 otherwise. Clearly, x contains precisely k many 1s, i.e., x has weight k.
In this section, we discuss Gray codes for combinations that use different flip operations, as well as Gray codes for restricted classes of combinations, including necklaces and Catalan objects (the latter can be seen as special (2k, k)-combinations). Lastly, we consider more general Gray codes that list bitstrings for certain admissible weight values and weight ranges, and also some generalizations and variants of combinations.

Transpositions
We first focus on transposition Gray codes or revolving door Gray codes for combinations, i.e., any two consecutive combinations differ by swapping a 0 and 1 in the bitstring representation. Tang and Liu [TL73] showed that restricting the binary reflected Gray code (BRGC) for bitstrings of length n to any fixed weight k yields a cyclic transposition Gray code for (n, k)-combinations; see Figure 5 (a). The resulting listing is genlex, and its ordered set representation has the interesting property that for any sublist with the same fixed prefix the next larger element is always non-decreasing or non-increasing, alternatingly depending on the parity of the prefix length, which leads to an efficient generation algorithm; see [PI79] and [Knu11, Sec. 7.2.1.3]. Bitner, Ehrlich and Reingold [BER76] devised a loopless algorithm to generate this ordering. The flip graphs of (n, k)-combinations under arbitrary transpositions are known as Johnson graphs J(n, k), which were shown to be Hamilton-connected by Jiang and Ruskey [JR94] and by Knor [Kno94]; see Figure 1 (b) and also [Als13].
Chase [Cha70a] and Eades and McKay [EM84] constructed so-called homogeneous Gray codes for combinations, which use only transpositions of the form 00 · · · 01 ↔ 10 · · · 00, i.e., the bits between the swapped 0 and 1 are all 0s; see Figure 5 (b). We can think of this as an ordering that plays all possible combinations of k keys out of n available keys on a piano, without ever crossing any fingers. Their homogeneous Gray code also has the genlex property. Chase [Cha89] showed that we can restrict the allowed swaps further and only allow transpositions of the form 01 ↔ 10 or 001 ↔ 100, and this listing is also genlex and can be implemented efficiently; see Figure 5 (c) and also [Rus93,JM95]. Buck and Wiedemann [BW84] and Eades, Hickey and Read [EHR84] independently proved that all (n, k)-combinations can be generated by using only adjacent transpositions 01 ↔ 10 if and only if k ∈ {0, 1} or n − k ∈ {0, 1} or k and n − k are both odd; see Figure 5 (d). Note that such a Gray code must start and end at the combinations 1 k 0 n−k and 0 n−k 1 k , as these admit only a single transposition (they are degree-1 vertices in the corresponding flip graph). An efficient algorithm to compute the Eades-Hickey-Read ordering was provided by Hough and Ruskey [HR88], and an efficient algorithm for computing a distinct adjacent transposition listing was given by Ruskey [Rus88a]; see Figure 5 (d').
Extending earlier partial results of Joichi and White [JW80], Enns [Enn93] showed that (n, k)-combinations can be generated by circularly adjacent transpositions, i.e., including transpositions that swap the first and last bit, if and only if at least one of k or n − k is odd.
Felsner, Kleist, Mütze and Sering [FKMS20] showed that, for odd n, all (n, 2)-combinations can be generated by transpositions so that each of the n 2 possible transpositions is used exactly once. P21 They raised the question where such balanced Gray codes are possible for (n, k)-combinations in general, whenever n is odd and n 2 divides n k (it is easy to argue that for even n such Gray codes cannot exist). Their balanced Gray code for (n, 2)-combinations can be partitioned into n blocks, where each block is a cyclic right-shift of the previous one; see Figure 5 (h). Consequently, it is also a single-track Gray code in which column i is a cyclic shift of the first column by 1 n n 2 · (i − 1) for all i = 2, . . . , n.

Cool-lex order and bubble languages
Another elegant and efficient method for generating combinations based on prefix shifts was described by Ruskey and Williams [RW09], who named their ordering cool-lex, because of its similarities to colex and its numerous striking features. A prefix shift cyclically left-shifts a prefix of the bitstring by one position to generate the next combination. The following simple successor rule generates the next combination in the cool-lex ordering: Shift the shortest prefix of length at least 3 that ends with 01, or if no such prefix exists shift the entire string; see Figure 5 (g1) and cf. [SW14]. The cool-lex ordering is cyclic, any two consecutive combinations differ by one or two transpositions, and it admits simple loopless algorithms. Moreover, the ordering is genlex in the ordered set representation (but not in the bitstring representation).
Ruskey, Sawada and Williams [RSW12] present another major application of the coollex approach. They consider subsets B of (n, k)-combinations that are bubble languages, which means that if a string x is in B and x contains 01, then the string obtained from x by flipping the first such occurrence to 10 must also be in B. Examples of bubble languages include combinations, b-ary Dyck words, necklaces and aperiodic necklaces with lexicographically largest representatives, strings that avoid the factor 01 ℓ for some fixed integer ℓ ⩾ 1, strings with ⩽ ℓ inversions w.r.t. 1 * 0 * , strings with ⩽ ℓ transpositions w.r.t. 1 * 0 * , strings that are lexicographically ⩾ some fixed string, and strings that are > or ⩾ their reversal (all of these families are considered for a fixed number k of 1s). The number of inversions w.r.t. 1 * 0 * of a combination x = (x 1 , . . . , x n ) is the number of pairs of bits (x i , x j ) with i < j and (x i , x j ) = (0, 1), and the number of transpositions w.r.t. 1 * 0 * is the minimum number of exchanges of a 0 and 1 so that all 1s are left of all 0s. The main result of [RSW12] is that the words of any bubble language, when arranged in the order induced by the cool-lex order, form a cyclic Gray code in which any two consecutive strings differ by a left-shift of a substring by one position, which results in one or two transpositions; see Figure 5 (g2)-(g8) and Figure 6 (f2)+(f3). Note that complementing such a listing yields a shift Gray code for the complemented bubble language, for example necklaces and aperiodic necklaces with lexicographically smallest representatives (i.e., fixed-density Lyndon words), strings that avoid 10 ℓ , strings that are ⩽ some fixed string, and strings that are < or ⩽ their reversal. Observe furthermore that for any two bubble languages B and B ′ , the intersection B ∩ B ′ and the union B ∪ B ′ are also bubble languages. For example, b-ary Dyck words that avoid 01 ℓ are a bubble language. Following up on these results, Sawada and Williams [SW12a,SW13a] devised constant amortized-time algorithms for computing many of the aforementioned bubble language Gray codes.
P22 Is there a unifying principle behind flip-swap languages and bubble languages (recall Section 3.18)?
P23 Another interesting open question in this context is whether all (n, k)-combinations can be generated by prefix reversals, i.e., in each step, a prefix of the bitstring representation is reversed to obtain the next combination. Such orderings can be constructed easily for the cases k ∈ {1, 2} or n − k ∈ {1, 2}, but no general construction is known.

Fixed-density necklaces
We now consider equivalence classes of (n, k)-combinations under cyclic shifts, so-called necklaces with fixed density. Wang and Savage [WS96] devised a cyclic transposition Gray code, valid for all n and k. The representatives from each equivalence class are not the lexicographically smallest ones, but those rotated left until the first bit equals 1. Independently, Ueda [Ued00] described another transposition Gray code for necklaces with fixed density, and also a Gray code for aperiodic necklaces with fixed density. However, the chosen representatives in his two Gray codes are non-standard, in particular, they are neither the lexicographically smallest nor largest ones. He also established stronger Hamiltonicity properties about the underlying flip graphs.

Catalan objects
Dyck words are (2k, k)-combinations with the additional property that every prefix contains at most as many 0s as 1s. By interpreting the 1s as opening brackets and the 0s as closing brackets, we see that Dyck words are in bijection with well-formed parenthesis expressions with k pairs of parenthesis. They are also in bijection to preorder sequences of binary trees with k nodes, when recording a 1 for every internal node and a 0 for every leaf (the 0 corresponding to the last leaf being implicit). It is well known that they are counted by the kth Catalan number ]. Proskurowski and Ruskey [PR85] devised a transposition Gray code for Dyck words, and in a subsequent paper [RP90], they present a simpler genlex construction for this problem; see Figure 6 (a) and also [Wal98]. They also showed that an adjacent transposition Gray code exists if and only if k is even or k < 5; see Figure 6 (c). A homogeneous transposition Gray code for Dyck words, which is also genlex, was given by Bultena and Ruskey [BR98]; see Figure 6 (b). More generally, Roelants van Baronaigien [RvB00] developed a homogeneous transposition Gray code b-ary Dyck words, valid for any integer b ⩾ 2; see Figure 6 (d2)+(d3); see also [XUT00]. These are are strings with k many 1s and k(b − 1) many 0s such that in every prefix, the number of 0s is at most b − 1 times the number of 1s, which are in bijection to preorder sequences of b-ary trees. Vajnovszki and Walsh [VW06] present a genlex Gray code for this problem that is even more restrictive and uses only transpositions 01 ↔ 10 or 001 ↔ 100; see Figure 6 (e2)+(e3).
Ruskey and Williams [RW08] present a Gray code for Dyck words that uses prefix shifts, which cyclically left-shifts a substring that starts at the second position (the first bit clearly has to always be 1); see Figure 6 (f2). Any two consecutive words in this ordering differ by one or two transpositions, and the ordering has a very simple successor rule and loopless algorithm. Durocher, Li, Mondal, Ruskey and Williams [DLM + 12] generalized this construction to higher arity b ⩾ 2; see Figure 6 (f3).
Dyck words can be generalized to words with e flaws, where 0 ⩽ e ⩽ k is an integer parameter, which are (2k, k)-combinations with the property that precisely e prefixes ending with 0 have strictly more 0s than 1s. We denote them by F k,e . Clearly, F k,0 are Dyck words, and F k,k are complemented Dyck words. The well-known Chung-Feller theorem asserts that |F k,0 | = |F k,1 | = · · · = |F k,k | = 1 k+1 2k k = C k , i.e., the number of words with e flaws is the same for each possible value of e. Mütze, Standke and Wiechert [MSW18] constructed a bijection between F k,e and F k,e+1 , for any e = 0, . . . , k − 1, that uses only adjacent transpositions, and that maps any Dyck word in F k,0 to its complement in F k,k when applied k times. By combining this Gray code with any of the aforementioned transposition Gray codes for Dyck words, we obtain a transposition Gray code for (2k, k)combinations in which the number of flaws is alternatingly increasing and decreasing; see Figure 5 (f).
A Motzkin word with fixed content is a word over the alphabet {0, 1, −} with k many 1s, k many 0s, and a fixed number m of occurrences of −, with the property that every prefix contains at most as many 0s as 1s. Consequently, Motzkin words for m = 0 are Dyck words. Vajnovszki [Vaj02] presents a genlex Gray code for Motzkin words with fixed content that either transposes two symbols or permutes three symbols in each step; see Figure 6 (g). These can be combined into a Gray code for Motzkin words of fixed length with an arbitrary number of −s. Lapey and Williams [LW22] devised a shift Gray code for Łukasiewicz words with fixed content, which generalize both Dyck words and Motzkin words with fixed content. Further Gray codes for Catalan objects will be discussed in Sections 5.4, 5.5, 6.3 and 8.1.

Weight ranges
As discussed before, combinations can be represented by bitstrings of length n with weight k. On the other hand, in Section 3 we discussed Gray codes for all bitstrings of length n, irrespective of their weight. Generalizing both types of objects, we may consider bitstrings of length n whose weight is in some interval [k, ℓ], where 0 ⩽ k ⩽ ℓ ⩽ n. The corresponding flip graph, denoted by Q n, [k,ℓ] , is the subgraph of the n-cube induced by all levels from k to ℓ, where the kth level of Q n contains all bitstrings with weight k. The graph Q n, [k,ℓ] is clearly bipartite, and it is easy to show that the partition classes have the same size if and only if n is even and (k, ℓ) = (0, n), or n is odd and k + ℓ = n, i.e., the boundary levels k and ℓ are symmetric around the middle. Consequently, a Hamilton cycle in Q n, [k,ℓ] can only exist in one of those cases.
One of most intriguing instances of this problem is the middle levels conjecture, which asks for a Hamilton cycle in Q 2k+1,[k,k+1] for all k ⩾ 1, i.e., a Hamilton cycle in the middle two levels of the (2k + 1)-cube. This question was first raised by Havel [Hav83] and Buck and Wiedemann [BW84] independently, and it received considerable attention in the literature. The conjecture was answered affirmatively by Mütze [Müt16], who showed that there are in fact double-exponentially (in k) many distinct Hamilton cycles. Subsequently, a shorter and more accessible proof of the middle levels conjecture was presented by Gregor, Mütze and Nummenpalo [GMN18], which reduces the problem to finding a spanning tree in an auxiliary graph on plane trees. This construction was turned into a loopless algorithm by Mütze and Nummenpalo [MN20]. Consider a Hamilton cycle in the middle levels graph Q 2k+1, [k,k+1] , and prefix every bitstring of weight k with 1 and every bitstring of weight k + 1 with 0. Note that the resulting listing is a star transposition ordering of (2k + 2, k + 1)-combinations, i.e., in each step, the first bit is swapped with some later bit; see Figure 5 (e). Knuth [Knu11] raised a strengthened version of the middle levels conjecture, asking for a Hamilton cycle in Q 2k+1,[k,k+1] that can be partitioned into 2k + 1 blocks such that each block is a cyclic shift of the previous one (without the first column). Such an ordering has the property that any two of the columns 2, . . . , 2k + 2 of bits differ by a cyclic shift, i.e., it is a single-track Gray code, with the exception of the first column which is simply 101010 · · · . Furthermore, such a Hamilton cycle corresponds to a Gray code for necklaces of length 2k + 1 with weights k or k + 1. A general algorithmic solution for this problem was presented by Merino, Mička and Mütze [MMM22]; see Figure 5 (e'). Moreover, the middle levels graph Q 2k+1, [k,k+1] was shown to be Hamilton-laceable by Gregor, Merino and Mütze [GMM22b]. While the algorithms described in [MN20] and [MMM22] solve the middle levels problem and its strengthened version efficiently, these algorithms are admittedly rather complicated. It remains open to find a simple algorithm for solving either of these problems, ideally in the form of a successor rule. The authors of [MMM22] offer a reward of 2 5 EUR for an algorithm that can be implemented with at most 4000 ASCII characters of C++ code.
The more general central levels problem asks for a Hamilton cycle in Q 2k+1,[k−c,k+1+c] for all k ⩾ 1 and 0 ⩽ c ⩽ k. This problem was raised independently by Buck and Wiedemann [BW84], Savage [Sav93], Gregor and Škrekovski [GŠ10], and by Shen and Williams [SW19]. A solution for the case c = k (all levels) is given by the BRGC. The case c = k − 1 (all levels except the two extreme vertices) was solved by Buck and Wiedemann [BW84] and in a more general setting by Locke and Stong [LS03]; see also [EHH01]. Gregor and Škrekovski [GŠ10] solved the case c = k − 2 (all levels except the top two and bottom two). The case c = 0 (middle two levels) follows from the (a0) (a1) (a2) (a3) (b0) (b1) (b2) (b3) (c1) (c2) (c3) (c4) (d) (e) Coming back to the most general version of the problem about Q n, [k,ℓ] , Gregor and Mütze [GM18] showed that for all n ⩾ 3 and 0 ⩽ k ⩽ ℓ ⩽ n, in those cases where the partition classes of Q n, [k,ℓ] have different sizes, the graph admits a saturating cycle and a tight enumeration, where a saturating cycle is a cycle in Q n, [k,ℓ] that visits all vertices in the smaller partition class, and a tight enumeration is a cyclic listing of the bitstrings in both partition classes, flipping a single bit in most steps, and exchanging a 0 and 1 in d steps, where d is the difference in size between the partition classes (the steps flipping two bits are within the larger partition class). Saturating cycles and tight enumerations are natural generalizations of Hamilton cycles for bipartite graphs whose partition classes are not necessarily of the same size. Several of the weight range Gray codes devised in [GM18] are obtained by considering sublists of the BRGC within an interval [k, ℓ].
A Boolean layer cake [Sch99] is obtained from Q n by selecting any subset of complete levels (not necessarily consecutive), connecting any two vertices in subsequent levels by an edge if they are connected by a weight-monotone path in Q n (equivalently, if the vertices are from subsequent levels k and ℓ, the path has length |k − ℓ|). Obviously, the graph Q n, [k,ℓ] is the Boolean layer cake obtained by selecting all levels k, k + 1, . . . , ℓ.
P26 It is open which Boolean layer cakes admit Hamilton cycles, or more generally, saturating cycles and tight enumerations.
Stevens and Williams [SW14] modified the aforementioned cool-lex successor rule for combinations to be able to generate all bitstrings of length n as follows: Shift the shortest prefix of length at least 3 that ends with 01, or if no such prefix exists complement the first bit and shift the entire string; see Figure 7 (b3). Moreover, they generalized the rule even further so as to generate all bitstrings with weight in the interval [k, ℓ] by prefix shifts: Shift the shortest prefix of length at least 3 that ends with 01, or if no such prefix exists, complement the first bit if this keeps the weight in the interval [k, ℓ], and then shift the entire string; see Figure 7 (b0)-(b3). In the resulting cyclic Gray codes, any two consecutive bitstrings differ in at most 4 positions.

Bipartite Kneser graphs and Kneser graphs
For integers k ⩾ 1 and n ⩾ 2k + 1, the bipartite Kneser graph H(n, k) has as vertices all k-element and (n − k)-element subsets of [n], and an edge between a set A of size k and a set B of size n − k if A ⊆ B. Considering the characteristic vectors of those subsets, we see that H(n, k) is isomorphic to the Boolean layer cake given by levels k and n − k in the n-cube. In particular, H(2k + 1, k) is isomorphic to the middle levels graph Q 2k+1,[k,k+1] . Hurlbert [Hur94] and Roth (see [Gou91]) conjectured that H(n, k) has a Hamilton cycle for all k ⩾ 1 and n ⩾ 2k + 1. This conjecture was proved by Mütze and Su [MS17], using an inductive construction in Q n that uses the middle levels theorem as a base case. Rephrased in terms of a Gray code, this result asserts that all k-element and (n−k)-element subsets of [n] (i.e., (n, k)-and (n, n − k)-combinations) can be listed cyclically, so that we alternatingly move to a subset or a superset of the current set. The construction from [MS17] has the additional property that any two consecutive k-sets, which occur after every two steps, differ only in exchanging one element; see Figure 7 (c1)-(c4).
For integers k ⩾ 1 and n ⩾ 2k+1, the Kneser graph K(n, k) has as vertices all k-element subsets of [n], and an edge between any two disjoint sets. The Kneser graphs K(2k + 1, k) are also known as odd graphs O k . A Hamilton cycle in the Kneser graph corresponds to a cyclic listing of all k-element subsets of [n] (i.e., (n, k)-combinations), such that any two consecutive sets are disjoint. P27 It has long been conjectured that all Kneser graphs K(n, k) have a Hamilton cycle, with one notable exception, the Petersen graph K(5, 2) = O 2 ; see Figure 1 (c). For the odd graphs this conjecture was raised by Meredith and Lloyd [ML72,ML73] and Biggs [Big79], even in the stronger form that O k admits ⌊(k+1)/2⌋ edge-disjoint Hamilton cycles. The best known general result is due to Chen [Che03] who showed that K(n, k) has a Hamilton cycle whenever n ⩾ 2.62k + 1. Her construction uses Baranyai's well-known partition theorem for complete hypergraphs. Moreover, Mütze, Nummenpalo and Walczak [MNW21] proved that the odd graphs O k = K(2k + 1, k) have a Hamilton cycle for all k ⩾ 3 (even double-exponentially many distinct ones), using as a starting point the cycle factor in O k from [MSW18] whose cycles all have the same length k + 1; see Figure 7 (d). Combined with an inductive construction of Johnson [Joh11], their result implies that K(2k + 2 a , k) has a Hamilton cycle for all k ⩾ 3 and a ⩾ 0. Maybe the first interesting unknown case is K (2k + 3, k).
For integers k ⩾ 1, 0 ⩽ t ⩽ k − 1, and n ⩾ 2k + 1 if t = 0 or n ⩾ 2k − t if t > 0, the uniform subset graph U (n, k, t) has as vertices all k-element subsets of [n], and an edge between any two sets whose intersection has size t. By taking complements, we see that U (n, k, t) is isomorphic to U (n, n − k, n − 2k + t). For t = 0 this precisely gives the Kneser graphs. For t = k − 1 we get the flip graphs of (n, k)-combinations under transpositions, the Johnson graphs J(n, k). For this reason uniform subset graphs are also known as generalized Johnson graphs in the literature. The graphs U (n, k, t) were introduced by Chen and Lih [CL87], who conjectured that they all have a Hamilton cycle, except the Petersen graph, which arises as U (5, 2, 0) or U (5, 3, 1) (cf. [Gou91]). A solution of this conjecture for the case t = k − 1 follows from the transposition Gray codes for (n, k)-combinations presented earlier. In addition to this, Chen and Lih settled the cases t = k − 2 and t = k − 3 in their paper.
Note that bipartite Kneser graphs, Kneser graphs and uniform subset graphs are all vertex-transitive, so they are interesting instances of Lovász' conjecture mentioned in Section 2.7.

Other generalizations and variants
Combinations are generalized by bounded integer compositions, and Gray codes for those are discussed in Section 7.2.
Joichi, White and Williamson [JWW80] consider classes of combinatorial objects that satisfy the two-parameter recursion C n,k = a n,k · C n−1,k−1 + b n,k · C n−1,k , which includes (n, k)-combinations (for a n,k = b n,k = 1), set partitions of [n] into k parts, permutations of [n] with k cycles, and permutations of [n] with k runs. These objects are in bijective correspondence with monotone paths in the integer grid from (0, 0) to (n − k, k), where the steps have edge-multiplicities as specified by the coefficients a n,k and b n,k , i.e., they are described by an (n, k)-combination for the path, and an additional word of length n that describes which of the multi-edges are taken. The paper describes a general Gray code scheme for these pairs of strings, obtained from fusing a combination Gray code with a straightforward product space Gray code.
A numerical semigroup is a subset S of the non-negative integers N such that 0 ∈ S, N \ S is finite, and a, b ∈ S implies that a + b ∈ S. The numbers in G := N \ S are referred to as gaps of the semigroup, and the quantity g := |G| = |N \ S| is referred to as its genus. For any semigroup with genus g, we have max G < 2g, so any such semigroup can be represented as a (2g, g)-combination by considering the first 2g entries of the characteristic vector of G.
P29 Is there a Gray code for numerical semigroups of genus g, represented as (2g, g)-combinations, for every g ⩾ 1? Figure 7 (e) shows a solution for g = 7. An easier general question could be: Is the corresponding flip graph connected? These problems are interesting, as for the counting sequence of numerical semigroups with genus g, even basic facts such as monotonicity in g are not proved; see [BA08] and [OEIS A007323].

Permutations
In this section we first discuss Gray codes for listing all n! permutations of [n] = {1, 2, . . . , n} using different flip operations. We then discuss Gray code for interesting subsets of permutations, obtained by imposing additional constraints. Lastly, we discuss Gray codes for generalizations and variants of permutations.

Transpositions
Possibly the most basic operation on a permutation is a transposition, i.e., the exchange of two entries of the permutation. Transposition Gray codes for permutations can be constructed inductively by appending an additional symbol in all possible ways to a Gray code with one symbol less, using transpositions with the newly appended symbol at the transitions between blocks, which yields a genlex ordering. Wells [Wel61] devised an explicit rule for producing such a transposition ordering of permutations; see Figure 8 (a). Another simple rule was found by Heap [Hea63], which is to perform the ith transposition involving the entry at position n in a block with the first entry if n is odd, and with the ith entry if n is even; see Figure 8 (b). Lipski [Lip79] considerably generalized the methods proposed by Wells and Heap, and came up with an entire family of transposition Gray codes for permutations, two of which are shown in Figures 8 (c)+(c'); see [Arn11].
The famous Steinhaus-Johnson-Trotter (SJT) algorithm generates permutations by adjacent transpositions, i.e., transpositions of neighboring entries of the permutation; see Figure 1 (d) and Figure 8 (d). This ordering can also be constructed inductively, but instead of appending an additional symbol in all possible ways, we insert the new symbol in all possible ways from right to left alternatingly. This algorithm was discovered independently by Trotter [Tro62] and Johnson [Joh63], and is also implicit in a book by Steinhaus [Ste64,, where he describes a puzzle about generating all permutations of beads on an abacus. The SJT algorithm is also known as the method of plain changes; see Knuth's book [Knu11, Sec. 7.2.1.2] for the historical origins of this algorithm in the art of change ringing of church bells. Ehrlich gives a loopless implementation of the SJT algorithm [Ehr73a,Ehr73b]. Sedgewick [Sed77] provides an insightful analysis and fair comparison of the computational efficiency of several permutation generation algorithms; see also Arndt's book [Arn11].
Compton and Williamson's [CW93] doubly-adjacent Gray code is an ordering of permutations by adjacent transpositions with the additional property that for any two consecutive transpositions (i, i + 1) and (j, j + 1), we have |i − j| = 1; see Figure 8  Shen and Williams [SW13b] constructed a 'hot potato' Gray code for permutations, where the value 1 moves in each step, and it moves by circularly adjacent or semi-adjacent transpositions, i.e., transpositions of the form (i, i+1) or (i, i+2) modulo n; see Figure 8 (g). We can think of the value 1 as being the hot potato that is passed around in a circle of n children, and it is always passed to a neighbor in distance 1 or 2 along the circle. By considering the inverse permutations of this ordering, the meaning of values and positions is exchanged, so we obtain a star transposition ordering of permutations (the entry at position 1 changes in each step), with the additional property that the value at position 1 always changes by ±1 or ±2 modulo n; see Figure 8 (g −1 ) and cf. Figure 8 (

f). Shen and Williams' construction uses the aforementioned doubly-adjacent Gray code of Compton and Williamson as a building block.
The parity of a permutation π is the parity of the number of its inversions, where an inversion is a pair (π(i), π(j)) with i < j and π(i) > π(j). Equivalently, the parity of π is given by the parity of the number of transpositions whose product is π. Alternatively, the parity of π is the parity of n minus the number of cycles of π. Note that every transposition changes the parity of a permutation.
For a particular set of admissible transpositions, we consider the transposition graph on the vertex [n], which contains as edges all admissible transpositions (i, j). For adjacent transpositions, the transposition graph is a path, whereas for star transpositions, the transposition graph is a star. Clearly, to be able to generate all permutations by a set of transpositions, the transposition graph must be connected. Kompel'maher and Liskovec [KL75] and Slater [Sla78] independently generalized the aforementioned results considerably by proving that all permutations of [n] can be generated for any transposition tree on [n]. Even more generally, Tchuente [Tch82] showed that for any transposition tree on [n], n ⩾ 4, and for any two permutations of opposite parity, there is a transposition Gray code starting and ending with the two chosen permutations. As every transposition changes the parity, any transposition Gray code lists permutations with even and odd parity alternatingly. In graph-theoretic language, the underlying flip graph for any tree of transpositions is bipartite, and Tchuente's result asserts that it is Hamilton-laceable; see also [XM09,Sec. 12].
Ruskey and Savage [RS93] showed that for any transposition tree on [n], n ⩾ 5, and any fixed transposition from that tree, there is a transposition Gray code that uses this fixed transposition in every second step. In other words, the fixed transposition induces a perfect matching in the corresponding flip graph, and this perfect matching extends to a Hamilton cycle, i.e., the cycle alternatingly uses matching and non-matching edges. Their Gray code for a path and star on n = 5 vertices and for the fixed transposition (1, 2) is shown in Figures 8 (h) and (h'), respectively. P30 Felsner, Kleist, Mütze and Sering [FKMS20] raised the question whether there is a transposition Gray code for permutations that uses each of the n 2 transpositions equally often; see Figure 8 (i). This is the analogue of balancing the transition counts in Gray codes for binary strings; recall Section 3.2. The same question arises naturally for permutations and n − 1 adjacent transpositions. Gregor, Merino, and Mütze [GMM22a] constructed a permutation Gray code for odd n that uses each of the n circularly adjacent transpositions equally often; see Figure 8 (i').

Reversals, shifts and other generators
Ord-Smith [Ord67] devised a method to generate all permutations by prefix reversals; see Figure 8 (j). His listing also has the genlex property, and the average length of reversed prefixes approaches e = 2.71828 . . . (a constant, which allows for an efficient algorithm). This ordering was rediscovered by Zaks [Zak84], who was motivated by sorting problems involving stacks of pancakes; see also [XM09,Sec. 11]. A prefix reversal corresponds to flipping over some of the pancakes at the top of the stack. In the following, we write ρ k for the operation that reverses the first k entries of a permutation, i.e., in cycle notation we have ρ k := (1 k)(2 k − 1) · · · .
Prefix shifts have also been investigated heavily for permutation generation. Unlike transpositions and prefix reversals discussed before, prefix shifts are in general not involutions. Formally, for any 2 ⩽ k ⩽ n, we write σ k for the operation that cyclically left-shifts the first k entries of a permutation by one position, i.e., σ k = (k k − 1 · · · 2 1). Note that σ 2 = ρ 2 simply transposes the first two entries. Corbett [Cor92] showed that all permutations can be generated cyclically by prefix shifts of arbitrarily length, i.e., using the generators {σ n , σ n−1 , . . . , σ 2 }; see Figure 8 (k). Compton and Williamson [CW93], as an application of their doubly-adjacent Gray code, showed that we can also use the generators {σ n , σ −1 n , σ 2 }. Stevens and Williams [SW12b] showed the same result for the generators {σ n , σ 3 , σ 2 }, and Ruskey and Williams [RW10] proved it for {σ n , σ n−1 }; see Figure 8 (l). In a recent breakthrough, Sawada and Williams [SW20] give a simple and explicit rule to generate all permutations of length n using only the two generators {σ n , σ 2 }, and this listing is cyclic if and only if n is odd; see Figure 1 (e) and Figure 8 (m). This problem was known as sigma-tau problem, and was first mentioned in Nijenhuis and Wilf's book [NW75,Ex. 6]. All of the preceding results mentioned in this paragraph assert the existence of Hamilton paths or cycles in the Cayley digraph #" Γ (S n , X) for various sets X of shifts as generators.
Savage [Sav90] showed that for any n ⩾ k ⩾ 2 and k ̸ = 3, all permutations of length n can be listed cyclically so that consecutive permutations differ in exactly k positions. For k = n such a listing is sometimes called a derangement order. Figure 8 (o) shows an example for this, using a construction due to Yarbrough described in [Sav97]. Rasmussen and Savage [RS94a] later generalized this result considerably, by showing that the corresponding flip graph is Hamilton-connected, even if we impose the additional constraint that the k modified positions are consecutive. P31 Despite all of the aforementioned results, in general it is wide open for which sets of generators X the Cayley graph Γ(S n , X) or the Cayley digraph #" Γ (S n , X) have a Hamilton cycle or path. Generalizing the sigma-tau problem, we may consider X = {σ n , (1 k)} or X = {σ n , σ k } for suitable values of n and 2 ⩽ k ⩽ n. Specifically, the case X = {σ n , σ 3 } for even n was suggested by Stevens and Williams [SW12b]. Furthermore, Savage [Sav97] mentions X = {ρ n , ρ n−1 , (n − 1 n)} as an interesting open problem. Lastly, Bass and Sudborough [BS03] and Sawada and Williams [SW16b] suggest the instances X = {ρ n , ρ n−1 , ρ n−2 } and X = {ρ n , ρ n−1 , ρ 2 }.

Restricted permutations
Even permutations are permutations with even parity, i.e., with an even number of inversions. As mentioned before, any transposition Gray code visits permutations with even and odd parity alternatingly, so from any transposition Gray code for all permutations we can obtain a 2-transposition Gray code for even permutations (or odd permutations, or permutations with an even number of cycles, or an odd number of cycles); cf. [VV11]. Savage [Sav90] showed that they can be listed by applying a 3-rotation, i.e., a product of two transpositions that share one element, in each step. Recall that each transposition changes the parity, so single transpositions cannot be used. Her listing is shown in Figure 9 (a), and it is genlex. She also came up with a listing that uses only 3-rotations of consecutive entries, to the left or right by one position if the middle entry is at an odd or even position, respectively (these are only n − 2 different operations in total). This listing is described in [Knu11, Ex. 103 in Sec. 7.2.1.2], and it is shown in Figure 9 (a'). Gould and Roth [GR87] proved that for n ⩾ 5 all even permutations can be listed cyclically by 3-rotations of the form (1 i n) for some 1 < i < n, i.e., in every step, the first, ith and last entry of the permutation rotate cyclically; see Figure 9 (a"). Equivalently, their result asserts that for n ⩾ 5 the Cayley digraph #" Γ (A n , X) of the alternating group A n with generators X = {(1 i n) | 1 < i < n} has a Hamilton cycle. By reordering positions, Gould and Roth's generators are equivalent to X = {(1 2 i) | 3 ⩽ i ⩽ n}, which can be seen as 'star-like' 3-rotations, analogous to Ehrlich's star transpositions for S n . Holroyd [Hol17] proved that for all odd n ̸ = 5, #" Γ (A n , X) with generators X = {σ 3 , σ 5 , . . . , σ n }, i.e., odd prefix shifts, has a Hamilton cycle.
Walsh [Wal00] constructed a Gray code for permutations of length n with a fixed number k of inversions, 0 ⩽ k ⩽ n 2 , which uses a product of two adjacent transpositions in each step; see Figure 9 (b). He derived this from a genlex Gray code for integer compositions b 1 + · · · + b n = k with bounded parts b i ⩽ i − 1 for all i ∈ [n], by interpreting the composition (b 1 , . . . , b n ) as the inversion vector of a permutation. The inversion vector of a permutation π of length n is a vector (b 1 , . . . , b n ), where b i counts the number of values in π that are to the right of the value i and smaller than i. Consequently, any permutation with exactly k inversions has an inversion vector (b 1 , . . . , b n ) with b 1 + · · · + b n = k. In Walsh's composition Gray code, consecutive compositions differ by changing one entry b i by +1 and another entry b j by −1, and this translates into a product of two adjacent transpositions in the permutation: Specifically, i is transposed with the first entry to its left smaller than i, and j is transposed with the first entry to its right larger than j. Vajnovszki and Vernay [VV11] generalized this Gray code to permutations for which the number of inversions is in any fixed interval.
An alternating permutation is a permutation π such that π(1) < π(2) > π(3) < π(4) > · · · . Ruskey [Rus89] showed that for odd n, all alternating permutations can generated by transpositions (which must clearly be non-adjacent); see Figure 9 (c). P He raised the question whether such a Gray code exists also for even values of n. A more general notion are permutations with a signature, which is sequence s = (s 1 , . . . , s n−1 ) with s i ∈ {+, −}, and the requirement is that π(i) < π(i + 1) if s i = + and π(i) > π(i + 1) if s i = − for all 1 ⩽ i < n. Note that alternating permutations arise from the signature s = (+, −, +, −, . . .). Efficient generation algorithms for permutations with any fixed signature have been devised by Roelants van Baronaigien and Ruskey [RvBR92], and later by Korsh [Kor01]. P33 However, none of these methods is based on a Gray code, so the question for the existence of a (transposition?) Gray code for permutations with a given signature remains open in general.
A left-to-right minimum in a permutation π is an entry π(i), i ∈ [n], for which π(j) > π(i) for all 1 ⩽ j < i. In particular, the first entry is always a left-to-right minimum. Baril [Bar13] developed a Gray code for permutations of length n with a fixed number k of left-to-right minima, 1 ⩽ k ⩽ n, which uses transpositions or 3-rotations as transitions; see Figure 9 (e1)+(e2). It is well known that for any n and k, permutations of [n] with k left-to-right minima and permutations of [n] with k cycles are equinumerous, and both are counted by the Stirling numbers of the first kind [OEIS A132393].
An excedance in a permutation is an entry π(i), i ∈ [n], with π(i) > i. Baril [Bar08] describes a Gray code for permutations π that have exactly one excedance, where consecutive permutations differ by a transposition or a 3-rotation; see Figure 9 (f). The question whether there is a Gray code for permutations with a fixed number k of excedances is open for k ⩾ 2.
A derangement is a permutation π : [n] → [n] that has no fixpoints, i.e., π(i) ̸ = i for all i = 1, . . . , n [OEIS A000166]. Korsh and LaFollette [KL04a] present a Gray code for derangements, using either one transposition or a 3-rotation in each step. Their listing is genlex; see Figure 9 (g). They also generalized their Gray code to visit all permutations with a given lower and upper bound on the number of fixpoints; see also [BV04].
An involution is a permutation π : [n] → [n] in which all cycles have length 1 or 2, i.e., for all i = 1, . . . , n we have π(i) = i or π(i) = j and π(j) = i for some j ∈ [n] \ {i} [OEIS A000085]. Walsh [Wal01] presents a Gray code for involutions, which uses either one or two transpositions or a 3-rotation in each step, and this listing is genlex; see Figure 9 (h). He also extended this result to involutions with a given number of fixpoints, in particular for fixpoint-free involutions (in the latter case no 3-rotations are needed). Gutierres, Mamede and Santos [GMS19] developed a Gray code for involutions that uses only one transposition or a 3-rotation in each step, i.e., consecutive permutations differ in at most three entries; see Figure 9 (h').
A permutation π of [n] is indecomposable if no proper prefix of π is a permutation, i.e., π([i]) ̸ = [i] for all 1 ⩽ i < n. King [Kin06] constructed a transposition Gray code for indecomposable permutations; see Figure 9 (i). He also raised the question whether they admit an adjacent transposition Gray code.
A rosary permutation is bracelet of permutations, i.e., an equivalence class of permutations under cyclic shifts and reversal. We can pick as representatives the permutations that have n at their last position and the value 1 before the value 2, and then these representatives can be listed in adjacent transposition order by considering the first (n − 1)!/2 permutations in the SJT listing for n; see Figure 9 (j) and [Roy73].

Pattern-avoiding permutations
Given a permutation π of length n and a permutation τ of length k, where k ⩽ n, we say that π contains the pattern τ , if there is a subsequence of indices i 1 < · · · < i k such that the elements of π(i 1 ), . . . , π(i k ) appear in the same relative order as in τ . Otherwise, we say that π avoids τ . In a vincular pattern τ , two consecutive entries are underlined, and for π to contain τ , these entries must match consecutive entries of π. For example, π = 531462 contains τ = 4231, as evidenced by the shaded entries of π, whereas π avoids τ ′ = 4231 and also τ ′′ = 2413. The study of pattern-avoidance in permutations is a major branch of combinatorics, and the reason is that a vast number of combinatorial objects are bijectively equivalent to pattern-avoiding permutations. For example, 321-avoiding permutations and 231-avoiding permutations are both counted by the Catalan numbers, and are thus bijectively equivalent to many other Catalan objects [Sta15]. For any pattern τ , we write S n (τ ) for the set of permutations of [n] that avoid τ . Moreover, for any set X of permutation patterns (possibly of different lengths), we write S n (X) for the permutations of [n] that avoid each of the patterns from X, i.e., S n (X) := τ ∈X S n (τ ).
Dukes, Flanagan, Mansour and Vajnovszki [DFMV08] developed Gray codes for patternavoiding permutations. To state their result, we call a set X of permutation patterns regular, if every τ ∈ X of length k satisfies the following two conditions: (i) two entries smaller than k are to the right of k in τ ; (ii) if the entry k is not at the leftmost position of τ , then X contains at least one subpattern of τ ′ , where τ ′ is obtained from τ by transposing k with the entry to its left. For example, if τ = 436512 ∈ X, then by (ii) one subpattern of τ ′ := 463512 must be in X, for example σ := 4632 = 3421 ∈ X. Consequently, if σ = 3421 ∈ X, then by (ii) one subpattern of σ ′ := 4321 must be in X, for example σ ′ ∈ X itself. Overall, X = {τ, σ, σ ′ } = {436512, 3421, 4321} is a regular set of patterns. Note that if all patterns in X have the largest entry at the leftmost position, then condition (ii) is void, and (i) requires that all patterns have length at least 3. The paper [DFMV08] shows how to list, for any regular set of patterns X, all pattern-avoiding permutations S n (X) such that at most five entries change in each step. This construction was refined by Baril [Bar09] to most three changes in each step (which must be a 3-rotation). Examples of regular patterns to which this result applies are Hartung, Hoang, Mütze and Williams [HHMW22] propose a different Gray code for generating pattern-avoiding permutations, using cyclic shifts of substrings. Specifically, a right jump of the value a i in a permutation π = a 1 , . . . , a n cyclically shifts a substring a i , . . . , a j with a i > a i+1 , . . . , a j one position to the left, yielding a i+1 , . . . , a j , a i , whereas  a left jump of the value a j shifts a substring a i , . . . , a j with a j > a i , . . . , a j−1 one position  to the right, yielding a j , a i , . . . , a j−1 , and   . The listings are obtained from a simple greedy algorithm, which repeatedly performs a minimal distance jump with the largest possible value, so that a new permutation in the list is generated. The main feature of this approach is that applying standard bijections to these jump orderings of permutations yields Gray codes for many different combinatorial objects; see Figure 11. This generation approach therefore generalizes several known Gray codes, such as the BRGC (for X = {231, 132}), the SJT algorithm (for X = ∅ minimal jumps are adjacent transpositions), the Gray code for binary trees by rotations due to Lucas, Roelants van Baronaigien and Ruskey [LRvBR93] (for X = {231}), and the Gray code for set partitions by element exchanges described by Kaye [Kay76] (for X = {231}). It also yields Gray codes for many different classes of rectangulations [MM21], and it produces Hamilton paths and cycles on large classes of polytopes [HM21,CMM22,CHMM22]. The reason why minimal jumps are natural becomes clear when considering the inversion vector of the permutations. Observe that a right jump of a i as indicated in the definition above decreases the a i th entry of the inversion vector of π by j − i, whereas a left jump of a j as indicated before increases the a j th entry by j − i (all values that are jumped across are smaller than the value that jumps). Consequently, minimal jumps change the inversion vector in a single entry by a minimal amount, and a jump Gray code of permutations corresponds to a genlex ordering of the inversion vectors.

Linear extensions and ideals of posets
A poset P is a reflexive, antisymmetric and transitive binary relation. A linear extension of P is a total order (=chain) that extends P . For further terminology regarding posets used below, see for example [Tro92]. Linear extensions are sometimes also referred to as topological sorts, and they generalize many interesting combinatorial objects. For example, if P is an antichain on [n], then the linear extensions are all n! permutations of [n]. More generally, if P is a set of k disjoint chains of sizes c 1 , . . . , c k , then the linear extensions are multiset permutations with frequencies c 1 , . . . , c k (see Section 5.6), obtained by identifying the elements of each chain in the linear extension; see Figure 9 (k). Furthermore, linear extensions of a 2 × k grid tilted by 45 degrees correspond to Catalan objects. Indeed, if we regard the k elements in the lower chain as opening brackets and the k elements of the upper chain as closing brackets, then every linear extension corresponds to a well-formed parenthesis expression with k pairs of parentheses. By subdividing the lower chain and appending additional minima, this construction can be generalized to encode b-ary Catalan objects for any b ⩾ 2. Moreover, note that if the poset P is a fence, i.e., 1 < 2 > 3 < 4 > · · · , then its linear extensions are the inverses of alternating permutations. Similarly, all Young tableaux of a given shape arise as the inverse permutations of linear extensions of the tableau turned so that its corner is the minimum; see Figure 9 (l). Lastly, partitions of the ground set [k · c] into k sets of size c are obtained as inverse permutations of the linear extensions of the comb poset, obtained from k chains of size c by combining their minima into a chain of size k. This idea can be generalized to partitions of [n] into subsets of arbitrary prescribed sizes c 1 , . . . , c k , by forming one comb for every group of identical integers c i as before, and taking the disjoint union of those combs.
Clearly, the flip graph of linear extensions under transpositions is bipartite, with the partition classes given by the parity of the permutations. We say that a poset is balanced if the two partition classes have the same size. P36 Ruskey [Rus88b] conjectured that all balanced posets admit a transposition Gray code, and he also asked whether an adjacent transposition Gray code exists; see also [JSH09,Problem 485]. This conjecture still stands as one of the most challenging open problems in this area, and has been confirmed for several special cases. In [Rus92], Ruskey also raised a seemingly easier version of his conjecture, asking for a perfect matching in the flip graph of balanced posets. Ruskey's original conjecture is known to be true for the 2 × k grid [RP90], which is balanced if and only if k is even. It is also known for k disjoint chains of sizes c 1 , . . . , c k , k ⩾ 2, which form a balanced poset if and only if at least two of the c i are odd [Rus92], and this positive result also holds for the more restrictive requirement of adjacent transpositions [Sta92]. Ruskey [Rus92] also showed that if P is a forest, i.e., the Hasse diagram of P is a collection of rooted trees, then P is balanced if and only if the forest does not admit a matching in which all but at most one of the trees' roots are matched. To state the next result, we say that a poset is ranked, if it admits a rank function that assigns rank 0 to all maximal elements and the rank changes by −1 when moving down any cover relation. Pruesse and Ruskey [PR91] confirmed the conjecture for ranked posets P in which every non-minimal element has at least two lower covers or every non-maximal element has at least two upper covers. Using the results from [RS93], this statement even holds for adjacent transpositions. This confirmed case of the conjecture generalizes Ruskey's [Rus89] earlier transposition Gray code for alternating permutations for odd n, obtained when P is an odd fence. It also applies to forest posets in which no vertex has exactly one child, i.e., leaves have none, and all other vertices have at least two. West [Wes93] gives another proof for such forest posets, by showing that if the linear extensions of P admit an adjacent transposition Gray code, then the poset P ∧ Q also has this property, which is obtained by making a single element of P cover an antichain Q of size at least 2. In a similar vein, Stachowiak [Sta92] showed that if a poset P has an even number of linear extensions that can be listed in adjacent transposition order, then for any poset Q, the linear extensions of the disjoint union P ∪ Q also admit an adjacent transposition Gray code. Another relevant result due to Pruesse and Ruskey [PR94] is that the linear extensions of any poset P can be generated by one or a product of two adjacent transpositions in each step, and this scheme can be implemented efficiently (cf. [CW95,KL02]); see Figure 9 (k)+(l). They proved this by showing that the Cartesian product of the linear extension flip graph G(P ) with a single edge, i.e., the prism of G(P ), has a Hamilton cycle. As G(P ) is bipartite, this easily implies that the square G 2 (P ) has a Hamilton cycle.
An ideal of a poset P is a downward-closed subset of P . Koda and Ruskey [KR93] constructed a Gray code for the ideals of a forest poset, where consecutive ideals differ by exactly one element. Pruesse and Ruskey [PR93] showed that the ideals of any poset can be listed by changing (i.e., adding or removing) at most two elements in each step, by proving that the prism of the ideal flip graph admits a Hamilton cycle. They also proved that such a listing exists for the ideals of fixed size of a series-parallel poset. Habib, Nourine and Steiner [HNS97] generalized this result about ideals of fixed size to interval orders, and they showed that all ideals of a poset can be listed in non-decreasing order of cardinality by changing at most two elements in each step. It is a long-standing open problem whether the ideals of any poset can be generated in constant amortized-time per ideal, either in a Gray code fashion or not.

Multiset permutations
A useful generalization of permutations are multiset permutation, which allow repetition of symbols. Formally, a multiset permutation over the alphabet [k] with frequencies c 1 , . . . , c k ⩾ 1 is a string that contains exactly c i entries i for all i ∈ [k]. Permutations are the special case where c 1 = · · · = c k = 1. Multiset permutations also generalize combinations, which are obtained for k = 2.
Ko and Ruskey [KR92] describe a genlex Gray code for multiset permutations that uses transpositions, and that is constructed from a generation tree. Takaoka [Tak99a] used a similar idea to construct another transposition-based genlex Gray code, which moreover yields a loopless algorithm. Ruskey [Rus03] also devised a Gray code that operates by homogeneous transpositions, i.e., whenever entries a i and a j are transposed, all entries in between satisfy a i+1 , . . . , a j−1 ⩽ min{a i , a j }. This construction is a generalization of the Eades-McKay homogeneous transposition Gray code for combinations; see also [Vaj03,KL04b]. Already much earlier, Chase [Cha70b] generalized his Gray code for combinations to multiset permutations, such that it only uses transpositions of the form a i , a i+1 ↔ a i+1 , a i  or a i−1 , a i , a i+1 ↔ a i+1 , a i , a i−1 with a i = min{a i−1 , a i+1 }.
Lehmer [Leh65] raised the question under which conditions multiset permutations can be generated by adjacent transpositions. He phrased the problem in terms of a motel, which hosts k families with c i members for each i ∈ [k], and the task is to create all possible assignments of these guests to n := i∈[k] c i rooms, where changes take place only between adjacent rooms. Stachowiak [Sta92] answered this question completely, proving that an adjacent transposition Gray code exists if and only if at least two of the c i are odd, or in the trivial cases k = 1, or k = 2 and min{c 1 , c 2 } = 1; see also [Rus92].
Williams [Wil09a] showed that multiset permutations can be generated by prefix shifts, and the average length of the shifts is less than 3 when c 1 = · · · = c k = 1. He obtained this result by generalizing his cool-lex order to multiset permutations. In his thesis [Wil09b], he also shows that prefix shifts of length n − 1 or n are sufficient to generate all multiset permutations, which generalizes the aforementioned result for permutations published in [RW10]. P38 Shen and Williams [SW21] conjectured that multiset permutations with equal frequencies c 1 = · · · = c k =: c can be generated by star transpositions. This generalizes Ehrlich's star transposition Gray code for permutations (c = 1), and the middle levels conjecture (k = 2). Such star transposition Gray codes were constructed by Gregor, Merino and Mütze [GMM22b] for all frequencies satisfying c i ⩽ 4 for i ∈ [k] and 2·max i∈[k] c i ⩽ i∈[k] c i , settling in particular the cases c = 2, 3, 4 of Shen and Williams' conjecture. All other cases are still open.

Other generalizations and variants
A signed permutation is a permutation in which every entry has a sign {+, −}. Korsh, LaFollette and Lipschutz [KLL11] combined the BRGC and the SJT algorithm to a Gray code for signed permutations that operates by adjacent transpositions or inverting the sign of the last entry.
In a complemented prefix reversal we reverse a prefix of a signed permutation and complement all of its signs. In terms of the pancake flipping analogy, we can imagine pancakes with one side burnt and the other side unburnt, so flipping them around brings up the other side. Suzuki, N. Sawada and Kaneko [SSK05] showed that the flip graph on signed permutations under those operations is Hamilton-connected. Moreover, J. Sawada and Williams [SW16a] describe two simple algorithms for computing a Hamilton cycle in this graph. The first algorithm greedily applies complemented prefix reversals to the shortest possible prefix, so that a new signed permutation is generated. The average length of the reversed prefixes approaches √ e = 1.64872 . . .. Interestingly, the Ord-Smith/Zaks ordering of (unsigned) permutations is also obtained by such a greedy rule. Moreover, it is shown that greedily reversing (and complementing) the longest possible prefix also yields a Gray code listing of permutations (and signed permutations, respectively). P In the follow-up paper [SW16b], Sawada and Williams conjectured that signed permutations can be generated using only complemented prefix reversals of lengths n, n − 1 or n − 2.
Cameron, Sawada and Williams [CSW21] generalized these results to colored permutations, where each entry of the permutation has one of k available colors. For k = 1 these are (uncolored) permutations and for k = 2 these are signed permutations. This paper establishes that the greedy strategy that modifies the shortest possible prefix by reversing and cyclically shifting colors works for any number k of colors, and the average length of the reversed prefixes approaches e 1/k .
Gutierres, Mamede and Santos [GMS18] present a Gray code for signed involutions that uses a transposition, a 3-rotation and/or a sign change in each step.

Set partitions
A set partition is a partition of [n] into a disjoint union of nonempty sets. We consider every set partition in its canonic representation, where every subset is sorted increasingly, and the subsets are sorted increasingly by their smallest elements. A restricted growth string (RGS) is a string a 1 , . . . , a n such that a 1 = 0 and a i ⩽ 1 + max{a 1 , . . . , a (a 1 , . . . , a i−1 all i = 2, . . . , n. It is well known that set partitions are in bijection with RGSs. Indeed, given a set partition in canonic representation, we give labels j = 0, 1, . . . to each subset according to the canonic ordering, and we then define a i := j if the element i is in the subset labeled j.

Unrestricted set partitions
Kaye [Kay76] describes a Gray code for set partitions where in each step, one element moves from one subset to an adjacent subset (in the canonic representation); see Figure 12 (a). This Gray code for the partitions of [n] can be constructed inductively by considering the listing for partitions of [n−1] and adding n to every subset and as a singleton, alternatingly from left to right or vice versa. In Kaye's paper and in [Wil89], this construction idea is attributed to Knuth, who solved the corresponding problem stated in [NW75,p. 292,Problem 35]. The corresponding RGS listing is genlex, but consecutive RGSs may differ in multiple positions. Ruskey [Rus03] proposed a simple modification of this ordering which maintains the genlex property and ensures that consecutive RGSs differ in exactly one position, and by ±1 or ±2 in that position; see Figure 12 (b). Already earlier, Ehrlich [Ehr73b] presented a Gray code for set partitions which is genlex and consecutive RGSs differ in exactly one position, either by ±1 or the value in that position changes from 0 to the maximum value or vice versa; see Figure 12 (c). In the canonic set representation, this means that an element moves to a circularly adjacent subset, i.e., the first and last subset are also considered adjacent. Ehrlich also proved that under the stricter requirement that two consecutive RGSs differ only by ±1, Gray codes do not exist for infinitely many values of n because of balancedness problems. Mansour and Nassar [MN08] present another genlex Gray code for set partitions in which consecutive RGSs differ in exactly one position.
Williams [Wil13] describes a genlex Gray code for set partitions that is produced by starting at the partition {1, 2, . . . , n}, and then repeatedly and greedily moving the largest possible element to the leftmost possible set so that a new set partition is created; see Figure 12 (e). In the corresponding RGS listing, some strings differ in more than one position (in the listing for n = 6 shown in the figure, there is precisely one such transition from the 73rd to the 74th string, which differ in the last two positions). Williams' paper claims that this listing is the same as Kaye's, but this is not the case. In particular, Williams' listing always ends with the partition {1}, {2}, . . . , {n}, unlike Kaye's. Yet another genlex greedy Gray code was communicated to the author by Joe Sawada and his student Kevin Kerr in 2021 [Ker21]. It starts with 0 n and then repeatedly and greedily changes the rightmost possible entry (and only that entry) to the largest possible value so that a new RGS is created; see Figure 12 (f).

Fixed number of parts
Ehrlich's paper [Ehr73b] also describes a Gray code for set partitions with a fixed number of parts; see Figure 12 (g2)-(g4). The sets differ in moving one or two elements to another subset, and the corresponding RGS listings are genlex and differ in at most two positions in each step. His construction works more generally for set partitions whose number of parts is in any fixed interval. Ruskey [Rus93] presents another Gray code for this problem in which the RGSs differ in exactly one position in each step, but this listing is not genlex; see Figure 12 (h2)-(h4). Ruskey and Savage [RS94b] showed that a Gray code with only single ±1 transitions in the RGS representation does not exist in general.
Sabri and Vajnovszki [SV17] consider Gray codes for set partitions with a fixed number of parts or an upper bound on the number of parts. They constructed a 5-Gray (in the RGS representation) for the first family and a 3-Gray code for the second family, based on sublists of generalizations of the BRGC, implying that both of these Gray codes are genlex; see Figure 12 (i3)-(i5).

Non-crossing, non-nesting and sparse partitions
Huemer, Hurtado, Noy and Omaña-Pulido [HHNOP09] developed Gray codes for noncrossing set partitions. A set partition is non-crossing if for any two sets A and B of the partition and any four elements a, a ′ ∈ A and b, b ′ ∈ B we do not have a < b < a ′ < b ′ . The authors construct a cyclic Gray code for non-crossing partitions, valid for all n ⩾ 3, that moves one element of a subset to another in each step. A non-cyclic Gray code for this problem can be obtained easily, by following Kaye's construction described in Section 6.1 and skipping set partitions that have crossings, which yields a genlex listing; see Figure 12 (j). This paper also construct a cyclic Gray code for non-crossing partitions of fixed size k, for all n > k ⩾ 3, allowing however one additional flip operation, namely to exchange two elements between two subsets, i.e., P43 The authors conjectured that the latter problem can be solved for all n > k ⩾ 3 without using this extra type of flip operation.
Complementing the aforementioned results, Conflitti and Mamede [CM15] consider non-nesting set partitions, which are set partitions such that for any two sets A and B of the partition and any four elements a, a ′ ∈ A and b, b They present a Gray code for non-nesting partitions that moves one element of a subset to another in each step; see Figure 12 (k). The construction is a straightforward variation of Kaye's construction, and it also yields a genlex listing. The authors used the same idea to construct a genlex Gray code for sparse set partitions, which are partitions such that no subset contains two consecutive elements; see Figure 12 (l). Interestingly, there is a simple bijection between sparse set partitions of [n] and unrestricted set partitions of [n − 1]. In particular, sparse set partitions are also counted by the Bell numbers. In addition to these simple non-cyclic constructions, Conflitti and Mamede also provide constructions of cyclic Gray codes for both problems. In a later paper, Conflitti and Mamede [CM17] present similar Gray codes for non-crossing and non-nesting partitions in Weyl groups of type B and D.
P44 For all the classes of restricted set partitions discussed in this section, it is open whether they admit Gray codes that change only few entries in the RGS representation in each step.

Generalizations
For any integer k ⩾ 0, a restricted growth tail is a string a 1 , . . . , a n such that a 1 ⩽ k and a i ⩽ 1 + max{a 1 , . . . , a i−1 , k − 1} for all i = 2, . . . , n. Obviously, for k = 0 these are the same as RGSs. Ruskey and Savage [RS94b] present Gray codes for restricted growth tails, valid for any n ⩾ 1 and k ⩾ 0, which satisfy Ehrlich's conditions mentioned in Section 6.1, i.e., a single position changes in each step, either by ±1 or the value in that position changes from 0 to the maximum value of at least k or vice versa. These Gray codes are moreover cyclic.
Mansour, Nassar and Vajnovszki [MNV11] consider another generalization of RGSs, called restricted growth functions, for which there is a vector b = (b 2 , . . . , b n ) with b i ⩾ 1 for all i = 2, . . . , n, and the requirement for the string a 1 , . . . , a n is that a 1 = 0 and a i ⩽ b i + max{a 1 , . . . , a i−1 } for all i = 2, . . . , n. Clearly, for b = (1, . . . , 1) we recover standard RGSs. They present genlex Gray codes that are valid for any vector b, and those Gray codes change only one entry of the RGS representation at a time; see Figure 12 (m)+(m'). For b = (1, . . . , 1) the obtained listings coincide with the Gray code of Kerr-Sawada mentioned before, and they can also be constructed greedily, by starting with 0 n and then repeatedly and greedily changing the rightmost possible entry to the largest possible symbol.
Subsequently, Mansour and Vajnovszki [MV13] introduced an even more general concept, called restricted growth words. They consider strings a 1 , . . . , a n such that a 1 = 0 and a i ⩽ 1 + f (a 1 , . . . , a i−1 ), where f is any non-negative function of a 1 , . . . , a i−1 . Their paper describes a genlex Gray code for any such family of strings, which changes only one entry at a time, either by ±1 or ±2. For f = max we obtain RGSs. For f = i − 2 we obtain subexcedent sequences, which are counted by the factorial numbers; see Figure 12 (n). For f = a i−1 we obtain staircase words, which are another Catalan family; see Figure 12 (n'). For f = 0 we obtain bitstrings with first bit 0, which are counted by powers of 2, and the resulting listing is the (first half of the) BRGC. For f = |{1 ⩽ j < i − 1 | a j < a j+1 }| we obtain ascent sequences, which are counted by the Fishburn numbers [OEIS A022493]; see Figure 12 (n"). Interestingly, the Kerr-Sawada greedy approach also works in this more general setting, yielding different listings, however.

Integer partitions and compositions
In this section we discuss Gray codes for integer partitions and integer compositions.

Integer partitions
A partition of n is a sequence a 1 , . . . , a k of integers such that a 1 ⩾ a 2 ⩾ · · · ⩾ a k ⩾ 1 and a 1 + · · · + a k = n. Integer partitions are counted by the partition numbers [OEIS A000041].
Wilf asked whether integer partitions of n admit a Gray code with transitions of the form a i , a j ↔ a i − 1, a j + 1 in each step, which includes transitions a i (, 0) ↔ a i − 1, 1 that change the number of parts. This problem was solved by Savage [Sav89], who showed more generally that for all n ⩾ k ⩾ 1, all partitions of n with parts of size at most k admit such a Gray code. Her results also yield Gray codes for all partitions of n with largest part equal to k, all partitions of n into at most k parts, and all partitions of n into exactly k parts.
Rasmussen, Savage and West [RSW95] constructed a Gray code for partitions of n into parts of size at most k and congruent to 1 modulo d, where d ⩾ 1 is some integer parameter. For d = 1 this is the same problem as before. For d = 2 these are partitions into odd parts of size at most k. Their Gray code uses transitions a i , a j ↔ a i − d, a j + d and a i (, 0 d ) ↔ a i − d, 1 d . Furthermore, the authors present a Gray code for partitions of n into distinct parts of size at most k, using transitions a i , a j ↔ a i − 1, a j + 1 as before. It is a well-known result of Euler that the number of partitions of n into odd parts is the same as the number of partitions of n into distinct parts [OEIS A000009]. P45 The paper [RSW95] also raised the problem to construct Gray codes for the following five families of restricted partitions of n: exactly k distinct parts; distinct odd parts; distinct parts congruent to 1 modulo d; at most c copies of each part; parts congruent to 1 modulo d and at most c copies of each part. Savage [Sav97] conjectured that such codes exist for all n ⩾ k ⩾ 1 and c, d ⩾ 1.
A compact representation of an integer partition a 1 , . . . , a k is obtained by grouping together runs of a i that have the same value, and recording their multiplicities, i.e., we obtain a list of pairs (a ′  1 , b 1 Ruskey [Rus03] observed that ordering partitions lexicographically, the corresponding compact representations differ at most in the last three pairs of integers.

Integer compositions
A composition of n is a sequence of integers a 1 , . . . , a k such that a 1 , . . . , a k ⩾ 1 and a 1 + · · · + a k = n, i.e., in contrast to partitions, the order of the summands matters. The number of compositions of n is 2 n−1 , and there is a simple bijection between bitstrings of length n − 1 and compositions: Specifically, for any bitstring x, we consider the lengths of all maximal non-overlapping substrings of x1 that end with 1. For example, for the string x = 1101000110000 of length 13 we have x1 = 1|1|01|0001|1|00001, where the vertical bars indicate the boundaries between maximal non-overlapping substrings ending with 1, and therefore x is mapped to the composition 1, 1, 2, 4, 1, 5 of 14. Observe that the BRGC has the interesting property that for every flip 1 ↔ 0, the flipped bit is the last one or at least one of the bits next to it is also a 1. Applying the aforementioned bijection to the BRGC, we thus obtain a cyclic genlex Gray code for compositions that uses only transitions a i , 1 ↔ a i + 1, where the 1 is at positions i + 1 or i − 1, respectively.
If we consider compositions of n with a fixed number k of parts, then the above bijection shows that they correspond to (n − 1, k − 1)-combinations. Using the Gray codes for combinations discussed in Section 4.1 that use transpositions 01 ↔ 10 or 001 ↔ 100, we obtain Gray codes for compositions with transitions a i , a i+1 ↔ a i − d, a i+1 + d with d = ±1 or d = ±2, respectively (recall that using only the former requires some conditions on n and k).
Klingsberg [Kli82] describes a genlex Gray code for compositions into a fixed number of parts that uses only transitions a i , a j ↔ a i − 1, a j + 1 (cf. also [MN10]). In Klingsberg's paper and in [Wil89], the idea for this construction is attributed to Knuth, who solved the corresponding problem stated in [NW75,p. 292,Problem 34].
Ruskey and Savage [RS96] consider compositions a 1 , . . . , a k of n with a fixed number k of parts, with the additional requirement that the parts are bounded, i.e., there is a vector b = (b 1 , . . . , b k ) such that a i ⩽ b i for all i = 1, . . . , k. For b i ⩾ n this restriction becomes irrelevant, so we obtain compositions of n into k parts. Moreover, for b 1 = · · · = b k = 2 these are (k, n − k)-combinations (by changing the alphabet 1, 2 → 0, 1). The authors construct a Gray code that uses transitions a i , a j ↔ a i − 1, a j + 1. They raise the problem to determine when an adjacent transition Gray code for this problem is possible, i.e., if we also require that |j − i| = 1 (in some cases, there are balancedness problems). Earlier, Ehrlich [Ehr73a,Ehr73b] presented an adjacent transition Gray code, but with changes that can be more than ±1.
Walsh [Wal00] considered the same setting of bounded compositions as Ruskey and Savage, and he showed that for any vector b, the sublist of Klingsberg's ordering obtained by selecting only the compositions that satisfy the upper bounds given by b forms a genlex Gray code with transitions a i , a j ↔ a i − 1, a j + 1. By choosing an appropriate b and interpreting every composition as an inversion vector of a permutation, he used this to derive a Gray code for permutations with a fixed number of inversions; see Section 5.3.
Vajnovszki and Vernay [VV11] showed more generally that we may start with a straightforward generalization of the BRGC for tuples a 1 , . . . , a k with 1 ⩽ a i ⩽ b i (recall Section 3.19), and consider the sublist of all tuples that satisfy s ⩽ a 1 + · · · + a k ⩽ t, and this sublist will be a genlex Gray code with transitions a i ↔ a i ± 1 or a i , a j ↔ a i − 1, a j + 1. In particular, Walsh's result for compositions follows from this by setting s = t = n. Furthermore, this also generalizes Tang and Liu's result about combinations discussed in Section 4.1 (for b 1 = · · · = b k = 2 and s = t), who obtained their Gray code for combinations by restricting the ordinary BRGC to bitstrings with fixed weight.

Geometric objects
In this section we consider Gray codes for geometric objects equipped with flip operations that are constrained by geometry, e.g., from a planarity requirement, and this makes the topic particularly interesting. For results on flips in planar graphs beyond Gray codes, we refer to the survey of Bose and Hurtado [BH09b]. In addition to the material in this section, non-crossing and non-nesting set partitions are discussed in Section 6.3.

Triangulations and matchings
We first consider the flip graph G n that has as vertices all triangulations of a convex n-gon, and edges connecting triangulations that differ by a flip, i.e., a diagonal in a quadrilateral formed by two triangles is replaced by the other diagonal. The number of such triangulations is the (n − 2)th Catalan number. It is well known that G n is the cover graph of a lattice, namely the Tamari lattice, and the skeleton of a polytope, namely the (n − 3)-dimensional associahedron. By considering the dual graphs of the triangulations, we see that triangulations are isomorphic to binary trees with n − 2 nodes, and edge flips correspond to tree rotations; see Figure 1 (f). Lucas [Luc87] proved that G n has a Hamilton cycle, and her proof yields an efficient generation algorithm. Subsequently, Lucas, Roelants van Baronaigien and Ruskey [LRvBR93] provided a simpler proof for the existence of a Hamilton path in G n , which yields a loopless algorithm. Possibly the simplest description of their path was given by Williams [Wil13] via a greedy algorithm, which is to repeatedly rotate the edge with the largest inorder label so that a new tree is generated; see also [CMM22] and Figure 11. Another proof for the existence of a Hamilton cycle in G n was obtained by Hurtado and Noy [HN99] via a generation tree. Huemer, Hurtado and Pfeifle [HHP08] later generalized this result to a flip graph of dissections of a convex polygon into (b + 1)-gons under edge flips, whose dual graphs are b-ary trees under tree rotations.
Hernando, Hurtado and Noy [HHN02] consider the set of all non-crossing perfect matchings on a set of n = 2m points in convex position, with the flip operation that replaces edges and non-edges along an alternating 4-cycle. They proved that the corresponding flip graph has a Hamilton cycle for every even m ⩾ 4, and no Hamilton path for any odd m ⩾ 5. Note that non-crossing matchings are also counted by the Catalan numbers.
Aichholzer, Aurenhammer, Huemer and Vogtenhuber [AAHV07] exhibit a set of six points in non-convex position for which the flip graph of triangulations is a star with three rays, so it does not admit a Hamilton path. P47 They speculate whether Hamiltonicity holds for triangulations of every sufficiently large point set. Moreover, they conjectured that the flip graph of pseudo-triangulations under edge removals/insertions and exchanges has a Hamilton cycle, where a pseudo-triangulation has faces that are bounded by three concave chains.
Certain flip graphs for triangulations and non-crossing matchings on general point sets were considered by Houle, Hurtado, Noy and Rivera-Campo [HHNRC05], and they established that these graphs are connected, which implies 3-Gray codes by Sekanina's [Sek60] theorem discussed in Section 2.4.

Dissections, plane graphs and spanning trees
Huemer, Hurtado, Noy and Omaña-Pulido [HHNOP09] consider Gray codes for dissections of a convex polygon. A dissection of a convex polygon with n vertices is a subdivision of the polygon by k non-crossing diagonals, where 0 ⩽ k ⩽ n − 3. We let G n and G n,k be the graphs on the set of all dissections and those with exactly k diagonals, respectively. In G n , two dissections are connected by an edge if they differ either in removing or adding one diagonal, and in G n,k they are adjacent if they differ by removing one diagonal and adding another diagonal in the subpolygon that contains the end vertices of the removed diagonal. The authors prove that G n has a Hamilton cycle for all n ⩾ 4, and G n,k has a Hamilton cycle for all k ⩾ 1 and n ⩾ 4. Note that the vertices of G n,k are precisely the (n − 3 − k)-dimensional faces of the associahedron (as a polytope), so this result generalizes the aforementioned result about the Hamiltonicity of the associahedron (the special case k = n − 3).
Hernando, Hurtado, Marquez, Mora and Noy [HHM + 99] proved that all plane spanning trees on a set of n ⩾ 3 points in convex position can be listed cyclically so that consecutive trees differ by exchanging one edge. Rivera-Campo and Urrutia-Galicia [RCUG01] proved the same result for plane spanning paths.
Aichholzer, Aurenhammer, Huemer and Vogtenhuber [AAHV07] consider point sets in general position, with plane graphs whose edges connect certain pairs of points by a straight line. In this setting, they obtained Gray codes via generation trees for three different families of graphs: all plane graphs by edge removals/insertions, all plane spanning trees by edge exchanges (generalizing the result from [HHM + 99] for convex position), and all connected plane graphs by edge removals/insertions or exchanges.

Rectangulations and rainbow cycles
Merino and Mütze [MM21] present Gray codes for various families of generic rectangulations, which are subdivisions of a rectangle into n smaller rectangles, subject to the constraint that no four rectangles meet in a point. In particular, they constructed a Gray code for all generic rectangulations with n rectangles by flip operations called wall slides, simple flips and T-flips. They also obtained a Gray code for diagonal rectangulations, which are those generic rectangulations for which every rectangle intersects the diagonal from the top-left to the bottom-right corner of the outer rectangle, and this Gray code uses only simple and T-flips (diagonal rectangulations are counted by the Baxter numbers [OEIS A001181]); see Figure 13. More generally, their approach yields Gray codes for many subfamilies of generic rectangulations that are characterized by pattern avoidance, such as guillotine rectangulations or 1-sided rectangulations, by so-called jumps, which generalize wall slides, simple flips and T-flips. P48 They raised the problem of constructing Gray codes for rectangulations of point sets as introduced in [ABP06] (see also [YRN18]).
Felsner, Kleist, Mütze and Sering [FKMS20] constructed cycles in the flip graphs of different geometric configurations that are balanced in the sense that each flip operation occurs equally often along the cycle. They refer to these cycles as rainbow cycles, and establish existence and non-existence results for the flip graphs of triangulations of a convex polygon, non-crossing perfect matchings on a convex set of points, and plane spanning trees on a general point set.
P49 They conjectured that the flip graph of non-crossing perfect matchings on a convex 2m-gon under flips along alternating 4-cycles does not contain a cycle along which every possible edge on the point set appears and disappears exactly once (such a cycle has length m 2 /2), whenever m ⩾ 6 is even, which is confirmed for m ∈ {6, 8, 10, 12} (see also [MMP21]).

Objects on graphs
In this section we discuss Gray codes for combinatorial objects that are defined with respect to a fixed graph H. We write K n , P n and C n for the complete graph, path or cycle on n vertices, respectively, and K a 1 ,a 2 ,...,ar for the complete r-partite graph with partition classes of sizes a 1 , . . . , a r .

Spanning trees, cycles, and generalizations to matroids
Cummins [Cum66] showed that the spanning trees of any fixed graph H can be listed cyclically by edge exchanges, i.e., in each step one edge is removed from the current spanning tree and another edge is inserted; see Figure 1 (g). Equivalently, his result asserts that the flip graph of the spanning trees of H under edge exchanges has a Hamilton cycle. Cummins proved more strongly that this flip graph is edge-Hamiltonian, i.e., for each of its edges, there is a Hamilton cycle containing this edge. A short proof of this result was given by Shank [Sha68]. Smith [Smi97] devised an algorithm for listing all spanning trees of a graph by edge exchanges, which requires only constant time on average per generated spanning tree. Details of his algorithm are described in [Knu11, Sec. 7.2.1.6].
Holzmann and Harary [HH72] generalized the aforementioned results to matroids, proving that the flip graph of the bases of a matroid under element exchanges has a Hamilton cycle. They showed more generally that if the flip graph has at least two cycles, then it is Hamilton-uniform, i.e., for every edge of the flip graph, there is a Hamilton cycle containing this edge, and a Hamilton cycle avoiding this edge. Naddef and Pulleyblank [NP81] proved that the matroid base flip graph is either Hamilton-connected or a hypercube, which is known to be Hamilton-laceable. Alspach and Liu [AL89] showed that for simple matroids, this flip graph is also edge-pancyclic, i.e., for every edge and every integer ℓ at least 3 and at most the number of vertices of the flip graph, there is a cycle of length ℓ through this edge; see also [BI76]. Note that for the uniform matroid, the matroid base flip graph is the Johnson graph, and in this case a Hamilton cycle corresponds to a transposition Gray code for combinations.
Many of the aforementioned Gray codes for spanning trees of a graph H are based on a straightforward recursion, already observed by Feussner [Feu02] (see also [Min65]), namely to consider the spanning trees that do not contain a fixed edge e, which are the spanning trees of H − e, and those that do contain e, which are the spanning trees of H/e.
The graph H − e is obtained from H by removing e, but none of its end vertices, whereas H/e is obtained from H by contracting the end vertices of e to a single vertex. Based on this recursion, Arturo Merino discovered a strikingly simple greedy algorithm to list the spanning trees of H by edge exchanges, by considering their characteristic vectors: An edge exchange corresponds to a transposition of a 0 and 1 in the characteristic vector, and the rule is to perform a transposition that changes the shortest possible prefix so as to generate a previously unseen spanning tree. This amazing rule works for any graph H, for any edge ordering that determines the indices of the characteristic vector, for any initial spanning tree, and for any tie-breaking rule, it always yields a genlex listing, and it also generalizes straightforwardly to bases of a matroid (however, this Gray code is in general not cyclic). P50 Cameron, Grubb and Sawada [CGS21] asked whether there is a Gray code for spanning trees of a graph H that uses edge exchanges, with the additional requirement that the removed and added edge have a vertex of H in common. They refer to a listing satisfying this stronger requirement as a pivot Gray code, and they constructed such a Gray code for the family of fan graphs, which are obtained by joining a single vertex to all vertices of a path. P5 Knuth [Knu11, Ex. 102 in Sec. 7.2.1.6] considers a directed graph and all of its spanning trees in which all arcs are oriented away from a fixed root vertex, also known as out-trees or arborescences. He asked for a Gray code to list those directed trees in Gray code order, exchanging one arc at a time. Note that the removed and added arc must point to the same vertex. We conclude that the existence of Knuth's Gray code would imply a pivot Gray code for undirected graphs (simply replace each undirected edge with two arcs in opposite directions). P52 Furthermore, Knuth [Knu11, Ex. 101 in Sec. 7.2.1.6] asked for a simple listing of the spanning trees of the complete graph K n by edge exchanges. The precise definition of 'simple' is not specified, but it could mean fast ranking and unranking algorithms, and possibly also a more fine-grained explanation of Cayley's formula n n−2 for the number of all spanning trees.
Li and Liu [LL08a] consider the flip graph of circuits of a matroid, whose vertices are the circuits and two of them are connected by an edge if their intersection is nonempty. They proved that the circuit flip graph of a connected matroid is Hamilton-uniform, provided that there are at least four circuits; see also [FL13]. In the case of graphical matroids, a Hamilton cycle in the flip graph corresponds to a cyclic listing of the cycles of a graph so that any two consecutive cycles share at least one edge. Li and Liu [LL07] proved that the circuit flip graph of a connected matroid is also edge-pancyclic; see also [LL08b,LL12].

Perfect matchings
For a graph H, we consider the flip graph G(H) that has as vertices all perfect matchings of H, and two of them are connected by an edge in G(H) if they differ by an alternating cycle. Naddef and Pulleyblank [NP81] proved that G(H) is either Hamilton-connected or a hypercube, which is known to be Hamilton-laceable; see also [NP84] and [ZG86b]. Naddef [Nad84] showed that the flip graph G(H) is also edge-pancyclic, provided that the set of edges of H that are contained in some perfect matching form a connected subgraph of H.

Hamilton cycles and Eulerian tours
Fleischner, Horák and Širáň [FHŠ93] consider the flip graph G(H) of Hamilton cycles of H, where any two cycles C and C ′ are connected by an edge in G(H) if the symmetric difference of their edge sets is a 4-cycle in H, and the vertices of this 4-cycle appear consecutively on C and C ′ . They showed that G(K n ) for n ⩾ 4 is edge-Hamiltonian (see also Sierksma's papers [Sie93,Sie98]). Note that a Hamilton cycle in G(K n ) corresponds to a cyclic listing of rosary permutations of [n] by circularly adjacent transpositions. It would be very interesting to investigate the Hamiltonicity of G(H) for other graphs H, for example H = K a,b .
Let H be a graph that admits a Eulerian tour, i.e., H is connected and each vertex has even degree. The graph H may also have multiple edges, but no loops. Zhang and Guo [ZG86a] consider the flip graph G(H) that has as vertices all Eulerian tours of H without considering their orientation, i.e., a forward or backward traversal of the same tour is represented as a single vertex in G(H). Moreover, two Eulerian tours are connected by an edge in G(H) if they differ by reversing the orientation of traversing a closed proper subtour. This flip operation is known as Kotzig transformation. They proved that if H has at least three Eulerian tours, then G(H) is edge-Hamiltonian. In [ZG87], the same authors also consider an analogous question for directed graphs. Let H be a digraph that admits a Eulerian tour, i.e., H is connected and for each vertex, the in-degree equals the out-degree. As before, multiple edges in H are allowed, but no loops. The flip graph G(H) has as vertices all directed Eulerian tours of H, and two of them are connected if they differ by exchanging two directed subtrails between the same pair of vertices. The authors showed that if H has at least three directed Eulerian tours, then G(H) is edge-Hamiltonian.
Guan and Pulleyblank [GP85] consider orientations of an undirected graph H that admit a directed Eulerian tour. The corresponding flip graph G(H) has as vertices all Eulerian orientations of H, and two of them are connected in G(H) if they differ by reversing an oriented (simple) cycle. They proved that G(H) is either Hamilton-connected or a hypercube, which is known to be Hamilton-laceable.

Elimination orders and trees
A perfect elimination ordering (PEO) of a graph is an ordering v 1 , . . . , v n of its vertices such that for every i = 1, . . . , n, the neighbors of v i among v 1 , . . . , v i−1 form a clique. It is well known that a graph H admits a PEO if and only if H is chordal. Chandran, Ibarra, Ruskey and Sawada [CIRS03] present a Gray code for the PEOs of any chordal graph that performs one or a product of two adjacent transpositions in each step. Their construction is based on the antimatroid Gray code from [PR93] (see also [Saw05]).
An elimination tree of a connected graph H is a rooted unordered tree, obtained by removing a vertex v of H, which becomes the root of the tree, and recursing on the connected components of H − v that become the children of v in the tree. An elimination forest of a disconnected graph H is a collection of elimination trees, one for each connected component of H. Elimination trees generalize many combinatorial objects, such as binary trees (if H is a path), permutations (if H is a complete graph) and bitstrings (if H is a disjoint union of edges). Manneville and Pilaud [MP16] showed that if H has at least two edges, then its elimination trees can be generated cyclically by tree rotations, which naturally generalize classical rotations in binary trees. The corresponding flip graphs arise as skeleta of graph associahedra, which are a class of polytopes introduced by Carr and Devadoss [CD06,Dev09] and Postnikov [Pos09]. Cardinal, Merino and Mütze [CMM22] present a simple and efficient algorithm to compute a Gray code for the elimination forests of H by tree rotations for the case when H is a chordal graph, and this Gray code is cyclic if H is also 2-connected. This Gray code generalizes the Gray code for binary trees due to Lucas, Roelants van Baronaigien and Ruskey [LRvBR93], the SJT algorithm for permutations, and the BRGC for bitstrings.

Acyclic orientations
Savage, Squire and West [SSW93] consider a graph H and all of its acyclic orientations. The flip graph G(H) has these acyclic orientations as vertices, and two of them are adjacent if the differ by the reversal of a single arc. Observe that for a graph H with m edges, G(H) is a subgraph of the m-cube, in particular, G(H) is bipartite. Moreover, if H is a forest, then G(H) is the full m-cube, i.e., acyclic orientations are in 1-to-1 correspondence to bitstrings of length m, and reversing an arc corresponds to flipping a single bit. Observe also that if H = K n , then acyclic orientations are in 1-to-1 correspondence to permutations of [n], and reversing an arc corresponds to an adjacent transposition. For these two cases we immediately obtain Hamilton cycles in G(H) by the BRGC and SJT algorithm, respectively. The aforementioned paper of Savage, Squire and West showed more generally that G(H) has a Hamilton cycle for any chordal graph H, and the resulting orderings generalize the BRGC and SJT. To describe the other results, we introduce two more families of graphs: The ladder L n is defined as the Cartesian product L n := P n × P 2 , and the wheel W n is obtained from C n by adding a new vertex adjacent to all others. The authors constructed Hamilton cycles in G(C n ) and G(L n ) for odd n, and a Hamilton path in G(W n ) for odd n. On the negative side, they proved that the following flip graphs have no Hamilton path because of balancedness problems: G(C n ), G(L n ) and G(W n ) for even n, G(K a,b ) for a, b ⩾ 2 if a or b is even. P54 They conjectured that G(W n ) has a Hamilton cycle for odd n (not just a Hamilton path), and they also raise the problem of finding a Hamilton path or cycle in G(K a,b ) when a and b are both odd. More generally, they conjectured that G(H) has a Hamilton cycle if and only if its partition classes have the same size. This question was reiterated by Savage and Zhang [SZ98] and by Edelman (see [Sav97]). Towards this question, Squire [Squ94] showed that the square G 2 (H) has a Hamilton cycle for any graph H. Pruesse and Ruskey [PR95] strengthened this result and proved that the prism G(H) × P 2 , i.e., the Cartesian product of G(H) with a single edge, admits a Hamilton cycle. As G(H) is bipartite, this easily implies that G 2 (H) has a Hamilton cycle. Squire [Squ98] gives an efficient algorithm for computing a Hamilton cycle in the square G 2 (H), i.e., for listing all acyclic orientations of H by reversing at most two arcs in each step.
The problem of listing the acyclic orientations of H by arc reversals can be generalized so that it simultaneously generalizes the problem of listing the linear extensions of a poset by adjacent transpositions discussed in Section 5.5. Specifically, for a graph H, we consider a subset F of edges of H to which we assign a fixed acyclic orientation, and we let G(H, F ) be the subgraph of G(H) induced by acyclic orientations that preserve the orientation of the edges in F . Clearly, we have G(H, ∅) = G(H), so this captures acyclic orientations as before. On the other hand, if F are the cover edges of a poset P on [n], oriented upwards, then the acyclic orientations of G(K n , F ) (i.e., we take H as the complete graph on [n]) are in 1-to-1 correspondence with the linear extensions of P , and reversing an arc corresponds to an adjacent transposition. Savage [Sav97] asked whether G(H, F ) admits a Hamilton cycle whenever its partition classes have the same size, but a counterexample was constructed by Naatz [Naa01]. Pruesse and Ruskey [PR95] also give an example showing that the prism of G(H, F ) need not be Hamiltonian, and Squire [Squ94] strengthened this by an example showing that the square G 2 (H, F ) need not be Hamiltonian. In general, it is open under which conditions G(H, F ) or its prism or square admit a Hamilton path or cycle. As this generalizes Ruskey's conjecture discussed in Section 5.5, this is arguably a hard problem.
Pilaud [Pil21] equipped G(H) with a poset structure, and found conditions on H for when this poset is a lattice with various additional properties. P56 He also describes the corresponding lattice congruences and realizations of their quotients as polytopes, and he raises the question whether they admit a Hamilton cycle. Cardinal, Hung, Merino, and Mütze [CHMM22] answered a slightly weaker version of this question, namely for Hamilton paths instead of cycles, and those can be computed with a simple greedy algorithm.

Vertex colorings
Choo and MacGillivray [CM11] consider the flip graph G(H, k) of k-colorings of a fixed graph H, where two colorings are adjacent if they differ in the color of a single vertex of H. They showed that for every H there is a minimum integer k 0 (H), such that for all k ⩾ k 0 (H), the flip graph G(H, k) admits a Hamilton cycle. They also proved that k 0 (K n ) = n + 1 for n ⩾ 2, k 0 (C n ) = 4 for n ⩾ 3, and for any tree H we have k 0 (H) = 3, unless H is a star with an odd number of vertices, in which case k 0 (H) = 4. Celaya, Choo, MacGillivray and Seyffarth [CCMS16] proved that k 0 (K a,b ) = 3 if a and b are both odd and k 0 (K a,b ) = 4 otherwise. Bard [Bar14] established the upper bound k 0 (K a 1 ,a 2 ,...,ar ) ⩽ 2r. He also asked whether G(H, k) having a Hamilton cycle implies that G(H, k + 1) also has one. Stijn Cambie showed that the answer is 'No', by taking H as K 5,5 minus a perfect matching (cf. [CvdHJ08]). The resulting graph G (H, 3) has a Hamilton cycle, whereas G(H, 5) is disconnected and hence has none. Cavers and Seyffarth [CS19] showed that any 2-tree H satisfies k 0 (H) ∈ {4, 5}, and they characterized precisely which 2-trees attain which of these two possible values. A 2-tree is obtained from a triangle by repeatedly adding a new vertex that is joined to the end vertices of an existing edge. McDonald [McD15] considers a variation that allows recoloring more than one vertex at a time, namely at most ℓ vertices at a time, and he asked for the minimum ℓ for which the resulting flip graph has a Hamilton cycle.
Haas [Haa12] introduced another kind of flip graph for colorings. Specifically, we consider isomorphism classes of k-colorings of H that differ only in permuting the colors. For a fixed ordering π of the vertices of H, the lexicographically smallest coloring is chosen as the representative of each isomorphism class. The flip graph G(H, π, k) has those representative colorings as vertices, and an edge between any two that differ in the color of a single vertex of H. She showed that if H is a tree on at least 4 vertices and k ⩾ 3, then there is an ordering π such that G(H, π, k) has a Hamilton cycle. She also proved that G(C n , π, k) is connected for all n ⩾ 3, k ⩾ 4 and some π, and she mentions computer experiments suggesting that this flip graph has a Hamilton cycle for n > 5. Haas and MacGillivray [HM18] showed that G (K a,b , π, k) has a Hamilton path for all a, b ⩾ 2, k ⩾ 3, and some π. They also report some positive results for graphs H obtained via unions and joins, and some negative results about H = K a 1 ,a 2 ,...,ar for r ⩾ 3, a i ⩾ 2, k ⩾ r + 1.
Finbow and MacGillivray [FM14] consider the flip graph G(H, k) of vertex partitions of H into at most k independent sets, where two of them are adjacent if they differ by moving a single vertex from one class to another. Note that if H is an independent set of size n (=complement of K n ), then G(H, k) is the flip graph of set partitions with at most k parts under element exchanges. The authors showed that G(H, n) has a Hamilton cycle for every n-vertex graph H except for K n and K n − e, and that G(H, k) has a Hamilton cycle for any tree H with at least 4 vertices and k ⩾ 3.

Vertex labelings
Knor [Kno94] considers all non-isomorphic vertex labelings of an n-vertex graph H with integers 1, . . . , n, and two of these vertex-labeled graphs are adjacent if one can remove and reinsert k edges to transform one graph into the other. For example, if H = P n , then there are n!/2 non-isomorphic labelings of H, and if k = 1 then the flip operation is the well-known Pósa rotation. In general, we write G(H, k) for the corresponding flip graph. It is easy to see that G(H, k) is vertex-transitive, as the neighbors of some vertex labeling of H only depend on H and not on the labeling, which makes this problem an interesting test case for Lovász' conjecture (provided that G(H, k) is connected, which is not always the case). Knor proved that G(P n , 1) has Hamilton cycle for n ⩾ 3, G(C n , 2) has a Hamilton cycle for n ⩾ 4, and G(F n , 1) is Hamilton-connected for n ⩾ 7, where F n is the fork, i.e., the n-vertex graph obtained by appending two vertices to the same end vertex of the path P n−2 . He further showed that G(K a,b , a + b − 2) for a ̸ = b has the Johnson graph J(a + b, a) as a spanning subgraph, so it is Hamilton-connected by the results discussed in Section 4.1 (for a = b an analogous statement holds for J (2a − 1, a)). Another interesting special case is G (K a+1,a , a), which is isomorphic to the odd graph K (2a + 1, a) = O a .

Dominating sets
Adaricheva et al. [ABC + 21] consider the flip graph G(H) of dominating sets of H, where two dominating sets are connected by an edge if they differ by adding or removing a single vertex of H from the set. As the number of dominating sets of any graph H is odd [BCS09], the bipartite graph G(H) has two partition classes of different sizes and therefore no Hamilton cycle, so we only need to to focus on finding Hamilton paths. Note that every nonempty subset of vertices of K n is a dominating set, so G(K n ) is isomorphic to the n-cube Q n minus a single vertex. Similarly, G(K 1,n ) is isomorphic to Q n plus a pending edge attached to one vertex. As Q n has a Hamilton cycle, it follows immediately that G(K n ) and G(K 1,n ) have a Hamilton path. The aforementioned paper shows moreover that G(P n ) has a Hamilton path, and G (K a,b ) has a Hamilton path if and only if a or b is odd (if both are even there are balancedness problems).
[ABB + 22] proved that G(H) has a Hamilton path for any tree H. They also consider the case of cycles H = C n . Note that characteristic vectors of dominating sets of C n are precisely bitstrings of length n that cyclically avoid the factor 000 (three consecutive vertices on C n that are not in the dominating set leave the middle vertex undominated), i.e., they are complements of Lucas words. Therefore, by the results of Baril and Vajnovszki [BV05] discussed in Section 3.16, there is a Hamilton path in G(C n ) if and only if n is not a multiple of 4. Similarly, characteristic vectors of dominating sets of P n are precisely bitstrings of length n that avoid the factor 000 and also 00 at the first or last two positions, which are a proper subset of complemented Fibonacci words.

Degree sequences and 0-1 matrices
Arikati and Peled [AP99] consider degree sequences of graphs, which are integer sequences d = (d 1 , . . . , d n ) for which there exists a simple graph with vertex set [n] such that the degree of the vertex i is d i for all i = 1, . . . , n. The flip graph G(d) has as vertices all graphs that realize the degree sequence d, and two of them are connected by an edge in G(d) if they differ by removing two edges and adding two edges that together form a 4-cycle on [n], an operation that clearly preserves all degrees. The authors proved that G(d) has a Hamilton cycle provided that d has majorization gap 1 (see the paper for definitions). P59 In general, the question whether G(d) admits a Hamilton path or cycle is open.
In the aforementioned paper [AP99], Arkati and Peled point out that Brualdi's problem can be rephrased equivalently using degree sequences as follows: We can interpret an m × n matrix with row and column sums r and s, respectively, as the biadjacency matrix of a bipartite graph with partition classes of sizes m and n. We then turn the bipartite graph into a split graph by adding all edges in one of the partition classes, making this partition class a clique. Note that the degree sequence d of the resulting split graph yields a flip graph G(d) which is isomorphic to G(r, s). This is because in a split graph, every flip operation removes and adds two edges that go between the independent set and the clique. Therefore, Brualdi's question is equivalent to asking whether the flip graph G(d) for the degree sequence d of any split graph admits a Hamilton path or cycle.

Greedy Gray codes
Throughout this survey, we encountered a number of versatile methods for constructing Gray code listings for several different combinatorial objects, by a suitable general encoding of the objects. These include flip-swap languages (Section 3.18), bubble languages (Section 4.2), pattern-avoiding permutations (Section 5.4), linear extensions of posets (Section 5.5), elimination trees (Section 9.4) and acyclic orientations (Section 9.5).
Williams [Wil13] discovered another powerful general paradigm for constructing Gray codes, which he dubbed the greedy approach. The idea is to describe the listing implicitly by an algorithm, in which the next object in the list is defined by applying a flip operation to the preceding object, and this operation is selected greedily from a set of applicable flip operations so as to generate an object which has not been encountered in the list before. Williams showed in his paper that many classical Gray codes can be described by such a greedy rule: • the BRGC for bitstrings (Figure 2  rotate the edge with the largest possible inorder label. Besides describing known Gray codes in a unified way, the greedy approach has proven to be very useful for discovering new Gray codes. One major application of the greedy method are the Gray codes for zigzag languages of permutations introduced by Hartung, Hoang, Mütze and Williams [HHMW22], which include many classes of pattern-avoiding permutations (recall Section 5.4), and which encode several classes of rectangulations [MM21] (recall Section 8.3), elimination trees of chordal graphs [CMM22] (recall Section 9.4), and acyclic orientations of chordal graphs (recall Section 9.5).
These Gray codes derived from the greedy approach all have an underlying hierarchical generation tree, instances of which can be found in several predecessor papers, including Hurtado and Noy's tree of triangulations [HN99], Takaoka's twisted lexico tree [Tak99b], the production trees of the ECO method [BBGP04], and in Li and Sawada's reflectable languages [LS09] (see also [XCU10]). Very recently, Arturo Merino exhibited an underlying connection of the greedy approach to Gray code listings that are genlex. Specifically, if there is a genlex listing of objects using a particular flip operation, where objects with the same prefix (or suffix) appear consecutively, then the greedy rule to perform a flip that modifies the shortest possible suffix (or prefix, respectively) can generate this listing, when using a suitable tie-breaking rule. This explains why the greedy approach works in all the aforementioned cases. More importantly, it vastly extends the applicability of the greedy method to any of the other genlex Gray codes mentioned in this survey. [CL91] [Hol17]