PlanarDiagram¶
Classes for working with planar diagram notation of knot diagrams.
See individual class documentation for more details.
API documentation¶
-
class
pyknotid.representations.planardiagram.
Crossing
(a=None, b=None, c=None, d=None)[source]¶ Bases:
list
A single crossing in a planar diagram. Each
PlanarDiagram
is a list of these.Parameters: - a (int or None) – The first entry in the list of lines meeting at this Crossing.
- b (int or None) – The second entry in the list of lines meeting at this Crossing.
- c (int or None) – The third entry in the list of lines meeting at this Crossing.
- d (int or None) – The fourth entry in the list of lines meeting at this Crossing.
-
as_mathematica
()[source]¶ Get a string of mathematica code that can represent the Crossing in mathematica’s knot library.
The mathematica code won’t be valid if any lines of self are None.
Return type: str
-
components
()[source]¶ Returns a de-duplicated list of lines intersecting at this Crossing.
Return type: list
-
class
pyknotid.representations.planardiagram.
PlanarDiagram
(crossings='')[source]¶ Bases:
list
A class for containing and manipulating planar diagrams.
Just provides convenient display and conversion methods for now. In the future, will support simplification.
Shorthand input may be of the form
X_1,4,2,5 X_3,6,4,1 X_5,2,6,3
. This is (should be?) the same as returned by repr.Parameters: crossings (array-like or string or GaussCode) – The list of crossings in the diagram, which will be converted to an internal planar diagram representation. Currently these are mostly converted via a GaussCode instance, so in addition to the shorthand any array-like supported by GaussCode
may be used.-
as_mathematica
()[source]¶ Returns a mathematica code representation of self, usable in the mathematica knot tools.
-
as_networkx
()[source]¶ Get a networkx graph representing the planar diagram, where each node is a crossing and each edge is an arc. This is a non-directed non-multi graph; where two arcs join the same crossing, they are represented as a single edge, but information about duplicates is returned alongside the graph.
Returns: - g (Graph) – The networkx graph
- duplicates (list) – A list of tuples representing nodes joined by multiple edges.
- heights (dict) – A dictionary of (start, end, arc_number) graph edges, containing the start and end height of each edge.
- first_edge (tuple) – The first edge in the graph, including (start, end, arc_number).
-