to_em_notation#

to_em_notation(g)#

Return EM dict notation of a planar diagram.

For each node, returns a CCW-ordered list of (neighbor, neighbor_pos) tuples. This uses the diagram’s endpoint “twin” relation to find the adjacent endpoint.

Parameters:

g (PlanarDiagram) – Planar diagram.

Returns:

dict – Mapping node -> [(neighbor, neighbor_pos), ...].

Return type:

Dict[Any, list[tuple[Any, int]]]

Examples

>>> from knotpy.classes.planardiagram import PlanarDiagram
>>> d = PlanarDiagram()
>>> d.add_vertices_from(["a", "b"])
>>> d.set_arc((("a", 0), ("b", 0)))
>>> em = to_em_notation(d)
>>> em["a"] == [("b", 0)]
True