to_pd_notation#

to_pd_notation(k)#

Serialize a planar diagram to PD notation.

Output uses abbreviations inferred by node type: X[...,...,...,...] for crossings and V[...] for vertices. Arc ids are assigned by enumerating unique arcs as they appear.

Parameters:

k (PlanarDiagram) – Diagram to serialize.

Returns:

str – PD notation string.

Return type:

str

Examples

>>> from knotpy.classes.planardiagram import PlanarDiagram
>>> d = PlanarDiagram()
>>> d.add_vertices_from(["a","b"])
>>> d.set_arc((("a",0),("b",0)))
>>> out = to_pd_notation(d)
>>> out.startswith("V[") or out.startswith("X[")
True