Simple Hierarchy
A module for a tree structure for a class hierarchy.
simple_hierarchy.tree.
Node
Bases: object
object
Stores a node with name and number of classes.
Used to store a node with a name of number of classes. This class is inteded for storing class heiarchies, as such, their is both a name and number of classes per node. The node is linked to a list of children and its parent.
name (str) – The name of the node.
str
n_classes (int) – The number of classes for this class that node represents.
int
parent (Optional[Node]) – The parent of the node, if its the root, then the parent is None.
Optional
name
The name of the node.
n_classes
The number of classes for this class that node represents.
parent
The parent of the node, if its the root, then the parent is None.
children
A list of nodes that are children of this node.
add_child
Adds a child node.
Adds a child node to current node. This child is added to a list of children.
child (Node) – A node to add the current node..
None
get_tuple
Get tuple of name, n_classes for each node.
Tuple[str, int]
Tuple
Tree
Stores a root node.
Creates a Tree oject to store a root node as defined with the Node class.
root (Node) – The root node to store as a tree.
root
The root node of the tree.