generate oriented forests of a given size
posint; number of nodes in an oriented forest
(optional) equation(s) of the form option = value; specify options for the OrientedForests command
compile = truefalse
True means compile the iterator. The default is true.
The OrientedForests command returns an iterator that generates all oriented forests on n-nodes, in decreasing lexicographic order of their level codes.
The iterator output Array contains the parent pointers, in preorder, of the nodes in the forest. If the pointer is zero, the node is the root of a tree. In the following two-tree forest, the representation is [0,1,2,0,4,5,5,4]. For example, the entry at index 8 is 4, which indicates the parent of node 8 is node 4.
In addition to the common iterator methods, this iterator object has the following methods. The self parameter is the iterator object.
Number(self): return the number of iterations required to step through the iterator, assuming it started at rank one.
Construct an iterator of oriented forests with 4 nodes.
1: 0 1 2 3
2: 0 1 2 2
3: 0 1 2 1
4: 0 1 2 0
5: 0 1 1 1
6: 0 1 1 0
7: 0 1 0 3
8: 0 1 0 0
9: 0 0 0 0
Compute the number of iterations.
Knuth, Donald Ervin. The Art of Computer Programming, volume 1, 3rd ed. fundamental algorithms, sec. 2.3, Trees, pp. 308-309.
Knuth, Donald Ervin. The Art of Computer Programming, volume 1, 3rd ed. fundamental algorithms, sec. 220.127.116.11, Enumeration of Trees, pp. 386-394.
Knuth, Donald Ervin. The Art of Computer Programming, volume 4, fascicle 4; generating all trees, sec. 18.104.22.168, generating all trees, algorithm O, oriented forests, p. 24.
The Iterator[OrientedForests] command was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
Download Help Document
What kind of issue would you like to report? (Optional)