The planarity repository provides the source code for the planarity Python package. The planarity package was originally developed to provide Python and NetworkX developers with a Python API to access planar graph testing, embedding, drawing, and forbidden subgraph isolation algorithms from the Edge Addition Planarity Suite (EAPS).
The planarity repository has now been transferred to the Github Graph Algorithms Organization. The planarity repository and Python package will soon be updated with more planarity-related algorithms from EAPS as well as its underlying graph library methods that enable developing a wide range of high-performance graph algorithms and applications.
In [1]: # Example of the complete graph of 5 nodes, K5
In [2]: # K5 is not planar
In [3]: import planarity
In [4]: edgelist = [('a', 'b'), ('a', 'c'), ('a', 'd'), ('a', 'e'),
...: ('b', 'c'),('b', 'd'),('b', 'e'),
...: ('c', 'd'), ('c', 'e'),
...: ('d', 'e')]
In [5]: print(planarity.is_planar(edgelist))
False
In [6]: # remove an edge to make the graph planar
In [7]: edgelist.remove(('a','b'))
In [8]: print(planarity.is_planar(edgelist))
True
In [9]: # make an ascii text drawing
In [10]: print(planarity.ascii(edgelist))----1---- | | | | | | -3--| | | |||| | -2--||| | | ||| ---4---|| | || ---5----
See here for more examples.
Planarity (the 'planarity' Python package; the software) is released under this BSD-3-Clause license.
Copyright (C) 2016-2026, Planarity Developers
Aric Hagberg aric.hagberg@gmail.com
Wanda B. K. Boyer wbkboyer@gmail.com
John M. Boyer john.boyer.phd@gmail.com
All rights reserved.
Planarity includes the Edge Addition Planarity Suite, which is
Copyright (c) 1997-2025, John M. Boyer.
The BSD-3-Clause license for the Edge Additional Planarity Suite
included in Planarity appears here.