duality#

“Create a dual graph of a planar diagram.

Functions

arc_face_graph(k)

Return the arc–face adjacency graph.

dual_planar_diagram(k)

Return the dual planar diagram of k.

dual_planar_diagram(k)#

Return the dual planar diagram of k.

In the dual: - Each face of k becomes a vertex. - Two dual vertices are adjacent for each pair of adjacent faces across an arc of k. - The degree of a dual vertex equals the number of endpoints around the original face.

This implementation labels dual vertices as f0, f1, ... to avoid using unhashable face objects as node IDs.

Parameters:

k (PlanarDiagram) – Input (unoriented) planar diagram.

Returns:

A new planar diagram representing the dual.

Return type:

PlanarDiagram

Example

>>> G = PlanarDiagram()
>>> G.set_arcs_from("a0b0,a1b1")  # two parallel edges → two faces
>>> D = dual_planar_diagram(G)
>>> isinstance(D, PlanarDiagram)
True
arc_face_graph(k)#

Return the arc–face adjacency graph.

Nodes are arcs of k (as they appear in k.arcs); two arcs are adjacent if they lie on the same face.

Parameters:

k (PlanarDiagram) – Input planar diagram.

Returns:

dict – Mapping arc -> set[arc] where each value contains arcs that share at least one face with the key arc.

Return type:

dict