Reconstruction from depth-first outdegrees #
Read a natural degree word from right to left. At a vertex of degree d,
the first d trees already reconstructed become its ordered children.
The decoder fails if fewer than d trees are available. A tree word must
leave exactly one tree; an empty word represents the empty forest only.
Concatenate the degree words in component order.
Equations
- ts.degrees = (List.map BGW.PlaneTree.degrees ts).flatten
Instances For
Reconstruct an ordered forest from its depth-first outdegrees.
Equations
Instances For
Prepending one complete tree word adds that tree to any decoded suffix.
The parser respects concatenation with any suffix word, valid or invalid.
A successful parse reproduces exactly the input degree word.
Successful parsing is exactly membership in the range of the forest encoder.
The number of roots is the deficit between word length and total degree.
Reconstruct a single tree, rejecting failed parses and nonsingleton forests.
Equations
- BGW.PlaneTree.ofDegrees? ds = match BGW.PlaneForest.ofDegrees? ds with | some [t] => some t | x => none
Instances For
A single-tree parse is precisely a forest parse with one component.