TreeNode¶
-
class
visualife.diagrams.TreeNode(id, value)¶ Bases:
objectCreates a tree node. Leaves should be appended later :param id: (
string) a string that is used to identify graphical elements of this tree. ID of a node will be created asID-idxwhereIDis the ID of a layout object andidxis the index of this node :param value: value stored at this nodeAttributes Summary
childrenReturns a reference of the list of children nodes children_deepcopyReturns a deep copy of the list of children nodes without None elements idparentMethods Summary
append(n)Appends a children node i.e. collect_leaves(root_node[, leaves])Collects all leaves of a given tree from the left to the right :param root_node: ( TreeNode) - the root of a tree :param leaves: (list) - a list where the leaves will be appended :return: the list of leavescount_nodes()Count all the nodes of a given tree :param root_node: ( TreeNode) - the root of a tree :return: the number of nodesis_leaf()nodes([if_update])Returns a list of all nodes of this tree :param if_update: ( boolean) - if True, the list will be collected from scratch, otherwise a cached copy is returned :return: a list of all nodes of this treevalues()Attributes Documentation
-
children¶ Returns a reference of the list of children nodes
-
children_deepcopy¶ Returns a deep copy of the list of children nodes without None elements
-
id¶
-
parent¶
Methods Documentation
-
append(n)¶ Appends a children node i.e. a leaf to this tree
-
static
collect_leaves(root_node, leaves=[])¶ Collects all leaves of a given tree from the left to the right :param root_node: (
TreeNode) - the root of a tree :param leaves: (list) - a list where the leaves will be appended :return: the list of leaves
-
count_nodes()¶ Count all the nodes of a given tree :param root_node: (
TreeNode) - the root of a tree :return: the number of nodes
-
is_leaf()¶
-
nodes(if_update=False)¶ Returns a list of all nodes of this tree :param if_update: (
boolean) - if True, the list will be collected from scratch,otherwise a cached copy is returnedReturns: a list of all nodes of this tree
-
values()¶
-