\subsection{A free-tree alphabet with an explicit index} \label{sec:free-tree-index} The tree components in the undirected background are \emph{free trees}: their vertices are unlabelled and no root is distinguished. The following construction provides the count, rank and unrank operations needed by the outer component multiset. Its structural ingredient is classical. Wilf~\cite[p.~204, properties (C1)--(C3)]{Wilf1981Free} already uses centroids to separate free trees into one-centroid and two-centroid classes. Polynomial tree indexing also has direct older antecedents; see the discussion and references in~\cite[Chapter~5]{Wilf1989Update}. No novelty is claimed for free-tree indexing. We give the details because the degree cap, the order, and the prefix-completion oracle must agree with the surrounding construction. Fix a size limit $N\ge1$ and a maximum degree $\Delta\ge0$. One may replace $\Delta$ by $\min(\Delta,N-1)$ for this alphabet; reading its original binary encoding is an additional input cost. When there is no degree restriction take $\Delta=N-1$. For $\Delta=0$, the alphabet consists only of the singleton tree, so suppose initially that $\Delta\ge1$. Set $d=\Delta-1$ and let \[ \mathcal U_d=\mathcal Z\operatorname{MSET}_{\le d}(\mathcal U_d), \qquad a_w=|\mathcal U_{d,w}|. \] Thus every vertex of a rooted tree in $\mathcal U_d$ has at most $d$ children. After its root is attached to an outside parent, every undirected degree is at most $\Delta$. The root of a whole free tree, when chosen at its unique centroid, will instead have capacity $\Delta$. These two capacities must not be confused. Order $\mathcal U_d$ first by size and then by the recursive child-multiset order of Section~\ref{sec:indexing-composition}. The child-count resource of Section~\ref{sec:forward-core-refinements} supplies its capped count, rank and unrank operations. More generally, for any nonnegative input root capacity $b$, the class $\mathcal Z\operatorname{MSET}_{\le b}(\mathcal U_d)$ has the same oracles: change only the outer multiset capacity from $d$ to $b$. The nonroot capacity remains $d$. In particular, an attached tree whose root already has two cycle neighbours uses $(b,d)=(\Delta-2,\Delta-1)$ when $\Delta\ge2$. \paragraph{The canonical split.} A centroid is a vertex for which every component left after its deletion has at most half of the original vertices. This is a size-balance condition; a centroid is different from a \emph{centre}, which minimizes the maximum distance to the other vertices. Every tree has either a unique centroid, or two adjacent centroids. In the first case each branch at that vertex has size at most $h_n=\lfloor(n-1)/2\rfloor$. In the second case the centroid edge separates two halves of size $n/2$. Here is a short justification sufficient for our use. If deleting a vertex leaves a component of more than $n/2$ vertices, move into that component. The largest component size strictly decreases, so this process stops at a centroid. At a centroid $c$, every component has size at most $n/2$. A vertex in a component of size less than $n/2$ cannot be another centroid, because its deletion leaves a component containing $c$ of more than $n/2$ vertices. A component of size exactly $n/2$, if present, is unique. Its neighbour of $c$ is also a centroid; every vertex farther inside it again leaves a component larger than $n/2$. This proves the alternatives and the stated strict bound for the unique-centroid case. Consequently the unique-centroid trees on $n$ vertices are in bijection with multisets of at most $\Delta$ letters from $\mathcal U_d$, each of size at most $h_n$, having total size $n-1$. Add a new vertex adjacent to the roots of those letters. The size restriction makes that new vertex the unique centroid, so an isomorphism cannot move it. The two-centroid trees, for even $n$, are in bijection with unordered pairs of size-$n/2$ letters of $\mathcal U_d$, with repetition allowed. Join their roots by an edge. Its two sides have equal size and its endpoints are precisely the centroids. Isomorphisms may interchange the halves but make no further identifications between distinct unordered pairs. Write $u_{n,\Delta}$ and $v_{n,\Delta}$ for the numbers in these two classes. The bijections give \begin{align} u_{n,\Delta} &=\sum_{j=0}^{\Delta}[z^{n-1}y^j] \prod_{w=1}^{h_n}(1-yz^w)^{-a_w}, \label{eq:free-unique-centroid-count}\\ v_{n,\Delta} &=\begin{cases} \displaystyle\binom{a_{n/2}+1}{2},& n\text{ even},\\ 0,&n\text{ odd}. \end{cases} \label{eq:free-two-centroid-count} \end{align} The free-tree count is $f_{n,\Delta}=u_{n,\Delta}+v_{n,\Delta}$. The empty product in~\eqref{eq:free-unique-centroid-count} gives $u_{1,\Delta}=1$. A zero-size tree is not a component, so $f_{0,\Delta}=0$; empty graphs enter only through the outer multiset. \paragraph{Order and prefix counts.} Within size $n$, put the unique-centroid class first and the two-centroid class second. In the first class use lexicographic order of the nondecreasing word of branch ordinals. In the second use lexicographic order of the pair $(i,j)$, where $0\le i\le j0$ the sentinel threshold $q_h$ has count zero. Initially use $(R,b,L)=(n-1,\Delta,0)$. If the next branch has ordinal $x\ge L$, the number of earlier continuations is \[ C_h(R,b,L)-C_h(R,b,x). \] Remove that branch and continue with $(R-\operatorname{wt}(x),b-1,x)$. This ranks an actual tree after its centroid and its rooted branches have been computed. The identity \begin{equation} C_h(R,b,x)-C_h(R,b,x+1) =C_h(R-\operatorname{wt}(x),b-1,x) \label{eq:free-centroid-remove} \end{equation} follows by removing one copy of the minimum letter from the multisets counted on the left. It also proves unranking: for a valid residual rank $r$, find the largest $x$ satisfying \[ C_h(R,b,L)-C_h(R,b,x)\le r \] by binary search. The failing sentinel ensures that the selected block has positive width. Subtract its preceding count and use \eqref{eq:free-centroid-remove} for the continuation. Only numerical letter tokens are needed during this search. Decode the selected rooted trees afterwards. For a two-centroid tree put $m=a_{n/2}$. There are $m-i$ pairs whose first entry is $i$, and their starting offset is \[ D(i)=im-\frac{i(i-1)}2. \] The free-tree rank of $(i,j)$ is \[ u_{n,\Delta}+D(i)+(j-i). \] Conversely subtract $u_{n,\Delta}$, binary-search the largest $i$ with $D(i)\le r$, and set $j=i+r-D(i)$. Decode those two rooted trees and join their roots. Equal halves are included once; dividing the number of ordered pairs by two would give the wrong answer. \paragraph{A small example.} Take $n=6$ and $\Delta=3$. The branch alphabet has at most two children at each vertex, and $a_1=a_2=1$, $a_3=2$. For a unique centroid the branches have size at most two and their total size is five. With at most three branches the only multiset of sizes is $(1,2,2)$, so $u_{6,3}=1$. The two-centroid class consists of the three pairs $(0,0),(0,1),(1,1)$ of size-three rooted trees. The four free trees therefore have ranks $0,1,2,3$, with rank zero belonging to the unique-centroid tree. Under $\Delta=2$ only the six-vertex path remains. This example displays both the cap at the centroid and the unordered-pair correction. \begin{lemma}[Free-tree oracle] \label{lem:free-tree-index} Unlabelled undirected trees of prescribed size, with an optional input maximum degree $\Delta$, admit exact count, rank and unrank in polynomial bit time and polynomial bit space, with exponent independent of $\Delta$. Their order is the centroid-first order specified above. The algorithms accept an actual unrooted tree and do not enumerate an alphabet of rooted trees. Every such tree is bipartite. \end{lemma} \begin{proof} The decomposition and the prefix identities prove correctness. For completeness, the capped rooted counts are computed in increasing size using \[ a_s=\sum_{j=0}^{d}[z^{s-1}y^j] \prod_{w=1}^{s-1}(1-yz^w)^{-a_w}. \] Only smaller sizes occur. The two-resource version of the multiset tail algorithm gives its recursive index, with root capacity $d$. For both this recurrence and~\eqref{eq:free-centroid-tail}, truncate the resources at $N$ and use \[ (1-yz^w)^{-b_w} =\sum_{t\ge0}\binom{b_w+t-1}{t}y^tz^{wt}, \] where for $b_w=0$ only $t=0$ contributes. There are $O(N^2)$ resource cells, $O(N)$ factors and $O(N)$ relevant terms per factor. Thus even direct multiplication takes only $O(N^4)$ arithmetic operations per tail query. Counts satisfy $a_w\le4^w$, so ordinals have $O(N)$ bits. A generous common bound of $O(N^2)$ bits suffices for all truncated coefficient counts and intermediate binomial computations, because a word has at most $N$ letters from an alphabet of at most $\sum_{w\le N}4^w$ letters. Exact binomial evaluation with lower argument at most $N$ is polynomial-bit-time. There are at most $N$ selected branches per multiset and $O(N)$ binary-search queries per selected branch. Recursive decoding occurs only on the selected, disjoint rooted subtrees; there are at most $N$ actual vertices at which recursive work is done. Centroid extraction, rooted-tree normalization and sorting their numerical tokens also take polynomial time. The two-centroid pair calculation has polynomial bit cost. All these bounds use only the two resource axes, size and number of children, so their polynomial exponents do not depend on $\Delta$. Finally, if $\Delta=0$ there is only the singleton tree. If $\Delta=1$, the general construction with $d=0$ gives only the singleton and the single edge. Thus neither extreme needs a negative child capacity, and all boundary cases are covered. \end{proof}