passagemath-planarity

raw JSON →
10.8.4 verified Fri May 01 auth: no python

Wraps the edge addition planarity suite for graph planarity testing and embedding in passagemath. Version 10.8.4, requires Python >=3.11, <3.15. Part of the passagemath ecosystem. Release cadence follows passagemath.

pip install passagemath-planarity
error ModuleNotFoundError: No module named 'planarity'
cause Importing the module directly without the passagemath namespace.
fix
Use 'from passagemath.planarity import planarity' instead of 'import planarity'.
error ModuleNotFoundError: No module named 'passagemath'
cause The passagemath package is not installed.
fix
Run 'pip install passagemath-planarity' which pulls in the passagemath base package.
error UserWarning: The planarity module is experimental. API may change.
cause The library might emit a warning on import; it is still usable.
fix
Suppress warnings if needed with 'import warnings; warnings.filterwarnings("ignore", message=".*experimental.*")'.
gotcha The library is part of the passagemath ecosystem. Do not import 'planarity' directly; always use 'from passagemath.planarity import planarity'.
fix Use the correct import path: from passagemath.planarity import planarity
deprecated Some older examples use 'passagemath.planarity.planarity' (duplicated module name). This still works but is redundant; the canonical import is 'from passagemath.planarity import planarity'.
fix Use the recommended import: from passagemath.planarity import planarity
gotcha Requires Python >=3.11, <3.15. Installing on Python 3.15+ will fail.
fix Use a Python version from 3.11 to 3.14.

Quick example showing planarity test and planar embedding extraction.

from passagemath.planarity import planarity
# Test planarity of a graph given as adjacency list
# Graph: triangle with an extra isolated vertex
adj = {0: [1,2], 1: [0,2], 2: [0,1], 3: []}
result = planarity.is_planar(adj)
print(result)  # True
# Get a planar embedding
try:
    embedding = planarity.planar_embedding(adj)
    print(embedding)
except Exception as e:
    print(e)