Registry / data / planarity

planarity

JSON →
library0.6pypypi✓ verified 83d ago

Planarity is a Python package for testing and manipulating the planarity of undirected graphs. It wraps the Boyer-Myrvold planarity algorithm (C library) and provides functions like is_planar, kuratowski_subgraph, and planar_embedding. The current version is 0.6, released with Cython 3 support, but the library is in maintenance mode with infrequent updates.

pip install planarity
INSTALL
IMPORT
SIG · PLANARITY
P
planarity
datapythonv0.6
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

planarity
import planarity
The top-level module is named 'planarity'. No subpackage import.

Simple test of planarity for the non-planar graph K5.

import planarity def test_planarity(): # Example: complete graph K5 is non-planar edges = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)] # Check planarity result = planarity.is_planar(edges) print('Is K5 planar?', result) # False test_planarity()
Debug
Known issues
breakingIn version 0.4, inputs with parallel edges are silently dropped with a warning. This can cause incorrect results or confusion. Always deduplicate edges before calling planarity functions.
fix
Remove parallel edges using set operations: edges = list(set((min(u,v), max(u,v)) for u,v in edges))
affects: >=0.4
brokenThe library uses Cython and requires compilation. On some platforms (e.g., Windows without a C compiler), installation may fail with a 'Unable to find vcvarsall.bat' error.
fix
Install from a precompiled wheel if available, or use conda; alternatively, use the Cython source and ensure a C compiler is properly configured.
affects: all
gotchaThe function kuratowski_subgraph() may raise a KeyError if the graph is planar. It is designed to be called only for non-planar graphs, but the documentation is unclear. Always check is_planar first.
fix
if not planarity.is_planar(edges): sub = planarity.kuratowski_subgraph(edges)
affects: all
Errors
Common errors & fixes
ImportError: No module named 'planarity'
The package is not installed or the Python environment is incorrect.
fix
Run 'pip install planarity' in the correct environment.
FileNotFoundError: [Errno 2] No such file or directory: 'planarity.c'
The Cython-generated C file is missing from the source distribution (common with older pip or setuptools).
fix
Install with '--no-cache-dir' or upgrade pip: 'pip install --upgrade pip && pip install planarity'
KeyError: 0
The planarity library expects integer vertices starting from 0. Non-consecutive or non-integer vertices (like strings) may cause this error.
fix
Remap vertices to consecutive integers starting at 0 before calling planarity functions.
Upgrade
Version history
0.6latest on PyPI · released Jul 6, 2024
Audit
Dependencies
cythonrequiredRequired to compile the included Cython source (planarity.pyx). Planarity 0.4.1+ requires cython for build.
Agent activity
10 hits · last 30 days
node
10
Resources
planarity — pip install planarity · libregistry