Star transposition Gray codes for multiset permutations

Given integers k ≥ 2 $k\ge 2$ and a 1 , … , a k ≥ 1 ${a}_{1},\ldots ,{a}_{k}\ge 1$ , let a ≔ ( a 1 , … , a k ) ${\boldsymbol{a}}:= ({a}_{1},\ldots ,{a}_{k})$ and n ≔ a 1 + ⋯ + a k $n:= {a}_{1}+\cdots \,\,+{a}_{k}$ . An a‐multiset permutation is a string of length n $n$ that contains exactly a i ${a}_{i}$ symbols i $i$ for each i = 1 , … , k $i=1,\ldots ,k$ . In this work we consider the problem of exhaustively generating all a ${\boldsymbol{a}}$ ‐multiset permutations by star transpositions, that is, in each step, the first entry of the string is transposed with any other entry distinct from the first one. This is a far‐ranging generalization of several known results. For example, it is known that permutations ( a 1 = ⋯ = a k = 1 ${a}_{1}=\cdots \,={a}_{k}=1$ ) can be generated by star transpositions, while combinations ( k = 2 $k=2$ ) can be generated by these operations if and only if they are balanced ( a 1 = a 2 ${a}_{1}={a}_{2}$ ), with the positive case following from the middle levels theorem. To understand the problem in general, we introduce a parameter Δ ( a ) ≔ n − 2 max { a 1 , … , a k } ${\rm{\Delta }}({\boldsymbol{a}}):= n-2\max \{{a}_{1},\ldots ,{a}_{k}\}$ that allows us to distinguish three different regimes for this problem. We show that if Δ ( a ) < 0 ${\rm{\Delta }}({\boldsymbol{a}})\lt 0$ , then a star transposition Gray code for a‐multiset permutations does not exist. We also construct such Gray codes for the case Δ ( a ) > 0 ${\rm{\Delta }}({\boldsymbol{a}})\gt 0$ , assuming that they exist for the case Δ ( a ) = 0 ${\rm{\Delta }}({\boldsymbol{a}})=0$ . For the case Δ ( a ) = 0 ${\rm{\Delta }}({\boldsymbol{a}})=0$ we present some partial positive results. Our proofs establish Hamilton‐connectedness or Hamilton‐laceability of the underlying flip graphs, and they answer several cases of a recent conjecture of Shen and Williams. In particular, we prove that the middle levels graph is Hamilton‐laceable.


Introduction
Permutations and combinations are two of the most fundamental classes of combinatorial objects. Specifically, k-permutations are all linear orderings of [k] := {1, . . . , k}, and their number is k!. Moreover, (α, β)-combinations are all β-element subsets of [n] where n := α + β, and their number is n α = n β . Permutations and combinations are generalized by so-called multiset permutations, and in this paper we consider the task of listing them such that any two consecutive objects in the list differ by particular transpositions, i.e., by swapping two elements. Such a listing of objects subject to a "small change" operation is often referred to as Gray code [27,30]. One of the standard references for algorithms that efficiently generate various combinatorial objects, including permutations and combinations, is Knuth's book [19] (see also [25]).

Permutation generation
There is a vast number of Gray codes for permutation generation, most prominently the Steinhaus-Johnson-Trotter algorithm [18,40], which generates all k-permutations by adjacent transpositions, i.e., swaps of two neighboring entries of the permutation; see Figure 1 (a). In this work, we focus on star transpositions, i.e., swaps of the first entry of the permutation with any later entry. An efficient algorithm for generating permutations by star transpositions was found by Ehrlich, and it is described as Algorithm E in Knuth's book [19, Section 7.2.1.2]; see Figure 1 (b). For any permutation generation algorithm based on transpositions, we can define the transposition graph as the graph with vertex set [k], and an edge between i and j if the algorithm uses transpositions between the ith and jth entry of the permutation. Clearly, the transposition graph for adjacent transpositions is a path, whereas the transposition graph for star transpositions is a star (hence the name "star transposition"). In fact, Kompel'maher and Liskovec [20], and independently Slater [36], showed that all k-permutations can be generated for any transposition tree on [k]. Transposition Gray codes for permutations with additional restrictions were studied by Compton and Williamson [7] and by Shen and Williams [33].

