rewire#
Functions
|
Permute the endpoint indices of a node. |
|
Pull out one endpoint and plug it somewhere else. |
|
Unplug an endpoint and overwrite the destination slot. |
|
Swap two endpoints in place (no insertion/removal). |
- pull_and_plug_endpoint(k, source_endpoint, destination_endpoint)#
Pull out one endpoint and plug it somewhere else.
This splits the source arc, creates a leaf at the destination, connects them, and removes temporary bivalent vertices. Operates in place.
- Parameters:
k (PlanarDiagram | OrientedPlanarDiagram) – Diagram to modify.
source_endpoint (Endpoint | tuple) – Endpoint or (node, position) to pull out.
destination_endpoint (Endpoint | tuple) – Endpoint or (node, position) where it is plugged.
- Return type:
None
- replug_endpoint(k, source_endpoint, destination_endpoint)#
Unplug an endpoint and overwrite the destination slot.
Does not insert at the destination (overwrites). Operates in place.
- Parameters:
k (PlanarDiagram | OrientedPlanarDiagram) – Diagram to modify.
source_endpoint (Endpoint | tuple) – Endpoint or (node, position) to unplug.
destination_endpoint (Endpoint | tuple) – Endpoint or (node, position) to overwrite.
- Raises:
ValueError – If unplugging from a crossing (would create 3-valent crossing).
- Return type:
None
- swap_endpoints(k, ep1, ep2)#
Swap two endpoints in place (no insertion/removal).
- Parameters:
k (PlanarDiagram | OrientedPlanarDiagram) – Diagram to modify.
ep1 (Endpoint | tuple) – Endpoint or (node, position).
ep2 (Endpoint | tuple) – Endpoint or (node, position).
- Return type:
None
- permute_node(k, node, permutation)#
Permute the endpoint indices of a node.
Example
permutation = {0: 0, 1: 2, 2: 3, 3: 1} maps [a, b, c, d] -> [a, d, b, c].
- Parameters:
k (PlanarDiagram | OrientedPlanarDiagram) – Diagram to modify.
node – Node label.
permutation (dict | list | tuple) – Mapping or sequence giving new index for each old index.
- Return type:
None