Cycles[{cyc1,cyc2,…}]
represents a permutation with disjoint cycles cyci.
Cycles
Cycles[{cyc1,cyc2,…}]
represents a permutation with disjoint cycles cyci.
Details
- The cycles cyci of a permutation are given as lists of positive integers, representing the points of the domain in which the permutation acts.
- A cycle {p1,p2,…,pn} represents the mapping of the pi to pi+1. The last point pn is mapped to p1.
- Points not included in any cycle are assumed to be mapped onto themselves.
- Cycles must be disjoint, that is, they must have no common points.
- Cycles objects are automatically canonicalized by dropping empty and singleton cycles, rotating each cycle so that the smallest point appears first, and ordering cycles by the first point.
- Cycles[{}] represents the identity permutation.
Examples
open all close allBasic Examples (2)
Scope (2)
Properties & Relations (9)
The identity permutation contains no cycles in its canonical form:
Cycles[{{1}, {2}, {3}, {4}}]Permutation applied to a single point:
PermutationReplace[3, Cycles[{{1, 3, 2}}]]Points not present in the cycles are mapped onto themselves:
PermutationReplace[4, Cycles[{{1, 3, 2}}]]Cycles given in SparseArray form are automatically converted into normal lists:
Cycles[{SparseArray[{1 -> 1000, 2 -> 10}], {100, 1, 10000}}]Generate the list of permutations corresponding to a symmetric group:
GroupElements[SymmetricGroup[3]]Permutations are numerically ordered by comparing their respective lists of images:
Cycles[{{5, 1, 2}}] < Cycles[{{1, 4}}]PermutationReplace[Range[5], Cycles[{{5, 1, 2}}]] < PermutationReplace[Range[5], Cycles[{{1, 4}}]]Canonical Wolfram Language ordering of Cycles objects:
Sort[{Cycles[{{5, 1, 2}}], Cycles[{{1, 4}}]}]The identity is always sorted first:
Cycles[{}] ≤ Cycles[{{1, 2, 3}}]A way to compute the inverse of a permutation:
Map[Reverse, Cycles[{{1, 20}, {4, 10, 19, 6, 18}, {5, 9}, {7, 14, 13}}], {2}]Possible Issues (3)
Only positive integers can appear in cycles:
Cycles[{{0, 1, 2, 3}, {4, 5}}]Cycles[{{1 / 2, 3}, {4, 5}}]All integers must be distinct:
Cycles[{{1, 2, 3}, {3, 4, 5}}]Permutation objects with symbolic arguments return unevaluated:
Cycles[{{1, 2, 3}, {a, b}}]Neat Examples (1)
Graph representation of a permutation:
perm = Cycles[{{1, 20}, {2, 15, 17, 16, 5}, {4, 10, 19, 12, 18, 3}, {6, 9}, {7, 14, 13}}];rules[cycle_] := Thread[DirectedEdge[cycle, RotateLeft[cycle]]];
Flatten[rules /@ First[perm]]Graph[%, VertexLabels -> Placed["Name", Center], VertexSize -> 0.6]The inverse permutation has the arrows reversed:
Flatten[rules /@ First[InversePermutation[perm]]]Graph[%, VertexLabels -> Placed["Name", Center], VertexSize -> 0.6]Tech Notes
Related Guides
History
Text
Wolfram Research (2010), Cycles, Wolfram Language function, https://reference.wolfram.com/language/ref/Cycles.html.
CMS
Wolfram Language. 2010. "Cycles." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Cycles.html.
APA
Wolfram Language. (2010). Cycles. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Cycles.html
BibTeX
@misc{reference.wolfram_2026_cycles, author="Wolfram Research", title="{Cycles}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/Cycles.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_cycles, organization={Wolfram Research}, title={Cycles}, year={2010}, url={https://reference.wolfram.com/language/ref/Cycles.html}, note=[Accessed: 13-June-2026]}