34:3
Several known algorithms for permutation generation use operations other than transpositions. Specifically, Zaks [43] presented an algorithm for generating permutations by prefix reversals; see Figure 1 (c). Moreover, Corbett [8] showed that all k-permutations can be generated by cyclic left shifts of any prefix of the permutation by one position; see Figure 1 (d). Another notable result is Sawada and Williams' recent solution [32] of the Sigma-Tau problem, proving that all k-permutations can be generated by cyclic left shifts of the entire permutation by one position or transpositions of the first two elements; see Figure 1 (e).
All of the aforementioned results can be seen as explicit constructions of Hamilton paths in the Cayley graph of the symmetric group, generated by different sets of generators (transpositions, reversals, or shifts). It is an open problem whether the Cayley graph of the symmetric group has a Hamilton path for any set of generators [28]. This is a special case of the well-known open problem whether any connected Cayley graph has a Hamilton path, or even more generally, whether this is the case for any vertex-transitive graph [21].

Combination generation and the middle levels conjecture
In a computer, (α, β)-combinations can be conveniently represented by bitstrings of length n := α + β, where the ith bit is 1 if the element i is in the set and 0 otherwise. For example, the (5, 3)-combination {1, 6, 7} is represented by the string 10000110.
In the 1980s, Buck and Wiedemann [3] conjectured that all (α, α)-combinations can be generated by star transpositions for every α ≥ 1, i.e., in every step we swap the first bit of the bitstring representation with a later bit. Figure 2 (a) shows such a star transposition Gray code for (4, 4)-combinations. Buck and Wiedemann's conjecture was raised independently by Havel [15], as a question about the existence of a Hamilton cycle through the middle two levels of the (2α − 1)-dimensional hypercube. This conjecture became known as middle levels conjecture, and it attracted considerable attention in the literature and made its way into popular books [9,42], until it was answered affirmatively by Mütze [23]; see also [13].

Multiset permutations
Shen and Williams [34] proposed a far-ranging generalization of the middle levels conjecture that connects permutations and combinations. Their conjecture is about multiset permutations. For integers k ≥ 2 and a 1 , . . . , a k ≥ 1, an (a 1 , . . . , a k )-multiset permutation is a string over the alphabet {1, . . . , k} that contains exactly a i occurrences of the symbol i. We refer to the sequence a := (a 1 , . . . , a k ) as the frequency vector, as it specifies the frequency of each symbol. The length of a multiset permutation is n a := a 1 + · · · + a k , and if the context is clear we omit the index and simply write n = n a . If all symbols appear equally often, i.e., a 1 = · · · = a k = α, we use the abbreviation α k := (a 1 , . . . , a k ). For example 123433153 is a (2, 1, 4, 1)-multiset permutation, and 331232142144 is a 3 4 -multiset permutation.
Clearly, multiset permutations are a generalization of permutations and combinations. Specifically, k-permutations are 1 k -multiset permutations, and (α, β)-combinations are (α, β)multiset permutations (up to shifting the symbol names 1, 2 → 0, 1). Stachowiak [37] showed that (a 1 , . . . , a k )-multiset permutations can be generated by adjacent transpositions if and only if at least two of the a i are odd.  [34] conjectured that all α k -multiset permutations can be generated by star transpositions, for any α ≥ 1 and k ≥ 2. We state their conjecture in terms of Hamilton cycles in a suitably defined graph, as follows. We write Π(a) = Π(a 1 , . . . , a k ) for the set of all (a 1 , . . . , a k )-multiset permutations. Moreover, we let G(a) = G(a 1 , . . . , a k ) denote the graph on the vertex set Π(a) = Π(a 1 , . . . , a k ) with an edge between any two multiset permutations that differ in a star transposition, i.e., in swapping the first entry of the multiset permutation with any entry at positions 2, . . . , n that is distinct from the first one. Figure 3 shows various examples of the graph G(a). When denoting specific multiset permutations we sometimes omit commas and brackets for brevity, for example 1312214 ∈ Π(3, 2, 1, 1).
In this and the following statements, the single edge G(1, 1) is also considered a cycle, as it gives a cyclic Gray code. Note that G(a 1 , . . . , a k ) is vertex-transitive if and only if a 1 = · · · = a k =: α. In this case, Conjecture 1 is an interesting instance of the aforementioned conjecture of Lovász [21] on Hamilton paths in vertex-transitive graphs.
Evidence for Conjecture 1 comes from the results mentioned in Sections 1.1 and 1.2 on generating permutations by star transpositions and the solution of the middle levels conjecture, respectively, formulated in terms of the graph G(a) below. These known results settle the boundary cases α = 1 and k ≥ 2, and α ≥ 1 and k = 2, respectively, of Conjecture 1.
In their paper, Shen and Williams also provided an ad-hoc solution for the first case of their conjecture that is not covered by Theorems 2 and 3, namely a Hamilton cycle in G(2, 2, 2), which is displayed in Figure 2 We approach Conjecture 1 by tackling the following even more general question: For which frequency vectors a = (a 1 , . . . , a k ) does the graph G(a) have a Hamilton cycle? By renaming symbols, we may assume w.l.o.g. that the entries of the vector a are non-increasing, i.e., We can thus think of the vector a as an integer partition of n.

