pygrenade_vx.network.abstract.multicompartment.tree.Tree
-
class
pygrenade_vx.network.abstract.multicompartment.tree.Tree(children: List, connections: Optional[List, None] = None, label: Optional[str, None] = None) Bases:
objectTree that contains children and connections between its children.
-
__init__(children: List, connections: Optional[List, None] = None, label: Optional[str, None] = None) Tree that contains children and connections between its children.
For leafs the child is not a Tree but a data class.
- Parameters
children – Set of children.
connections – Optional connections between children. if there is more than one child a connection is required.
label – Optional label for the tree.
Methods
__init__(children[, connections, label])Tree that contains children and connections between its children.
contains(tree)Recursively iterates trough all children of the current tree to check whether the searched tree is within this tree.
Return a mapping between the trees and their full labels.
get_fully_labeled_connections(full_labels[, …])Return connections with the full labels for connected trees.
Return a mapping between the data classes stored in leafs and the full label of the leafs.
is_leaf()Return whether a tree is a leaf i.e. only contains a single element of a data class.
-
contains(tree) → bool Recursively iterates trough all children of the current tree to check whether the searched tree is within this tree.
- Returns
Whether the searched for tree is part of this tree.
-
get_fully_labeled_children() → Tuple[Dict, Dict] Return a mapping between the trees and their full labels.
The full labels are created by concatenating the labels of all levels of the tree.
- Returns
Two dictionaries containing the mapping from leafs to their labels and the inverse mapping.
-
get_fully_labeled_connections(full_labels: Dict, leaf_labels: bool = True) → List Return connections with the full labels for connected trees.
- Returns
List of connections with full tree labels.
-
get_fully_labeled_leaf_elements() → Tuple[Dict, Dict] Return a mapping between the data classes stored in leafs and the full label of the leafs.
The full labels are created by concatenating the labels of all levels of the tree.
- Returns
Two dictionaries containing the mapping from the data in a leaf to the leaf label and the inverse mapping.
-
is_leaf() → bool Return whether a tree is a leaf i.e. only contains a single element of a data class.
Assume that leafs do not contain other trees but a element of a data class.
- Returns
Whether only a single element is contained.
-