Skip to main content

combinatorics - Cyclic and Non-cyclic Permutations


Mathematica has a built in function to generate all permutations of a given list of elements; Permutations


I can't find an equivalent function to generate cyclic permutations only in the documentation. Here is my function that achieves this goal:


CyclicPermutations[list_] := 
RotateRight[list, #] & /@ (Range[Length[list]] - 1)

Is there an in-built function somewhere that I've not been able to find?



And then a similar question which I don't have my own answer to. I would like to also generate all noncyclic permutations, ie. the set of permutations minus the set of cyclic permutations. I'm not sure of a good way to do this, I can think up some methods which use Permutations and my CyclicPermutations and then maybe DeleteCases, but I think this will be comparatively very inefficient. Does anyone else have a better method?



Answer



Per the request, I post my comment as an answer:



cy := Permute[#, CyclicGroup[Length@#]] &
cy[Range@5]


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





We can use the Complement mentioned by J.M. in his comment. I suppose that the order is $5$; then, you can use the following method to get noncyclic permutations:


Complement[Permutations[Range[5]], cy[Range@5]]


{{1,2,3,5,4},{1,2,4,3,5},{1,2,4,5,3},{1,2,5,3,4},{1,2,5,4,3},{1,3,2,4,5},{1,3,2,5,4},<<101>>,{5,3,4,2,1},{5,4,1,2,3},{5,4,1,3,2},{5,4,2,1,3},{5,4,2,3,1},{5,4,3,1,2},{5,4,3,2,1}}



Comments