Our results
For any i ∈ [n] and c ∈ [k], we write Π(a) i,c for the set of all multiset permutations from Π(a) whose ith symbol equals c. Note that every star transposition changes the first entry; see the inner track of each of the two wheels in Figure 2. As a consequence, G(a) is a k-partite graph with partition classes Π(a) 1,1 , . . . , Π(a) 1,k ; see Figure 3. Moreover, the partition class Π(a) 1,1 is a largest one because of (1). This k-partition of the graph G(a) is a potential obstacle for the existence of Hamilton cycles and paths. Specifically, if one partition class is larger than all others combined, then there cannot be a Hamilton cycle, and if the size difference is more than 1, then there cannot be a Hamilton path. We capture this by defining a parameter ∆(a) for any integer partition a = (a 1 , . . . , a k ) as S TA C S 2 0 2 2 34:6

Star Transposition Gray Codes for Multiset Permutations
We will see that if ∆(a) < 0, then the partition class Π(a) 1,1 of the graph G(a) is larger than all others combined, excluding the existence of Hamilton cycles. On the other hand, if ∆(a) ≥ 0, then every partition class of the graph G(a) is at most as large as all others combined (equality holds if ∆(a) = 0), which does not exclude the existence of a Hamilton cycle. The cases with ∆(a) = 0 lie on the boundary between the two regimes, and they are the hardest in terms of proving Hamiltonicity. These cases can be seen as generalizations of the middle levels conjecture, namely the case a = (α, α) captured by Theorem 3, which also satisfies ∆(a) = 0. For k = 2 symbols, the condition ∆(a) < 0 is equivalent to a 1 > a 2 , i.e., there is no star transposition Gray code for "unbalanced" combinations.
We now discuss the cases ∆(a) ≥ 0. Our first main goal is to reduce all cases with ∆(a) > 0 to cases with ∆(a) = 0. For doing so, it is helpful to consider stronger notions of Hamiltonicity. Specifically, we consider Hamilton-connectedness and Hamilton-laceability, which have been heavily studied (see [1,2,6,14,16,35]). A graph is called Hamilton-connected if there is a Hamilton path between any two distinct vertices. A bipartite graph is called Hamiltonlaceable if there is a Hamilton path between any pair of vertices from the two partition classes. In general, the graphs G(a) are not bipartite, so we say that G(a) is 1-laceable if there is a Hamilton path between any vertex in Π(a) 1,1 and any vertex not in Π(a) 1,1 , i.e., between any vertex with first symbol 1 and any vertex with first symbol distinct from 1.
This approach is inspired by the following result of Tchuente [39], who strengthened Theorem 2 considerably.
The key insight is that proving a stronger property makes the proof easier and shorter, because the inductive statement is more powerful and flexible; see Section 3.2 below. Encouraged by this, we raise the following conjecture about graphs G(a) with ∆(a) = 0. It is another natural and far-ranging generalization of the middle levels conjecture, which we support by extensive computer experiments and by proving some special cases. The dependence of Theorem 7 on Conjecture 6 can be captured more precisely. Specifically, G(a) with ∆(a) > 0 is shown to be Hamilton-connected, assuming that G(b) with ∆(b) = 0 is Hamilton-1-laceable for all integer partitions b that are majorized componentwise by a.
The three exceptions mentioned in Theorem 7 are well understood: Specifically, G(1, 1, 1) is a 6-cycle; see Figure 3. Furthermore, G(1 k ) for k ≥ 4 is Hamilton-laceable by Theorem 5. Lastly, we will show that G(α, α, 1) for α ≥ 3 satisfies a variant of Hamilton-laceability, which also guarantees a Hamilton cycle. In fact, we believe that G(α, α, 1) is Hamilton-connected, but we cannot prove it.
We provide the following evidence for Conjecture 6.
We also have the following (unconditional) result for k = 3 symbols.

