from_plantri_notation#

from_plantri_notation(graph_string)#

Parse a plantri notation string into a PlanarDiagram.

Supports:
  • Alphabetical: "5 bcde,aedc,abd,acbe,adb"

  • Numeric: "7: 1[2 3 4 5] 2[1 5 6 3] ..."

The plantri order is CW; this function reverses each adjacency string to obtain CCW before building the diagram.

Parameters:

graph_string (str) – Plantri string (alphabetical or numeric).

Returns:

PlanarDiagram – New diagram with vertices 'a','b','c',... and arcs set.

Raises:

ValueError – If vertex count exceeds 52 (a–zA–Z) or parsing fails.

Return type:

PlanarDiagram

Examples

>>> s = "5 bcde,aedc,abd,acbe,adb"
>>> d = from_plantri_notation(s)
>>> isinstance(d, PlanarDiagram)
True
>>> d.number_of_nodes == 5
True