How to calculate the cycles that change one permutation into another?

Posted by fortran on Stack Overflow See other posts from Stack Overflow or by fortran
Published on 2010-03-19T10:07:32Z Indexed on 2010/03/19 10:11 UTC
Read the original article Hit count: 108

Hi, I'm looking for an algorithm that given two permutations of a sequence (e.g. [2, 3, 1, 4] and [4, 1, 3, 2]) calculates the cycles that are needed to convert the first into the second (for the example, [[0, 3], [1, 2]]).

The link from mathworld says that Mathematica's ToCycle function does that, but sadly I don't have any Mathematica license at hand... I'd gladly receive any pointer to an implementation of the algorithm in any FOSS language or mathematics package.

Thanks!

© Stack Overflow or respective owner

Related posts about mathematics

Related posts about combinatorics