TreeNode
- class compas.datastructures.TreeNode[source]
Bases:
Data
A node of a tree data structure.
- Parameters:
- **kwargsdict[str, Any], optional
User-defined attributes of the tree node.
- Attributes:
- parent
compas.datastructures.TreeNode
The parent node of the tree node.
- childrenlist[
compas.datastructures.TreeNode
] The children of the tree node.
- tree
compas.datastructures.Tree
The tree to which the node belongs.
- is_rootbool
True if the node is the root node of the tree.
- is_leafbool
True if the node is a leaf node of the tree.
- is_branchbool
True if the node is a branch node of the tree.
- acestorsgenerator[
compas.datastructures.TreeNode
] A generator of the acestors of the tree node.
- descendantsgenerator[
compas.datastructures.TreeNode
] A generator of the descendants of the tree node, using a depth-first preorder traversal.
- parent
Methods
Add a child node to this node.
Construct an object of this type from the provided data.
Remove a child node from this node.
Traverse the tree from this node.
Inherited Methods
Converts the instance to a string.
Make an independent copy of the data object.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Validate the data against the object's data schema.