orientation#
Algorithms that deal with orientation.
Functions
|
Orient an unoriented diagram using the default edge directions. |
|
Orient an unoriented diagram along given edge paths. |
|
Generate all orientations of an unoriented diagram. |
|
Reverse orientation of an oriented diagram. |
|
Return an unoriented copy of the diagram. |
- orient(k)#
Orient an unoriented diagram using the default edge directions.
This picks the natural direction for every edge returned by
knotpy.algorithms.topology.edges()
.- Parameters:
k (PlanarDiagram) – Unoriented diagram.
- Returns:
Oriented diagram.
- Return type:
Example
>>> import knotpy as kp >>> k = kp.knot("3_1") >>> kp.orient(k) Diagram named 3_1 a → X(b3o c0i c3i b0o), b → X(a3i c2o c1o a0i), c → X(a1o b2i b1i a2o)
- unorient(k)#
Return an unoriented copy of the diagram.
- Parameters:
- Return type:
- orientations(k, up_to_reversal=False)#
Generate all orientations of an unoriented diagram.
If
up_to_reversal
is True, the first edge is always oriented “forward” and only the remaining edges are flipped (removing a global reversal).- Parameters:
k (PlanarDiagram) – Unoriented diagram.
up_to_reversal (bool) – If True, return orientations modulo global reversal.
- Returns:
List of
OrientedPlanarDiagram
.- Return type:
list[OrientedPlanarDiagram]
Notes
If
k
is already oriented, it is first “unoriented” (structure preserved) and then all orientations are generated.If
k.name
is set, each result’s name is suffixed with a string of “+”/“–” per-edge choices (useful for debugging).
Example
>>> import knotpy as kp >>> k = kp.knot("3_1") >>> k1, k2 = kp.orientations(k) >>> print(f'Oriented trefoils: {k1} and {k2}') Oriented diagrams: Diagram named 3_1+ a → X(b3o c0i c3i b0o), b → X(a3i c2o c1o a0i), c → X(a1o b2i b1i a2o) and Diagram named 3_1- a → X(b3i c0o c3o b0i), b → X(a3o c2i c1i a0o), c → X(a1i b2o b1o a2i)
- reverse(k, inplace=False)#
Reverse orientation of an oriented diagram.
Swaps each arc’s endpoint types (ingoing/outgoing) accordingly.
- Parameters:
k (OrientedPlanarDiagram) – Oriented planar diagram to reverse.
inplace (bool) – If
True
, modifyk
in place, otherwise return a copy.
- Returns:
The orientation-reversed diagram.
- Raises:
TypeError – If
k
is an unorientedPlanarDiagram
.- Return type: