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!