Skip to content

CycleCount ​

The number of cycles in the disjoint-cycle decomposition of pp.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000031via Permutation✓
CycleCount(p)the cycle count of a one-line permutation pp
SageMathenumeratio_stat("Permutation", p, "CycleCount")
Typed signatures
TypePackageApplies
(permutation) -> integercombinatoricsalways

Domain: Permutation statistics

Details
  • Permutations of {1,…,n}\{1, \dots, n\} with kk cycles are counted by the unsigned Stirling number of the first kind [nk]\left[{n\atop k}\right] (see StirlingS1)
  • The identity is all fixed points, so it splits into nn singleton cycles; an nn-cycle is a single cycle
  • Defined over Permutation as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a Permutation and nothing else — it reads values against their positions, or walks the orbits, so it needs the bijection. Applying it to a bare list is a type error, not a wrong answer.

Definition

Epsil, as the implementation runs it.

on Permutation, over _x

0 if Length(_x) < 1 else Count(Filter(
                                       Range(1, Length(_x), 1),
                                       Function(Fold(
                                                      Function(
                                                                w if w <= 0 else 0 if w == i else -1 if w < i else _x[w],
                                                                w,
                                                                k,
                                                              ),
                                                      _x[i],
                                                      Range(1, Length(_x), 1),
                                                    ) == 0, i),
                                     ))

Examples

Basic #

the 3-cycle (1 2 3)(1\,2\,3)

live ↗
InCycleCount(Permutation⁡([2,3,1]))\mathrm{CycleCount}({\operatorname{Permutation}}([2, 3, 1]))Out11

three singleton cycles

live ↗
InCycleCount(Permutation⁡([1,2,3]))\mathrm{CycleCount}({\operatorname{Permutation}}([1, 2, 3]))Out33

(1 2)(3)(1\,2)(3)

live ↗
InCycleCount(Permutation⁡([2,1,3]))\mathrm{CycleCount}({\operatorname{Permutation}}([2, 1, 3]))Out22

the one-line word 312312

live ↗
InCycleCount(Permutation⁡([3,1,2]))\mathrm{CycleCount}({\operatorname{Permutation}}([3, 1, 2]))Out11

the one-line word 24132413

live ↗
InCycleCount(Permutation⁡([2,4,1,3]))\mathrm{CycleCount}({\operatorname{Permutation}}([2, 4, 1, 3]))Out11
Properties #

FindStat's value for [1]

live ↗
InCombinatorialStat(Permutation⁡([1]),CycleCount)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([1]), \text{CycleCount})Out11

Known value · FindStat St000031

FindStat's value for [1,2]

live ↗
InCombinatorialStat(Permutation⁡([1,2]),CycleCount)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([1, 2]), \text{CycleCount})Out22

Known value · FindStat St000031

FindStat's value for [2,1]

live ↗
InCombinatorialStat(Permutation⁡([2,1]),CycleCount)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([2, 1]), \text{CycleCount})Out11

Known value · FindStat St000031

About
Examples8
Checked againstSageMath 8 agreemathlib4 5 agree
CrosswalkFindStatSageMath

Implementation

primitive · kernela kernel — an algorithm over mutable state that would not be readable as a tree

nativeenginetypescriptpackages/symbols/combinatorics/combinatorics/collections/src/stats.ts:cycleCount

Orbit traversal with a visited set — the one statistic here that does not reduce to an expression.

mappedsagepackages/oracle/src/mappings.ts
mappedmathlib4packages/oracle/src/mappings.ts

A 1-based one-line permutation list, rebuilt as an Equiv.Perm (Fin n) (a list that is not a permutation prints "not a permutation"); Equiv.Perm.partition is the cycle type with the fixed points as 1-cycles

See also: FixedPoints, StirlingS1, SymmetricGroup