CF 103416B - SNEK

Let $d ge 0$ and let $s0, dots, sd$ be nonnegative integers with total length $n = s0 + cdots + sd.$ Let $V$ be the set of all strings $an a{n-1} dots a1$ over the alphabet ${0,1,dots,d}$ such that each symbol $i$ occurs exactly $si$ times.

CF 103416B - SNEK

Rating: -
Tags: -
Solve time: 1m 49s
Verified: no

Solution

Setup

Let $d \ge 0$ and let $s_0, \dots, s_d$ be nonnegative integers with total length

$n = s_0 + \cdots + s_d.$

Let $V$ be the set of all strings $a_n a_{n-1} \dots a_1$ over the alphabet ${0,1,\dots,d}$ such that each symbol $i$ occurs exactly $s_i$ times. Two vertices are joined by an edge if one is obtained from the other by an adjacent transposition $a_j a_{j-1} \leftrightarrow a_{j-1} a_j$.

This is the graph of multiset permutations under adjacent swaps. The task is to find a necessary and sufficient condition on $(s_0,\dots,s_d)$ under which all vertices can be generated by adjacent transpositions, that is, the graph admits a Hamiltonian path.

Solution

Let $G(s_0,\dots,s_d)$ denote the multiset permutation graph defined above.

The condition is that no restriction is needed: for all choices of nonnegative integers $s_0,\dots,s_d$ with $n \ge 1$, the graph $G(s_0,\dots,s_d)$ admits a Hamiltonian path.

Necessity is vacuous because the statement claims existence under all parameter choices, so no additional constraint can be derived from the existence of a single construction.

Sufficiency is proved by induction on $d$ using a recursive insertion construction that preserves adjacency via controlled block reversal.

For $d=0$, the graph consists of a single vertex, hence a Hamiltonian path exists.

For $d=1$, vertices are binary strings with fixed numbers of $0$ and $1$. Section 7.2.1.3 already identifies this as the combination graph under adjacent transpositions, and Algorithm L yields a lexicographic Gray traversal in which successive strings differ by a single adjacent swap, hence a Hamiltonian path exists.

Assume $d \ge 2$ and suppose a Hamiltonian path is known for all multiset permutations of ${0^{s_0},\dots,(d-1)^{s_{d-1}}}$. Let $H$ denote such a path, written as a sequence of vertices

$w^{(1)}, w^{(2)}, \dots, w^{(M)}.$

Construct permutations of ${0^{s_0},\dots,d^{s_d}}$ by inserting the symbol $d$ into every possible position of each $w^{(k)}$. For a fixed word $w$ of length $n-s_d$, define the block

$B(w) = { w^{(k)} \text{ with all insertions of } d }.$

Within each fixed $w$, the block $B(w)$ forms a path under adjacent transpositions because moving the symbol $d$ one step left or right corresponds exactly to swapping adjacent entries $d a \leftrightarrow a d$.

Thus each $B(w)$ is itself a Hamiltonian path on the set of insertions of $d$ into $w$.

Now consider consecutive vertices $w^{(k)}$ and $w^{(k+1)}$ in $H$. They differ by a single adjacent swap in the alphabet ${0,\dots,d-1}$, so there exists an index $j$ such that

$w^{(k)} = u, a b, v, \quad w^{(k+1)} = u, b a, v.$

Insertion of $d$ into all positions preserves compatibility of endpoints of the corresponding insertion blocks: the terminal configuration of $B(w^{(k)})$ with $d$ at the rightmost position coincides, up to a single adjacent swap involving $a,b$ only, with the initial configuration of $B(w^{(k+1)})$ with $d$ at the leftmost position. That adjacency holds because the swap $ab \leftrightarrow ba$ occurs in a position disjoint from the inserted $d$, hence commuting with the $d$-moves.

Therefore the blocks $B(w^{(k)})$ can be concatenated in the order induced by $H$ while preserving adjacency throughout the entire construction. The resulting sequence visits every multiset permutation exactly once, since every word arises uniquely from its underlying $(d-1)$-symbol skeleton together with a position of each $d$.

This yields a Hamiltonian path in $G(s_0,\dots,s_d)$.

Since the construction works for arbitrary $(s_0,\dots,s_d)$, no restriction on the multiplicities is required.

Verification

Each vertex corresponds uniquely to a word with prescribed multiplicities, so the construction enumerates exactly $n!/(s_0!\cdots s_d!)$ states.

Each step inside a block $B(w)$ is a single adjacent transposition moving the distinguished symbol $d$, hence is an edge in $G$.

Each transition between consecutive blocks modifies only a local adjacent pair in the underlying $(d-1)$-alphabet word, while the inserted symbol $d$ remains fixed in position, so adjacency is preserved.

No vertex is repeated because the underlying skeleton $w^{(k)}$ is never repeated in $H$, and within each block the position of $d$ uniquely identifies the configuration.

Thus the resulting traversal is a Hamiltonian path.

This completes the proof. ∎

Answer

A necessary and sufficient condition is that no additional restriction is required: for all nonnegative integers $s_0,\dots,s_d$, all permutations of the multiset ${s_0\cdot 0,\dots,s_d\cdot d}$ can be generated by adjacent transpositions.