\subsection{Polynomial indexing of trees and functional digraphs} \label{sec:indexing-composition} This section applies the weighted-cycle oracle result to functional digraphs. The multiset and recursive-tree ingredients are standard combinatorial constructions; the purpose of the detailed argument is to specify an actual indexing order and to account for the implicit alphabet. No implication from efficient listing to efficient ranking is assumed. The complexity model here is \emph{bit complexity}, rather than the word-operation model of the linear-delay sections. Polynomial indexing of restricted rooted trees already has direct predecessors such as~\cite{MSN2019}. The present section supplies the particular recursive order and verifies its compatibility with the cycle closure of Section~\ref{sec:weighted-cycle-oracle}; it makes no first-indexing claim. Goldberg--Jerrum's historical account explicitly credits Nijenhuis--Wilf for uniform sampling of unlabelled rooted trees \cite{NW1978,GJ2000}. This is an older recursive-sampling antecedent, not an identification with the particular ranking order specified below. The proof has three stages. We first count multisets with a lower bound on their minimum letter. This gives a ranking operation for a root's multiset of subtrees. The weighted-cycle theorem then ranks connected components, and the same multiset operation ranks arbitrary graphs. \subsubsection{Multiset tail counts} Let $\mathcal A=\bigsqcup_{j\ge1}\mathcal A_j$ satisfy the positive-weight oracle assumptions of the preceding section. Write $a_j=|\mathcal A_j|$, and order its letters first by weight and then by their specified within-weight rank. For maximum weight $N$, let $q=\sum_{j\le N}a_j$. Letters are represented by ordinals in $[0,q)$; these ordinals have polynomial bit length, even when $q$ is exponential. Let $b_j(L)=|\{a\in\mathcal A_j:a\ge L\}|$. The intervals of ordinals belonging to each weight class determine $b_j(L)$ directly. The number of nondecreasing words of total weight $R$ using letters at least $L$ is \begin{equation} C(R,L)=[z^R]\prod_{j=1}^{R}(1-z^j)^{-b_j(L)}. \label{eq:mset-tail} \end{equation} The empty word contributes $C(0,L)=1$. For a nonnegative integer $b$, use \[ (1-z^j)^{-b}=\sum_{s\ge0}\binom{b+s-1}{s}z^{js}, \] where the coefficient is $1$ at $s=0$ and $0$ at $s>0$ when $b=0$. Only $s\le R/j$ is needed. Thus the upper binomial argument may be exponentially large, but its bit length and the lower argument are polynomially bounded. Elementary truncated multiplication computes \eqref{eq:mset-tail} with $O(R^3)$ arithmetic operations and $O(R)$ big-integer cells. This intentionally conservative bound is sufficient. Every coefficient counts at most $(q+1)^{O(R)}$ words, so its bit length is $O(R\log(q+1))$. For instance, with $a0$ and lower admissible letter $L$. For the next actual letter $x\ge L$, the number of continuations starting with a smaller letter is exactly \begin{equation} C(R,L)-C(R,x). \label{eq:mset-rank-step} \end{equation} Indeed the second term removes precisely those multisets whose minimum letter is at least $x$. Add \eqref{eq:mset-rank-step} to the rank, consume the weight of $x$, and update $L$ to $x$. Positive weights imply that two different words of the same total weight cannot be proper prefixes, so there is no additional prefix term. For unranking a valid residual rank $r0$. Furthermore, \[ C(R,x)-C(R,x+1)=C(R-\wt(x),x), \] with a negative residual weight interpreted as zero. Removing one copy of the minimum letter proves this identity. Consequently the selected letter is feasible and the residual rank after subtracting \eqref{eq:mset-rank-step} belongs to its continuation block. Each step consumes positive weight, so at most the original $R$ steps occur. All arithmetic and oracle costs are polynomial. \end{proof} \subsubsection{Rooted trees} Let $t_s$ be the number of unlabelled rooted trees on $s$ vertices. The recursive multiset decomposition gives \begin{equation} t_s=[z^{s-1}]\prod_{j=1}^{s-1}(1-z^j)^{-t_j}. \label{eq:tree-recursive-count} \end{equation} Only earlier counts occur, so the table up to size $N$ is polynomial-time computable. Forgetting the ordering of a rooted plane tree is surjective onto rooted unordered trees, and the Catalan bound therefore gives $t_s\le4^s$. The counts have $O(s)$ bits. For size three, the children of a root are either two singleton trees or the unique two-vertex tree. The resulting codes are $(3,1,1)$ and $(3,2,1)$, in that order. Thus the recursive multiset order has a concrete meaning even before any large counts are introduced. For a tree of size $s$, rank its multiset of immediate subtrees by Lemma~\ref{lem:mset-index}, recursively ranking each subtree. Order tree letters by size and then by the rank just defined. This is exactly the order of DPT's rooted-tree code: the code begins with its size and is followed by the sorted codes of its immediate subtrees. Induction on size establishes this identification; an unrelated pre-existing tree ranking would not automatically have the same order. During unranking, first produce the numerical $(\text{size},\text{rank})$ tokens for the children. Only after their selection, recursively decode the actual subtrees. This distinction matters: recursively constructing objects at every binary-search trial would not be justified by the present complexity proof. The actual recursive calls are on the disjoint subtrees of the output tree, so there are only $O(s)$ of them. Polynomial work per call remains polynomial overall. A recursion stack of depth at most $s$ suffices for the polynomial-space claim; the linear-space claims elsewhere do not rely on this indexing implementation. \subsubsection{Cycles and multisets of components} A connected functional digraph is a directed cycle of rooted trees. Apply the preceding weighted-cycle theorem with $a_j=t_j$. At total size $s$, order components first by cycle length and then by the least rotation of the corresponding tree-ordinal word. The count of a block of length $\ell$ is \begin{equation} c_{s,\ell}=\frac1\ell \sum_{d\mid\gcd(s,\ell)}\varphi(d) [z^{s/d}]\left(\sum_{j\ge1}t_jz^j\right)^{\ell/d}. \label{eq:component-count} \end{equation} Thus $c_s=\sum_{\ell=1}^{s}c_{s,\ell}$ is polynomial-time computable. For ranking, add the sizes of shorter-length blocks and the threshold rank within the actual length. For unranking, locate the length block, unrank its tree-ordinal necklace, and decode the selected trees. Finally a functional digraph is an unordered multiset of these components. Use $c_s$ as the weight-$s$ alphabet count and the component rank above as its within-weight order. Lemma~\ref{lem:mset-index} applies once more. \begin{theorem}[Polynomial indexing of functional digraphs] \label{thm:functional-index} Unlabelled rooted trees, connected functional digraphs and arbitrary functional digraphs of a prescribed size admit exact counting, ranking and unranking in polynomial bit time and polynomial space. For rooted trees the order is DPT's rooted-code order. For components it is cycle length followed by least-rotation lexicographic order of tree ordinals; for arbitrary graphs it is multiset lexicographic order of the size-first component ordinals. No alphabet of trees or components is listed in advance. \end{theorem} \begin{proof} The constructions above provide the procedures. To check the oracle assumptions at each composition step, rooted-tree counts have $O(s)$ bits, and both connected and arbitrary unlabelled functional-digraph counts are at most the number $s^s$ of labelled endofunctions. Their bit lengths are therefore $O(s\log(s+1))$. The output encodings have polynomial length. Actual recursively decoded subobjects have total size $s$, and numeric search candidates require no recursive decoding. The positivity and bit-length hypotheses are consequently preserved. \end{proof} The theorem does not rank the DPT reverse-search output order. Likewise, consecutive-rank generation is a polynomial-delay algorithm but carries none of the specialized linear-delay guarantees. Exact uniform sampling of isomorphism classes follows by drawing a uniform integer in the counted range and unranking it. This is uniformity over isomorphism classes, which differs from sampling a uniformly random labelled endofunction and discarding its labels.