BinTreeNetworkX#
- class tangles.util.tree.BinTreeNetworkX(nodes: list[BinTreeNode], ids: list[int] | None = None, labels: dict[int, str] | None = None, depths_for_layout=None)#
Responsible for generating and managing a NetworkX representation of a list of BinTreeNodes.
A NetworkX binary tree is created from nodes. The nodes are indexed by a list of ids. Every node is connected to every direct successor.
Depending on the choice of nodes this means that there might be nodes with more than two descendents.
Parameters#
- nodeslist of BinTreeNode
The list of nodes which should be included in the tree.
- idslist of int, optional
The ids of the input nodes. Defaults to the indices of the nodes.
- labelsdict, optional
The labels of the input nodes. Defaults to string representations of the ids.
Properties
The underlying directed graph of the tree
Methods
Draw the tree and label the tangles with their id
Get a list of all tangle ids which are labeled in the tree by the specified label
Get the label of the node representing the tangle with the specified tangle id
Relabel a node of the tree
Position the nodes of the tree in the following way: