# Hamiltonian paths where the vertices are integer partitions

Hello,

I have been working on this problem for several months now but have not made much progress. It concerns the set of all integer partitions of n.

Let the vertices of the graph G=G(n) denote all the p(n) integer partitions of n. There is an edge between two partitions if and only if one can be transformed into another by only moving one dot between rows in their Ferrers diagram representations.

So, for example, the partitions (3,2,1) and (3,3) of 6 are linked because we can move the dot in the last row to the second row.

OOO               OOO
OO      --------  OOO
O


My question: for what values of n does G(n) have a Hamiltonian path from (n) to (1,1,...,1)?

That is, is it possible to go through, without repetition, all the partitions of n by simply moving around the dots in the Ferrers diagrams?

Is there a determinate way to construct such paths?

I have only been able to construct paths for n = 1 to 6.

n=1 (trivial)

n=2: (2) => (1,1)

n=3:
(3) => (2,1) => (1,1,1)

n=4:
(4) => (3,1) => (2,2) => (2,1,1) => (1,1,1,1)

n=5: (5) => (4,1) => (3,2) => (2,2,1) => (3,1,1) => (2,1,1,1) => (1,1,1,1,1)

n=6: (6) => (5,1) => (4,1,1) => (4,2) => (3,3) => (3,2,1) => (2,2,2) => (2,2,1,1) => (3,1,1,1) => (2,1,1,1,1) => (1,1,1,1,1,1)

None of the basic theorems about Hamiltonian paths have not helped me here.

-

What you want is known as a Gray code for integer partitions.

It exists.

See C. D. Savage, Gray code sequences of partitions, Journal of Algorithms 10 (1989) 577-595. Disclaimer: I haven't actually read this paper. Other sources such as this 1997 survey by Savage and these class notes don't say what the construction is but say that it's complicated.

-
Gosh, thanks! I would never have known about Gray codes if it wasn't for you! –  Burhan Feb 23 '10 at 1:22

There are two great general sources for Gray codes on combinatorial objects you might enjoy:

1) Frank Ruskey's "Combinatorial Generation" book: http://tinyurl.com/yly4pq7

2) Don Knuth's "Art of Computer Programming", Vol. 4, Fascicle 2-4 (published separately - all excellent), see http://www-cs-faculty.stanford.edu/~uno/taocp.html

Preliminary versions of some of these can be downloaded from the internet archive: http://tinyurl.com/yfo57t4

-
Thank you for the links. I know you, Prof. I attended several of your IAP classes back when I was an undergrad at MIT. –  Burhan Feb 23 '10 at 8:22

There seems to be a general pattern indicated by your $n=6$ example. Here is a path for $n=7$:

1.  7
2.  6 + 1
3.  5 + 2
4.  5 + 1 + 1
5.  4 + 1 + 1 + 1
6.  4 + 2 + 1
7.  4 + 3
8.  3 + 3 + 1
9.  3 + 2 + 2
10. 2 + 2 + 2 + 1
11. 3 + 2 + 1 + 1
12. 3 + 1 + 1 + 1 + 1
13. 2 + 2 + 1 + 1 + 1
14. 2 + 1 + 1 + 1 + 1 + 1
15. 1 + 1 + 1 + 1 + 1 + 1 + 1


I have written this so that it is obvious that all 15 partitions of 7 are accounted for. Note the 10th partition.

Here is one for $n = 8$:

1.  8
2.  7 + 1
3.  6 + 2
4.  6 + 1 + 1
5.  5 + 1 + 1 + 1
6.  5 + 2 + 1
7.  5 + 3
8.  4 + 4
9.  4 + 3 + 1
10. 4 + 2 + 2
11. 4 + 2 + 1 + 1
12. 4 + 1 + 1 + 1 + 1
13. 3 + 1 + 1 + 1 + 1 + 1
14. 3 + 2 + 1 + 1 + 1
15. 3 + 3 + 1 + 1
16. 3 + 2 + 2 + 1
17. 3 + 3 + 2
18. 2 + 2 + 2 + 2
19. 2 + 2 + 2 + 1 + 1
20. 2 + 2 + 1 + 1 + 1 + 1
21. 2 + 1 + 1 + 1 + 1 + 1 + 1
22. 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1


$n=9$:

1.  9
2.  8 + 1
3.  7 + 2
4.  7 + 1 + 1
5.  6 + 1 + 1 + 1
6.  6 + 2 + 1
7.  6 + 3
8.  5 + 4
9.  5 + 3 + 1
10. 5 + 2 + 2
11. 5 + 2 + 1 + 1
12. 5 + 1 + 1 + 1 + 1
13. 4 + 1 + 1 + 1 + 1 + 1
14. 4 + 2 + 1 + 1 + 1
15. 4 + 2 + 2 + 1
16. 4 + 3 + 1 + 1
17. 4 + 4 + 1
18. 4 + 3 + 2
19. 3 + 3 + 3
20. 3 + 3 + 2 + 1
21. 3 + 2 + 2 + 2
22. 2 + 2 + 2 + 2 + 1
23. 3 + 2 + 2 + 1 + 1
24. 3 + 3 + 1 + 1 + 1
25. 3 + 2 + 1 + 1 + 1 + 1
26. 2 + 2 + 2 + 1 + 1 + 1
27. 3 + 1 + 1 + 1 + 1 + 1 + 1
28. 2 + 2 + 1 + 1 + 1 + 1 + 1
29. 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1
30. 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1

-
Thank you for the code for n=7. –  Burhan Feb 23 '10 at 8:23
What is the pattern here? –  Michael Lugo Feb 24 '10 at 1:26
It would probably have been better to say characteristics than pattern. The oscillatory behavior is what I had in mind, along with the appearance that even numbers are easier. –  Steve Huntsman Feb 24 '10 at 3:15
i still have not read the savage paper. my university's online subscription does not cover that particular issue of the Journal of Algorithm, so i guess i will have to goto another library to read it. it seems that most of the secondary literature does not provide his explicit construction. but they all say it is complicated, and it would be a cool research project to try to simplify it (or show that a simplification is impossible). the ruskey book, p. 175, gives some details. –  Burhan Feb 25 '10 at 16:41

If you mean to allow any part to go down 1 and any part (or 0) to go up 1, while maintaining non-increasing order, then Carla Savage's 1989 paper does in fact solve your problem (without requiring "double moves" as in the 10th listed partition of 7 above).

There are refinements of this operation in the literature. If you only allow a dot to "fall" into an adjacent part, i.e., from $(\ldots, p_i, p_{i+1}, \ldots)$ with $p_i \geq p_{i+1}+2$ to $(\ldots, p_i - 1, p_{i+1}+1, \ldots)$, that is called the "sandpile operation" or Brylawski's vertical rule. There is a transpose horizontal rule, and restictions of these called $\theta$ operations and "ice pile" operations, respectively. For some of these operations, the set of partitions of $n$ is not a connected graph, much less one with a Hamiltonian path. A survey article on these operations is available at http://www-rp.lip6.fr/~latapy/Publis/tcs04a.pdf

-