9

Where can I find some code to generate random self-avoiding walks on 2 and 3-dimensional lattices whose side-lengths are powers of two? The walk should pass through every point on the lattice More specifically, how can I find a random hamiltonian path on a large $2^n \times 2^n$ or $2^n \times 2^n \times 2^n$ grid graph?

The distribution doesn't have to be completely uniform, however in general the lattice should look wrinkled. The method used to generate the path should have low probability of producing extremely long stretches of straight line.

Alecto
  • 564
  • 4
  • 13

2 Answers2

6

A procedure is described in A combinatorial algorithm for effective generation of long maximally compact lattice chains.

enter image description here

Tomoki
  • 371
  • 1
  • 3
4

Here are two javascript implementations of an algorithm to sample Hamiltonian paths on 2-dimensional grid graphs: http://clisby.net/projects/hamiltonian_path/ and http://clisby.net/projects/hamiltonian_path/hamiltonian_path_v1.html (This is my code. The implementation at the first link has more features, while the second allows you to download the sequence of sites visited by the path.)

The javascript programs generate Hamiltonian paths on an n × n grid using the backbite move described in the paper “Secondary structures in long compact polymers” by Richard Oberdorf, Allison Ferguson, Jesper L. Jacobsen and Jané Kondev, Phys. Rev. E 74, 051801 (2006). Paper available via the APS (subscription required) or as a pre-print on the arXiv at https://arxiv.org/abs/cond-mat/0508094

The code includes an adjustable parameter that determines how close to the uniform distribution your sample will be, and you could adapt the method (Markov chain Monte Carlo with backbite moves) to 3d grid graphs with a little work.

Nathan
  • 141
  • 3