Tangle#

class tangles.Tangle(agreement: int, core: set[tuple[int, int]] | None = None, parent: Tangle | None = None)#

A node in the tangle search tree. It represents a tangle.

The path of the tangle search tree from the root to this node determines the features in this tangle: Each edge on the path determines the orientation of a separation.

More precisely, if the path contains an edge from a node on tree level \(k-1\) to a node on tree level \(k\) which is a left child, then this tangle contains the left orientation of the separation corresponding to tree level \(k\) (and vice versa for a right child).

Attributes#

parentTangle or None

The parent in the tangle search tree. It is a tangle that orients every separation except for the highest order separation of this tangle. None if the tangle is the root tangle.

left_childTangle or None

The left child in the tangle search tree. It is a tangle that orients one more separation than this tangle. The left child orients this additional separation to the left. None if there is no left child.

right_childTangle or None

The right child in the tangle search tree. It is a tangle that orients one more separation than this tangle. The right child orients this additional separation to the right. None if there is no right child.

coreset[OrientedSep]

The set of all minimal oriented separations contained within this tangle.

agreementint

The agreement value of this tangle.

Methods

children()

Return the list of children of this node

copy()

Create a new tangle with the same core and agreement value

copy_subtree()

Copy the subtree starting at this node

copy_subtree_into_children()

Replace each child by a copy of the subtree starting at this node

detach()

Detach the node by removing its pointer to its parent and the parents pointer to it

equal_data()

Check whether two tangles have the same data (core and agreement value)

from_indicator_matrix()

Turn an indicator matrix back into a binary tree

is_leaf()

Whether this node is a leaf

leaves_in_subtree()

Find all leaves in the binary tree

level()

Returns the level of this node

level_in_subtree()

Return all the nodes at a certain depth below this node

open()

Open the tangle by removing its children

path_from_root_indicator()

Returns the list of sides one has to take to go from the root to this node

set_left_child()

Set the left child of the node

set_right_child()

Set the right child of the node

to_indicator_matrix()

Turn a list of nodes into an indicator matrix