disjoint_union#
Disjoint components and disjoint sums of planar diagrams.
A disjoint component is a connected component that shares no nodes (crossings, vertices, …) with another. The disjoint sum of diagrams places them side-by-side without identifying any nodes or arcs.
- number_of_disjoint_components(k)#
Number of connected components.
- Parameters:
k (PlanarDiagram) – Diagram.
- Returns:
Count of components.
- Return type:
int
- disjoint_union_decomposition(k)#
Split a diagram into its disjoint (connected) components.
Components are returned as standalone diagrams. The result is ordered deterministically by the tuple of sorted node names in each component.
Notes
If
k.framing
is not None, the framing is placed on the first returned component and set to 0 on all subsequent ones.- Parameters:
k (PlanarDiagram) – Diagram to decompose.
- Returns:
List of component diagrams.
- Return type:
list[PlanarDiagram]
- add_unknot(k, number_of_unknots=1, inplace=True)#
Add one or more unknots disjointly to a diagram.
Each unknot is represented by a single degree-2 vertex with a loop (two opposite endpoints joined).
- Parameters:
k (PlanarDiagram) – Target diagram.
number_of_unknots (int) – How many unknots to add.
inplace (bool) – If False, operate on a copy and return it.
- Returns:
The diagram with the unknots added (same object if
inplace=True
).- Return type:
- is_disjoint_union(k)#
Whether the diagram has more than one connected component.
- Parameters:
k (PlanarDiagram) – Diagram.
- Returns:
True if there are ≥ 2 components.
- Return type:
bool
- disjoint_union(*knots, return_relabel_dicts=False)#
Disjoint sum of multiple diagrams (all of the same type).
The nodes of each input are relabeled to unique fresh names and placed into a single diagram without identifying any nodes or arcs.
- Parameters:
*knots (PlanarDiagram | OrientedPlanarDiagram) – One or more diagrams (all
PlanarDiagram
or allOrientedPlanarDiagram
).return_relabel_dictionaries – If True, also return a list of dictionaries mapping old node names (per component) to new node names in the sum.
return_relabel_dicts (bool)
- Returns:
The disjoint sum diagram, and optionally the relabeling dictionaries.
- Raises:
ValueError – If no diagrams are provided.
TypeError – If input diagrams mix oriented and unoriented types.