RootedForests
The forests of rooted labeled trees on , each element a length- parent array (entry marks a root). Count .
✓ checked against that system · ! checked, with disagreements (hover a chip)OEIS
A000272✓RootedForests(n)the rooted forests on , as parent arraysTyped signatures
| Type | Package | Applies |
|---|---|---|
(integer<0..>) -> indexed_collection<rooted_forest> | combinatorics | always |
Definition
Epsil, as the implementation runs it.
count(_n)
1 if _n <= 0 else (_n + 1) ^ (_n - 1)unrank(_n, _r)
Apply((sq: list<integer>) => Drop(Apply(
(us_init: list<integer>) => Fold(
(
us: list<integer>,
ui,
) => Apply(
(us_next: list<integer>) => us_next,
Apply(
(ul: integer) => Apply((ux: integer) => ReplaceAt(
ReplaceAt(ReplaceAt(us, ul, 0), ux, us[ux] - 1),
_n + 1 +
ul,
0 if ux ==
_n + 1 else ux,
), sq[ui]),
Fold(
Function(u_v if u_f == 0 &&
us[u_v] == 1 else u_f, u_f, u_v),
0,
Range(1, _n + 1, 1),
),
),
),
us_init,
Range(
1,
_n + 1 -
2,
1,
),
),
Join(Map(
Function(1 + Count(Filter(
sq,
Function(py == pv, py),
)), pv),
Range(1, _n + 1, 1),
), Map(
Function(0, pz),
Range(1, _n, 1),
)),
), _n + 1), Map(Function((_r - _r % (_n +
1) ^
(_n +
1 - 2 -
pj)) / (_n +
1) ^
(_n +
1 -
2 -
pj) %
(_n + 1) + 1, pj), Range(
1,
_n + 1 -
2,
1,
)))rank(_n, _x)
Apply((rs_init: list<integer>) => Fold(
(rs: list<integer>, ri) => Apply(
(rs_next: list<integer>) => rs_next,
Apply(
(rl: integer) => Apply(
(rn: integer) => ReplaceAt(
ReplaceAt(ReplaceAt(rs, rl, 0), rn, rs[rn] - 1),
_n + 1 +
1,
rs[_n + 1 +
1] *
(_n + 1) +
(rn - 1),
),
_n + 1 if _x[rl] == 0 else _x[rl],
),
Fold(
Function(r_v if r_f == 0 &&
rs[r_v] == 1 else r_f, r_f, r_v),
0,
Range(1, _n + 1, 1),
),
),
),
rs_init,
Range(1, _n + 1 - 2, 1),
), Join(Map(
Function(Count(Filter(
_x,
Function(dy == 0, dy),
)) if dv ==
_n +
1 else 1 +
Count(Filter(_x, Function(dy == dv, dy))), dv),
Range(1, _n + 1, 1),
), [0]))[_n + 1 + 1]valid(_n, _x)
Fold(
Function(ok_vr && Apply((vp_init: integer) => Fold(
(vp: integer, vk) => Apply(
(vp_next: integer) => vp_next,
0 if vp == 0 else _x[vp],
),
vp_init,
Range(1, _n, 1),
), vr) == 0, ok_vr, vr),
True,
Range(1, _n, 1),
) if Length(_x) == _n && Fold(Function(
ok_vi && 0 <= _x[vi] && _x[vi] <= _n,
ok_vi,
vi,
), True, Range(1, _n, 1)) else FalseEnumeration
Examples
About
| Examples | 2 |
|---|---|
| Crosswalk | OEIS |