# Delete duplicates when cycle both position and element

Cycle of position means: {a, b, a, a} and {a, a, b, a} is the same.

Cycle of element means: {a, b, a, a} and {b, a, b, b} is the same.

There's a solution of position cycle.

Notice that $$(2)$$ and $$(3)$$ is the same.

$$\rm{BBWBWW} \to \rm{WWBWBB} \to \rm{BBWWBW} = \rm{BBWWBW}$$

So how to delete the duplicates in this case?

ClearAll[labelings, labelingFreeCanonize]

labelings[a_] := Module[{u = Union @ a}, a /. Map[Thread[u -> #] &] @ Permutations[u]]

labelingFreeCanonize = First @ Sort[canonize /@ labelings[#]] &;

Union[labelingFreeCanonize /@ t]


FWIW: Alternative ways to canonize:

1. Permute input list under the elements of CyclicGroup:

ClearAll[canonizeCG]
canonizeCG = First @ Sort @ Permute[#, CyclicGroup[Length @ #]] &;


2. Use Ordering @* Ordering to get the ranks of list elements instead of Position in @Mr.Wizard's canonize:

ClearAll[ranks, canonize2, canonize3]

ranks = Ordering @* Ordering;

canonize2[a_] := ranks[a] // Map[RotateLeft[a, # - 1] &] // Sort // First


or

canonize3[a_] := ranks[a] // Map[RotateLeft[a, #1 - 1] &] // #[[First@Ordering[#, 1]]] &


All three methods give the same result as canonize:

canonize /@ t == canonizeCG /@ t == canonize2 /@ t == canonize3 /@ t


True