from_pd_notation#

from_pd_notation(text, node_type=<class 'str'>, oriented=False, **attr)#

Create a planar diagram from PD notation.

Supports Mathematica, KnotInfo, and Topoly variants. Nodes default to 'a','b','c',... if node_type is str; otherwise integers are used in order of appearance.

Parameters:
  • text (str) – PD notation string (mixed styles allowed; auto-detected).

  • node_type (type | Any) – Use str for a,b,c,... labels (default), or a different marker to keep integers.

  • oriented (bool) – Whether to create an oriented diagram (not implemented yet).

  • **attr (Any) – Diagram attributes to set (e.g., name, framing).

Returns:

PlanarDiagram – Parsed diagram.

Raises:
  • NotImplementedError – If oriented=True (placeholder).

  • ValueError – If the PD string is malformed or arcs are not paired.

Return type:

PlanarDiagram

Examples

>>> s = "V[1,2,3], X[2,3,4,5]"
>>> d = from_pd_notation(s)
>>> isinstance(d, PlanarDiagram)
True