rewire#

Functions

permute_node(k, node, permutation)

Permute the endpoint indices of a node.

pull_and_plug_endpoint(k, source_endpoint, ...)

Pull out one endpoint and plug it somewhere else.

replug_endpoint(k, source_endpoint, ...)

Unplug an endpoint and overwrite the destination slot.

swap_endpoints(k, ep1, ep2)

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:
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:
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:
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