Proof ideas
In this section, we give a high-level overview of the main ideas and techniques used in our proofs. No formal proofs of our results are presented in this extended abstract due to space constraints, but they can be found in the preprint [12].

The case ∆(a) < 0
The main idea for proving Theorem 4 is that if ∆(a) < 0, then the partition class Π(a) 1,1 of the graph G(a) is larger than all others combined, which excludes the existence of a Hamilton cycle. To exclude the existence of a Hamilton path, we show that the size difference is strictly more than 1, unless a = (2, 1). Note that the graph G(2, 1) is the path on three vertices, so in this case the size difference is precisely 1. These arguments are based on straightforward algebraic manipulations involving multinomial coefficients.

The case ∆(a) > 0
To prove Theorem 7, it is convenient to think of an integer partition a = (a 1 , . . . , a k ) as an infinite non-increasing sequence (a 1 , a 2  Specifically, for any a = (a 1 , . . . , a k ), i = 2, . . . , n, and c ∈ [k], the subgraph of G(a) induced by the vertex set Π(a) i,c is isomorphic to G(b) where b is the partition obtained from a by decreasing a i by 1 (and possibly sorting the resulting numbers non-increasingly); see Figure 5.
Moreover While conceptually simple, implementing this idea incurs considerable technical obstacles, in particular for some of the graphs G(a) with ∆(a) = 1, i.e., instances that are very close to the hyperplane ∆(a) = 0. The proof is split into several interdependent lemmas, and it is the technically most demanding part of our work.
Theorem 10 follows immediately from the inductive proof of Theorem 7 and by settling finitely many cases with computer help.
To further illustrate the ideas outlined before, we close this section by reproducing Tchuente's proof of Theorem 5.
The following arguments are illustrated in Figure 6. The partition classes of the graph G(1 k ) are given by the parity of the permutations, i.e., by the number of inversions. Therefore, we consider two distinct permutations x and y of [k] with opposite parity, and we need to show how to connect them by a Hamilton path in G(1 k ). As x ̸ = y, there is a positionî > 1 in which x and y differ, i.e., xî ̸ = yî, and this is the position that we will fix to different symbols. Specifically, we choose a permutation π of [k] such that π 1 = xî and π k = yî. The permutation π captures the order in which we will fix symbols at positionî. We then choose permutations u j , v j of [k], j = 1, . . . , k, satisfying u 1 = x, v k = y, and such that u j is obtained from v j−1 by a star transposition of the symbol π j at position 1 with the symbol π j−1 at positionî, for all j = 2, . . . , k. Moreover, we choose u j and v j such that the parity of the number of inversions after removing the symbol π j is opposite. Specifically, for u j this parity is the same as for u 1 = x if and only if π j has the same parity as π 1 , and for v j this parity is the same as for v k = y if and only if π j has the same parity as π k . For each j = 1, . . . , k, we now consider the permutations whoseîth entry equals π j (formally, this is the set Π(1 k )î ,πj ). Clearly, the subgraph of G(1 k ) induced by these permutations is isomorphic to G(1 k−1 ). In other words, by removing theîth entry and renaming entries to 1, . . . , k − 1, we obtain permutations of [k − 1]. Consequently, by induction there is a path in G(1 k ) that visits all permutations whoseîth entry equals π j and that connects u j to v j . The concatenation of those k paths obtained by induction is the desired Hamilton path in G(1 k ) from x to y, which completes the induction step. ◀ Note that the constraints imposed on the permutations π and u j , v j , j = 1, . . . , k, in this proof are very mild, and leave a lot of room for modifications to construct many different Hamilton paths, possibly so as to satisfy some additional conditions.

The case ∆(a) = 0
Our proofs of Theorems 8 and 9 build on ideas introduced in the papers [13,22].
Specifically, the first step in proving Theorem 8 is to build a cycle factor in the graph G(α, α), i.e., a collection of disjoint cycles in the graph that together visit all vertices. We then choose vertices x and y from the two partition classes of the graph that we want to connect by a Hamilton path. In this we can take into account automorphisms of G(α, α), i.e., for proving laceability only certain pairs of vertices x and y in the two partition classes have to be considered. In the next step, we join a small subset of cycles from the factor, including the ones containing x and y, to a short path between x and y. This is achieved by taking the symmetric difference of the edge set of the cycle factor with a carefully chosen path P from x to y that alternately uses edges on one of the cycles from the factor and edges that go between two such cycles; see Figure 7 (a)+(b). In the last step, we join the remaining cycles of the factor to the path between x and y, until we end with a Hamilton path from x to y. Each such joining is achieved by taking the symmetric difference of the cycle factor with a suitably chosen 6-cycle; see Figure 7 (b)+(c).
It was shown in [13] that the cycles of the aforementioned cycle factor in G(α, α) are bijectively equivalent to plane trees with α vertices, and the joining operations via 6-cycles can be interpreted combinatorially as local change operations between two such plane trees. To prove Theorem 9, we first generalize the construction of this cycle factor in the graph G(α, α) to a cycle factor in any graph G(a), a = (a 1 , . . . , a k ), with ∆(a) = 0. It turns out that the cycles of this generalized factor can be interpreted combinatorially as vertex-labeled  = (α, α), then all vertex labels are the same, so we can consider the trees as unlabeled. Moreover, the joining 6-cycles in G(α, α) generalize nicely to joining 12-or 6-cycles in G(a) with ∆(a) = 0, and they correspond to local change operations involving sets T of labeled plane trees with |T | ∈ {2, 3, 5, 6}, depending on the location of vertex labels. For proving Theorem 9, we consider the special case a = (α, α − 1, 1), i.e., exactly one vertex in the plane trees is labeled differently from all other vertices, and we show that there is a choice of joining cycles so that the symmetric difference with the cycle factor yields a Hamilton cycle in the graph G(a).

Open questions
We conclude this paper with the following open questions.
We believe that the ideas outlined in Section 3.3 to prove that G(α, α − 1, 1) has a Hamilton cycle are in principle suitable to prove that G(a) has a Hamilton cycle for all a with ∆(a) = 0, which would be an important first step towards a proof of Conjecture 6. In particular, the construction of the cycle factor and gluing tuples based on vertex-labeled plane trees are fully general. The main difficulty in combining these ingredients lies in the fact that some gluing cycles join more than two cycles from the factor (namely 3, 5, or 6 cycles) to a single cycle, and in this case the resulting interactions between different gluing cycles seem to be hard to control. We conjecture that G(α, α, 1) for α ≥ 2 is Hamilton-connected, just as all other graphs G(a) with ∆(a) > 0 covered by Theorem 7. However, we are unable to prove this based on Conjecture 6. With computer help, we verified that G(α, α, 1) is Hamilton-connected for α = 2, 3, 4. Proving this in general would streamline our proof of Theorem 7 considerably, as it would make several auxiliary lemmas redundant. To prove that G(α, α, 1) is Hamilton-connected, it may help to establish a Hamiltonicity property for graphs G(a) with ∆(a) = 0 and k ≥ 3 that is stronger than 1-laceability. Specifically, in addition to a Hamilton path between any vertex in Π(a) 1,1 and any vertex not in Π(a) 1,1 , we may also ask for a Hamilton path between any two distinct vertices in Π(a) 1,1 . We checked by computer whether G(a) has this stronger property for a ∈ {(2, 1, 1), (3, 2, 1), (3, 1, 1, 1), (4, 3, 1), (4, 2, 2), (4, 2, 1, 1), (4, 1, 1, 1, 1)}, and it was satisfied in all cases except for a = (2, 1, 1). While our proofs are constructive, they are far from yielding efficient algorithms for computing the corresponding Gray codes. Ideally, one would like algorithms whose running time is polynomial in n per generated multiset permutation of length n. Such algorithms are known for the Hamilton cycles mentioned in Theorems 2 and 3, see [19, Section 7.2.1.2] and [24], respectively. An interesting direction could be to explore greedy algorithms for generating multiset permutations by star transpositions, which may yield much simpler constructions to start with, cf. [41,4,31].

34:12 Star Transposition Gray Codes for Multiset Permutations
Knuth raised the question whether there are star transposition Gray codes for (α, α)combinations whose flip sequence can be partitioned into 2α − 1 blocks, such that each block is obtained from the previous one by adding +1 modulo 2α − 1. This problem is a strengthening of the middle levels conjecture, and it was answered affirmatively in [22]. The Gray code for (4, 4)-combinations shown in Figure 2 (a) has such a 7-fold cyclic symmetry. We can ask more generally: Are there star transposition Gray codes for multiset permutations whose flip sequence can be partitioned into n − 1 blocks, such that each block is obtained from the previous one by adding +1 modulo n − 1? Figure 8 shows an ad-hoc solution for (2, 2, 2)-multiset permutations with 5-fold cyclic symmetry.
A more general version of the problem considered in this paper is the following: We consider an alphabet {1, . . . , k} of size k ≥ 2, and frequencies a 1 , . . . , a k ≥ 1 that specify that symbol i appears exactly a i times for all i = 1, . . . , k. Moreover, there is an additional integer parameter s with 1 ≤ s ≤ k − 1 that has the following significance. The objects to be generated are all pairs (S, x), where S is a set or string of s distinct symbols, and x is a string of the remaining n − s symbols, where n := a 1 + · · · + a k . A star transposition swaps one symbol from S with one symbol from x that is currently not in S, and the question is whether there is a star transposition Gray code for all those objects.
Note that multiset permutations considered in this paper are the special case when s = 1. Andrea Sportiello suggested this problem with a 1 = · · · = a k = α (uniform frequency) and S being a set as a generalization of the middle levels conjecture (s = 1, k = 2, a 1 = a 2 = α). Moreover, Ajit A. Diwan suggested this problem with a 1 = · · · = a k = α (uniform frequency) and a set S of size s = k − 1. Note that the uniform frequency case is particularly interesting, as the underlying flip graph for this problem is vertex-transitive if and only if a 1 = · · · = a k (recall Lovász' conjecture [21]).