Skip to main content
deleted 280 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Define an orbit index using CyclicGroup:

cyclicGroupOrbitsorbitIndex = GroupOrbits[CyclicGroup[5]Association[Join @@ MapIndexed[Thread[# -> #2[[1]]] &] @
      GroupOrbits[CyclicGroup[Length @ First @ #], {#}, Permute]Permute]] &;

DeleteDuplicatesBy[arr, cyclicGroupOrbits]orbitIndex[arr]]
DeleteDuplicates[arr, Equal @@ (cyclicGroupOrbitsorbitIndex[arr][#] /@== {##})orbitIndex[arr][#2] &]

Alternatively, define an orbit index associationAn example with repeated elements:

orbitIndexarr2 = Association[Joinarr @@/. MapIndexed[Thread[#3 -> #2[[1]]] &] @
      GroupOrbits[CyclicGroup[Length @ First @ #], #, Permute]] &;

DeleteDuplicatesBy[arr, orbitIndex[arr]]2
{{1, 2, 32, 4, 5}, {2, 2, 4, 35, 1}, {5, 1, 2, 2, 4}, {4, 2, 2, 5, 1}}
DeleteDuplicates[arrDeleteDuplicatesBy[arr2, orbitIndex[arr][#] == orbitIndex[arr][#2] &]orbitIndex[arr2]]
{{1, 2, 32, 4, 5}, {4, 32, 2, 5, 1}}

An example with repeated elements:

arr2 = arr /. 3 -> 2

{{1, 2, 2, 4, 5}, {2, 2, 4, 5, 1}, {5, 1, 2, 2, 4}, {4, 2, 2, 5, 1}}

DeleteDuplicatesBy[arr2, orbitIndex[arr2]]

{{1, 2, 2, 4, 5}, {4, 2, 2, 5, 1}}

cyclicGroupOrbits = GroupOrbits[CyclicGroup[5], {#}, Permute] &;

DeleteDuplicatesBy[arr, cyclicGroupOrbits]
DeleteDuplicates[arr, Equal @@ (cyclicGroupOrbits /@ {##}) &]

Alternatively, define an orbit index association:

orbitIndex = Association[Join @@ MapIndexed[Thread[# -> #2[[1]]] &] @
      GroupOrbits[CyclicGroup[Length @ First @ #], #, Permute]] &;

DeleteDuplicatesBy[arr, orbitIndex[arr]]
{{1, 2, 3, 4, 5}, {4, 3, 2, 5, 1}}
DeleteDuplicates[arr, orbitIndex[arr][#] == orbitIndex[arr][#2] &]
{{1, 2, 3, 4, 5}, {4, 3, 2, 5, 1}}

An example with repeated elements:

arr2 = arr /. 3 -> 2

{{1, 2, 2, 4, 5}, {2, 2, 4, 5, 1}, {5, 1, 2, 2, 4}, {4, 2, 2, 5, 1}}

DeleteDuplicatesBy[arr2, orbitIndex[arr2]]

{{1, 2, 2, 4, 5}, {4, 2, 2, 5, 1}}

Define an orbit index using CyclicGroup:

orbitIndex = Association[Join @@ MapIndexed[Thread[# -> #2[[1]]] &] @
      GroupOrbits[CyclicGroup[Length @ First @ #], #, Permute]] &;

DeleteDuplicatesBy[arr, orbitIndex[arr]]
DeleteDuplicates[arr, orbitIndex[arr][#] == orbitIndex[arr][#2] &]

An example with repeated elements:

arr2 = arr /. 3 -> 2
{{1, 2, 2, 4, 5}, {2, 2, 4, 5, 1}, {5, 1, 2, 2, 4}, {4, 2, 2, 5, 1}}
DeleteDuplicatesBy[arr2, orbitIndex[arr2]]
{{1, 2, 2, 4, 5}, {4, 2, 2, 5, 1}}
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

cyclicGroupOrbits = GroupOrbits[CyclicGroup[5], {#}, Permute] &;

DeleteDuplicatesBy[arr, cyclicGroupOrbits]
{{1, 2, 3, 4, 5}, {4, 3, 2, 5, 1}}
DeleteDuplicates[arr, Equal @@ (cyclicGroupOrbits /@ {##}) &]
{{1, 2, 3, 4, 5}, {4, 3, 2, 5, 1}}

Alternatively, define an orbit index association:

orbitIndex = Association[Join @@ MapIndexed[Thread[# -> #2[[1]]] &] @
      GroupOrbits[CyclicGroup[Length @ First @ #], #, Permute]] &;

DeleteDuplicatesBy[arr, orbitIndex[arr]]
{{1, 2, 3, 4, 5}, {4, 3, 2, 5, 1}}
DeleteDuplicates[arr, orbitIndex[arr][#] == orbitIndex[arr][#2] &]
{{1, 2, 3, 4, 5}, {4, 3, 2, 5, 1}}

An example with repeated elements:

arr2 = arr /. 3 -> 2

{{1, 2, 2, 4, 5}, {2, 2, 4, 5, 1}, {5, 1, 2, 2, 4}, {4, 2, 2, 5, 1}}

DeleteDuplicatesBy[arr2, orbitIndex[arr2]]

{{1, 2, 2, 4, 5}, {4, 2, 2, 5, 1}}

DeleteDuplicates[arr2, orbitIndex[arr2][#] == orbitIndex[arr2][#2] &]
{{1, 2, 2, 4, 5}, {4, 2, 2, 5, 1}}

Symbolic elements:

arr3 = arr /. MapIndexed[#2[[1]] -> # &, {"A", "B", "C", "D", "E"}]
 {{"A", "B", "C", "D", "E"}, {"B", "C", "D", "E", "A"},
  {"E", "A", "B", "C", "D"}, {"D", "C", "B", "E", "A"}}
DeleteDuplicatesBy[arr3, orbitIndex[arr3]]
{{"A", "B", "C", "D", "E"}, {"D", "C", "B", "E", "A"}}
DeleteDuplicates[arr3, orbitIndex[arr3][#] == orbitIndex[arr3][#2] &]
{{"A", "B", "C", "D", "E"}, {"D", "C", "B", "E", "A"}}