Class: TreeNode

TreeNode

new TreeNode(parent, symbol)

A node in a tree. A node has a parent, a symbol as a label and children.
Parameters:
Name Type Description
parent TreeNode The parent of the node. Null indicates no parent, i.e. root node
symbol string The label of the node
Source:

Methods

copy() → {TreeNode}

Copy the tree node.
Source:
Returns:
A copy of the tree node.
Type
TreeNode

grow(node, depth, maxDepth, full, symbols)

Recursively grow a node to max depth in a pre-order, i.e. depth-first left-to-right traversal.
Parameters:
Name Type Description
node TreeNode Root node of subtree
depth number Current tree depth
maxDepth number Maximum tree depth
full boolean Grows the tree to max depth when true
symbols Symbols Set of symbols to chose from
Source:

strAsTree() → {string}

Return an s-expression for the node and its descendants.
Source:
Returns:
S-expression of tree.
Type
string