pygrenade_vx.network.multicompartment.tree.Node

class pygrenade_vx.network.multicompartment.tree.Node(children: set, connections: Optional[List, None] = None, label: Optional[str, None] = None)

Bases: object

Node that contains children and connecitons between its children.

__init__(children: set, connections: Optional[List, None] = None, label: Optional[str, None] = None)

Tree node that contains children and connections between its children.

For leaf nodes the child is not a Node 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 node.

Methods

__init__(children[, connections, label])

Tree node that contains children and connections between its children.

get_fully_labeled_children()

Return a mapping between the nodes and their full labels.

get_fully_labeled_connections(full_labels[, …])

Return connections with the full labels for connected nodes.

get_fully_labeled_leaf_elements()

Return a mapping between the data classes stored in leaf nodes and the full label of the leaf nodes.

is_leaf()

Return wether a node is a leaf i.e. only contains a single element of a data class.

node_in_tree(node)

Recursively iterates trough all children of the current node to check wether the searched node is within the tree of this node.

get_fully_labeled_children()Tuple[Dict, Dict]

Return a mapping between the nodes and their full labels.

The full labels are created by concatenating the labels of all levels of the tree.

Returns

Two dicitonaries containing the mapping from leaf nodes 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 nodes.

Returns

List of connections with full node labels.

get_fully_labeled_leaf_elements()Tuple[Dict, Dict]

Return a mapping between the data classes stored in leaf nodes and the full label of the leaf nodes.

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 node label and the inverse mapping.

is_leaf()bool

Return wether a node is a leaf i.e. only contains a single element of a data class.

Assume that a leaf node does not contain another node but a element of a data class.

Returns

Wether only a single element is contained.

node_in_tree(node)bool

Recursively iterates trough all children of the current node to check wether the searched node is within the tree of this node.

Returns

Wether the searched for node is in the tree of this node.