\subsection{Linear conversion to the DPT tree and component codes} \label{sec:rl-dpt-conversion} The recursive order used by our forest iterator need not be the lexicographic tree order of~\cite{DPT2024}. This distinction does not impose a quadratic cost on the output. We give a linear conversion for rooted trees and connected components. The precise scope of the assertion about disconnected graphs is stated below. The underlying method is the classical bottom-up ranking of rooted trees~\cite{AHU1974}. What needs checking here is the \emph{particular} order imposed by DPT's size codes, and the total cost of sorting variable-length signatures. An arbitrary isomorphism-invariant tree rank would preserve equality but need not preserve that order. For example, a three-vertex star and a three-vertex path have DPT codes $(3,1,1)$ and $(3,2,1)$. A forest iterator is free to put the path first under a different recursive order. The conversion must recover the displayed numerical lexicographic comparison without writing a complete code for every intermediate subtree. Write $C(T)$ for the DPT code of a rooted tree: its first integer is $|T|$, and the remainder is the concatenation of the codes of its children in nondecreasing lexicographic order. Thus $C(T)$ has exactly $|T|$ positive integer entries. In particular, no two distinct valid tree codes are in a proper-prefix relation: equal first entries imply equal lengths. Consequently, comparing two sequences of tree codes lexicographically is equivalent to comparing their concatenations, up to the usual proper-prefix case for the sequences themselves. \begin{lemma}[Linear DPT forest conversion] \label{lem:rl-dpt-forest-conversion} An arbitrary ordered rooted forest on $n$ vertices, represented by its preorder subtree sizes or by adjacency lists, can be converted to the DPT codes of all its roots in $O(n)$ time and $O(n)$ words. At the same cost one can assign dense integer ranks to the roots which preserve equality and lexicographic order of these codes. The root codes may be returned in their original order, or grouped in nondecreasing DPT order with multiplicities. The input is a valid forest; when adjacency lists are used, its roots and parent--child orientation are supplied or obtained by one traversal. \end{lemma} \begin{proof} The empty forest is immediate; assume $n>0$. Parse the input into child lists, parent pointers, and depth layers $V_0,\ldots,V_D$, placing all forest roots at depth zero. For preorder subtree sizes $s_v$, the children of the vertex at position $v$ are found by starting at $v+1$ and repeatedly advancing by the subtree size at the current position, until reaching $v+s_v$. Every forest edge is visited once. Depth layers and all subtree sizes can likewise be obtained in linear time from adjacency lists. First compress the size labels \emph{separately within each depth layer}. This is done by one global radix sort of the $n$ pairs $(d(v),s_v)$: stable counting sort first by size in $\{1,\ldots,n\}$ and then by depth in $\{0,\ldots,D\}$. Scanning the result gives a dense rank $a_v\in\{0,\ldots,|V_{d(v)}|-1\}$ which preserves the numerical order of subtree sizes within each layer. Both counting sorts together take $O(n)$ time and words. In particular, we do not clear an alphabet of size $n$ separately at every depth. Process the layers from $D$ down to zero. Suppose that the vertices of $V_{d+1}$ already have dense ranks $r_u$ preserving their DPT-code order. Put these vertices into buckets by $r_u$ and scan the buckets in increasing order, appending each vertex to its parent's new child list. This sorts every child list in $V_d$ in total $O(|V_d|+|V_{d+1}|)$ time. Form the integer-string signature \[ \sigma(v)=(a_v,r_{u_1},\ldots,r_{u_t}), \] where $u_1,\ldots,u_t$ are the newly ordered children of $v$. Sort these signatures lexicographically by Lemma~\ref{lem:linear-integer-string-sort}, then assign one rank to each block of equal signatures. The signatures at this layer have total length $|V_d|+|V_{d+1}|$ (with $V_{D+1}=\varnothing$), and their alphabet has size at most $\max(|V_d|,|V_{d+1}|)$. Thus their sorting and ranking also take $O(|V_d|+|V_{d+1}|)$ time and words. Equality of adjacent signatures can be checked directly: every signature participates in at most two such comparisons, so these checks are linear in their total length. We verify the rank invariant by induction. Different first coordinates compare exactly as the first entries $s_v$ of the DPT codes. If these coordinates agree, the subtree sizes agree. The inductive hypothesis compares each child rank exactly as its DPT code. At the first unequal child, the absence of proper-prefix relations between tree codes shows that the same comparison decides the concatenated child-code strings. If there is no unequal child, equality of parent sizes prevents one child sequence from being a proper prefix of the other: every omitted child would have positive size. Hence signature equality and order coincide exactly with DPT-code equality and order on $V_d$. The sum of $|V_d|+|V_{d+1}|$ over all layers is at most $2n$. The sum of their alphabet sizes is also at most $2n$. All ranks, pointers, layers, child lists and temporary signatures fit in $O(n)$ words; temporary sorting data can be discarded after each layer. Finally traverse each root in preorder through its newly sorted children and output the original subtree-size labels. These root codes have total length $n$. Their ranks are the common ranks just constructed on $V_0$. A final counting sort on these dense ranks groups equal root codes and produces the sorted alphabet and multiplicities, if desired, in $O(n)$ further time and words. \end{proof} \begin{corollary}[DPT connected outputs at linear cost] \label{cor:rl-dpt-connected-output} A connected functional digraph on $n$ vertices, given as a cyclic sequence of recursive-order rooted-tree codes, can be converted to its exact DPT connected-component code in $O(n)$ time and $O(n)$ words. Therefore any connected enumeration using $O(n)$ words and $O(n)$ worst-case delay retains those bounds when the required output is the DPT connected-component code. Its output \emph{sequence} is still the sequence of our iterator. \end{corollary} \begin{proof} Apply Lemma~\ref{lem:rl-dpt-forest-conversion} to the trees attached to the cycle, preserving their cyclic order. Their root ranks are integers in a common ordered alphabet. A linear-time least-rotation algorithm on the rank word selects precisely a lexicographically least rotation of the sequence of DPT tree codes. Expand the already constructed root codes in this rotation. There are at most $n$ root ranks and exactly $n$ tree-code entries. This proves the conversion bound. Applying it once to each output preserves both the claimed delay and working-space bounds, and it preserves uniqueness because it is an isomorphism invariant and the original enumeration has one output per class. \end{proof} For disconnected graphs the same procedure converts all component codes in total $O(n)$ time. If a canonical global order is required, first apply the forest conversion to \emph{all} cycle-rooted trees of the graph together, so their root ranks lie in one common ordered alphabet. Canonically rotate each component's rank sequence and sort the resulting integer strings, optionally prefixed by the component's total size. Their total length, including these optional prefixes, is at most $2n$, and the alphabet lies in $\{0,\ldots,n\}$. The same integer-string sorting lemma therefore provides, in linear time and space, the global order by DPT component-code lexicographic order, or by component size followed by that order. Expansion still produces only $n$ tree-code entries. \begin{corollary}[Linear disconnected output normalization] \label{cor:rl-dpt-disconnected-output} Any disconnected enumeration using $O(n)$ words and $O(n)$ worst-case delay retains those bounds if each output uses exact DPT rooted-tree and connected-component codes, with components ordered by size and then by their DPT codes. This statement does \emph{not} assert that the resulting global code is the particular disconnected code of Definition~14 in~\cite{DPT2024}: that definition orders equal-sized components according to the original connected generator's order. The separate theorem in Section~\ref{sec:dpt-linear-normalization} handles that generator order. \end{corollary} The conversion spends $O(n)$ work and uses $O(n)$ words for each output. It therefore preserves linear-word worst-case delay bounds, but does \emph{not} by itself preserve a CAT total, constant auxiliary space, or an $O(n)$-bit workspace. In particular, it cannot be inserted after each output of a CAT generator and charged as constant time.