{"id":24242,"library":"planarity","title":"Planarity - Graph Planarity Tools","description":"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.","status":"maintenance","version":"0.6","language":"python","source_language":"en","source_url":"https://github.com/hagberg/planarity/","tags":["planarity","graph-theory","networkx","planar-graph","cython"],"install":[{"cmd":"pip install planarity","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required to compile the included Cython source (planarity.pyx). Planarity 0.4.1+ requires cython for build.","package":"cython","optional":false}],"imports":[{"note":"The top-level module is named 'planarity'. No subpackage import.","wrong":"","symbol":"planarity","correct":"import planarity"}],"quickstart":{"code":"import planarity\n\ndef test_planarity():\n    # Example: complete graph K5 is non-planar\n    edges = [(0, 1), (0, 2), (0, 3), (0, 4),\n             (1, 2), (1, 3), (1, 4),\n             (2, 3), (2, 4),\n             (3, 4)]\n    # Check planarity\n    result = planarity.is_planar(edges)\n    print('Is K5 planar?', result)  # False\n\ntest_planarity()","lang":"python","description":"Simple test of planarity for the non-planar graph K5."},"warnings":[{"fix":"Remove parallel edges using set operations: edges = list(set((min(u,v), max(u,v)) for u,v in edges))","message":"In 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.","severity":"breaking","affected_versions":">=0.4"},{"fix":"Install from a precompiled wheel if available, or use conda; alternatively, use the Cython source and ensure a C compiler is properly configured.","message":"The 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.","severity":"broken","affected_versions":"all"},{"fix":"if not planarity.is_planar(edges): sub = planarity.kuratowski_subgraph(edges)","message":"The 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install planarity' in the correct environment.","cause":"The package is not installed or the Python environment is incorrect.","error":"ImportError: No module named 'planarity'"},{"fix":"Install with '--no-cache-dir' or upgrade pip: 'pip install --upgrade pip && pip install planarity'","cause":"The Cython-generated C file is missing from the source distribution (common with older pip or setuptools).","error":"FileNotFoundError: [Errno 2] No such file or directory: 'planarity.c'"},{"fix":"Remap vertices to consecutive integers starting at 0 before calling planarity functions.","cause":"The planarity library expects integer vertices starting from 0. Non-consecutive or non-integer vertices (like strings) may cause this error.","error":"KeyError: 0"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}