Advanced maths

Unlabeled rooted tree calculator with unordered branch counts and canonical examples

Count rooted unlabeled unordered trees exactly and generate canonical representatives only when the requested size is small.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Count rooted unlabeled unordered trees exactly and generate canonical representatives only when the requested size is small.

THE FORMULAa₁=1; (n−1)a_n=Σ_{j=1}^{n−1}(Σ_{d|j} d a_d) a_{n−j}; T(x)=x Π_{m≥1}(1−x^m)^(−a_m).

A worked example

Counts for one through six nodes are 1,1,2,4,9,20. At three nodes, the two shapes are a rooted chain and a root with two leaf children.

Good to know

Exact BigInt counts for 1–200 nodes using the Euler-transform rooted-tree recurrence. Canonical representative generation only for at most 10 nodes, with at most 1,000 representatives displayed. Trees are rooted, unlabeled and unordered; isomorphisms must preserve the root. Enumeration completeness and display truncation are separate. No claim to enumerate all 200-node trees.

Specify the tree model first

Enter a node count from one through two hundred. Trees are rooted, unlabeled and unordered: one vertex is distinguished as the root, vertex names carry no information, and permuting the children of a vertex does not create a new tree. Isomorphisms must preserve the root.

These choices substantially change the counting problem. A path rooted at an endpoint can differ from the same unrooted path rooted internally. Ordered trees distinguish left-to-right child arrangements and have different counts. Labeled-tree formulas count assignments of names and likewise cannot be substituted for this model, even when all objects have the same number of nodes.

Unlabeled rooted tree with unordered branch counts and canonical examples exampleThe two rooted unordered trees with 3 nodesRRIsomorphisms preserve the distinguished root R
Scroll across to see the full diagram.
Counts for one through six nodes are 1,1,2,4,9,20. At three nodes, the two shapes are a rooted chain and a root with two leaf children.

Compare this with the Cayley labeled tree count calculator. Count rooted nonplane trees up to root-preserving isomorphism, using multiset branch structure rather than Cayley labeled trees or Catalan ordered trees. Return exact counts by size, canonical bracket representatives for small sizes and symmetry examples.

View the root as a multiset of branches

Removing the root leaves an unordered multiset of rooted trees. Each branch is rooted at its former neighbor of the original root, and identical branch shapes may repeat. Conversely, attaching any such multiset to a new root creates one rooted unordered tree. This is the combinatorial basis of the product generating function.

If there are a_m branch types of size m, each type can occur zero, one or more times, contributing a factor (1−x^m) inverse. Multiplying across all types and adding one node for the new root yields T(x)=x times the product over m of (1−x^m) to power −a_m. Multiplicity, rather than branch order, is what matters.

Compute exact counts with integer arithmetic

The Euler-transform recurrence derives each a_n from earlier counts and divisor sums. The factor n−1 divides the numerator exactly; failure of divisibility would indicate an implementation error. Use arbitrary-size integers because rooted-tree counts grow rapidly and soon exceed the precision range of ordinary floating-point integers.

The recurrence computes counts through two hundred nodes without constructing those trees. Its output is an exact decimal integer, not a rounded estimate. The n=1 base case is one, representing a single root. A bookkeeping zero at n=0 is not the count of an allowed zero-node input tree under this page’s domain.

Check the first small values independently

At one node there is just the root, and at two there is a root with one leaf. At three nodes, either the root has one child that has one child, or it has two leaf children. These give counts one, one and two without invoking the recurrence.

Continuing canonical multiset generation gives four trees at size four, nine at size five and twenty at size six. The default result is therefore twenty. Comparing these explicit representatives with recurrence counts provides an independent check because one method builds branch multisets while the other manipulates divisor sums and earlier coefficients.

Read canonical parenthesis examples

Encode a rooted tree by an opening parenthesis, the sorted encodings of all child branches, and a closing parenthesis. A leaf is (). Sorting child encodings removes irrelevant order, while repeated identical substrings preserve branch multiplicity. Different canonical strings represent different rooted unordered shapes.

The figure contrasts the two three-node trees and identifies their roots. One has a two-edge chain below the root; the other has two children immediately below it. The same unrooted three-vertex path underlies both, illustrating why requiring isomorphisms to preserve the root changes the count.

Separate enumeration from presentation limits

Canonical representatives are generated only for at most ten nodes. Even there, the displayed list is limited to one thousand representatives, so the interface must distinguish a complete generated set from the subset shown. The exact recurrence count remains available when representative generation is disabled for a larger n.

At ten nodes there are 719 shapes, below the display cap, while substantially larger sizes quickly make full generation impractical. An exact count for two hundred nodes is not a claim that all corresponding trees were materialized. This separation lets a compact arithmetic calculation remain useful without hiding an impossible enumeration behind a short example list.

Use the result for the intended species

These counts describe one precise combinatorial species. They do not count unrooted trees, rooted forests, binary trees with prescribed child slots or chemically constrained structures. Additional restrictions on degree, height or branch types change the recurrence and require another model rather than a filter applied only to the displayed examples.

Save the node count, exact decimal count and model conventions together. For small n, canonical strings offer a transparent way to deduplicate independently generated shapes and verify completeness. For large n, divisor-sum recurrence checks and exact divisibility provide arithmetic evidence, while the stated generation boundary prevents a count from being misrepresented as an explicit list of all objects.

A few questions, answered

Are children ordered?

No. Permuting sibling branches does not create a new tree.

Must an isomorphism preserve the root?

Yes. Different root choices can produce distinct rooted shapes.

Are all two-hundred-node trees generated?

No. Exact counts extend to 200; representatives are generated only through 10 nodes.

Why use big integers?

The exact counts grow beyond ordinary floating-point integer precision.

Find your calculator

Start typing to explore the library.