Bracelet enumeration

96 Views Asked by At

Apologies if this has been asked and answered but I can't seem to find a solution! I am looking for a way to enumerate or list all of the bracelets for a given number of beads, without repetition of beads.

For example, in a bracelet of $n$ beads from a choice of $n$ different colours:

$1,2,3$ is equivalent in rotation and reflection to $2,3,1$ and $3,2,1$ respectively, which is standard for bracelet, but with this variety of bracelet I'm looking at $1,1,2$, for example, is not allowed.

I think I have found formulae which can give me the number of possibilities:

$\frac{n!}{2n}$ or $\frac{(n-1)!}{2}$ where $n\ge3$

In the case of $n = 3$, there is $1$ possibility, and for $n = 4$, there are $3$. However, I have no way to list them except by hand, and can find no calculator or program which can do this. The number I am looking for is $n = 6$ for which there should be $60$ possibilities. Apparently the number with repeated beads is $4291$ according to this calculator (https://www.jasondavies.com/necklaces/), but I'm not familiar with the calculation or algorithm used, or how to modify it to remove duplicate beads (Joe Sawada’s Generating Bracelets in Constant Amortized Time, https://dl.acm.org/doi/10.1137/S0097539700377037).

If you happen to know of a resource that would help with this or even know of a way to get Python/Java/etc. to do it that would be great. The reason I need a way to calculate it is that I want to feed in differently named 'beads' and get all $60$ distinct permutations of this kind.

Many thanks!

1

There are 1 best solutions below

1
On

To get all bracelets made of the numbers $\{1,\dots,n\}$, start by generating all permutations of the numbers $\{1,\dots,n-1\}$. Then,

  • cross out any permutation where $1$ occurs after $2$, then

  • append "$n$" to the end of the remaining permutations.

For example, to generate all three bracelets using $\{1,2,3,4\}$, start by generating all permutations of $\{1,2,3\}$: $$ 1,2,3\quad 1,3,2\quad 2,1,3\quad 2,3,1\quad 3,1,2\quad 3,2,1 $$ When you apply both bullets to this list, the result is $$ 1,2,3,\color{blue}4\quad 1,3,2,\color{blue}4\quad \not2,\not1,\not3\quad \not2,\not3,\not1\quad 3,1,2,\color{blue}4\quad \not3,\not2,\not1 $$

You can efficiently list all permutations using, say, the Steinhaus-Johnson-Trotter algorithm.