0
$\begingroup$

I am trying to classify permutations of n, in this case n=6, elements depending on the cycles that contian the points 1 and 2, since these are considered to be special points.

So for example, I will consider the permutations 1->3->2->4->1 6->5->6 to be equivalent to 1->5->2->3->1 4->6->4 because we have exactly one cycle that contains the elements 1 and 2 with exactly one between 1 and 2 and one element between 2 and 1 and we have one cycle with the remaining elements.

If I had the permutations 1->3->2->5->1 4->6->4, 1->5->2->3->1 4->4 6->6, then this permutations are not equivalent because the elements 4 and 6, which are not in the same cycle as 1 and 2, do not form just one cycle.

I would do a similar analysis if the elements 1 and 2 are in separate cycles.

What I want to do is to loop through a set of permutations Permutations[Range[n]] and classify the permutations according to the rules I established above. I have a working code for classifying the permutations up to n =8, but after that it takes too much time doing the classification. Is there any data structure that might be helpful with this task, like a data structure that allows me to evaluate all 9! or more options in a faster way? I would like to optimize my code somehow but am not sure how to do it since I don't have that much experienc programming. Thanks so much for any suggestion.

$\endgroup$
  • $\begingroup$ Why not try to generate your permutations in Cycles[] format? $\endgroup$ – J. M. is away Jun 23 '16 at 14:41
  • $\begingroup$ Since my input data are permutations of the form {1, 2, 4, 5, 6, 3}, to get the cycles I am using PermutationCycles[{1, 2, 4, 5, 6, 3}]. $\endgroup$ – user41204 Jun 23 '16 at 14:45
  • $\begingroup$ Right; the documentation claims that Cycles[] is automatically canonicalized, so convert everything to Cycles[] and do your comparisons on those. $\endgroup$ – J. M. is away Jun 23 '16 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.