2

I want to find all possible colorings for a given number of colors $C$ on a board with cells $M \cdot N$ (both are even numbers). The board has periodic boundry conditions, so shifting the pattern to the left, right, up and down is considered to be the same pattern.

example patern with all posible shifts

I found out, that Polyas enumeration theorem can tell you the total number of colorings. I just found examples, where they calculate the unique permutations for roational and mirros symetries.

  1. Could you please help me to find the answer for the total number of unique patterns?
  2. Is there a function which can generate all possible unique patterns?

Extra
I found out that the squared Fourier transform can tell whether two (shifted) patterns are the same.

Application
The patterns are used as inputs for a simulation program. The simulation gives the same result for all shifted representation of a pattern. The computation time could be greatly reduced by eliminiating all the redundant patterns.

Thank you very much for helping me out :)

Parcly Taxel
  • 103,344

1 Answers1

1

The symmetry group can be generated from two generators: a horizontal rotation $h$ of order $M$ and a vertical rotation $v$ of order $N$, where $h$ and $v$ commute. Therefore it is isomorphic to the direct product of two cyclic groups: $C_M \times C_N$, and PET says that the number of distinct patterns is

$$\frac {1}{MN}\sum_{a=0}^{M-1} \sum_{b=0}^{N-1} C^{c(h^a v^b)}$$

where $c(h^a v^b)$ is the number of cycles in the permutation $h^a v^b$ of the grid. By considering the well-known cycle index of the cyclic group we get (see e.g. Counting Toroidal Binary Arrays, S. N. Ethier, Journal of Integer Sequences vol. 16 (2013))

$$\frac {1}{MN}\sum_{c\mid M} \sum_{d \mid N} \varphi(c) \varphi(d) C^{MN/\ \textrm{lcm}(c,d)}$$

Peter Taylor
  • 13,425
  • Hi Peter, thank you very much, also for the link to the paper. The last equation tells me how many posibilities I have right?

    Is there also a way to systematically generate all possible petterns?

    – Lorenz Sykora May 22 '18 at 17:11
  • Both expressions give the number of possibilities, but the second is going to be more useful to you. I'm thinking about how to generate the patterns, but so far I haven't had any good ideas. The one-dimensional case (necklaces) is well studied: either generate all Lyndon words up to the desired length (see https://en.wikipedia.org/wiki/Lyndon_word#Generation ) and filter out the short ones; or check out https://scholar.google.com/scholar?q=necklace+generation . But given how recent Ethier's paper is, the 2D generalisation seems to be a very new idea. – Peter Taylor May 22 '18 at 18:09
  • You could generate necklaces of length $M$ over an alphabet of size $C$ to get an alphabet of size $K$, then generate necklaces of length $N$ over that alphabet of size $K$, and then for each one you only need to consider at most $M^{N-1}$ rotations. But that's complicated and possibly still not very efficient. – Peter Taylor May 22 '18 at 18:19
  • Do you think you could walk through the evaluation of the second formula, for a 6 times 4 board and three colors? An example would really help me and others, who are new to this field, to understand all parts of it and the practical application. – Lorenz Sykora May 23 '18 at 12:08
  • @LorenzSykora, to help me pitch it at the right level, which of these parts of the notation do you understand and which not? (i) $\sum$ (ii) $c \mid M$; (iii) $\varphi(c)$; (iv) $\textrm{lcm}(c, d)$. Also, if I try to implement the ideas from my previous comment, would an implementation in C# or Java be any use to you? – Peter Taylor May 23 '18 at 13:37