Skip to content

Commit

Permalink
Add Left-Right Planarity test. (#475)
Browse files Browse the repository at this point in the history
* Add Left-Right Planarity test.
This commit implements a new function `is_planar` that
checks if an undirected graph can be drawn in a plane without any edge
intersections. The planarity check algorithm is based on the
Left-Right Planarity Test.

Reference: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.217.9208

* fix clippy

* fix compiler error

* add generalized Petersen graph as test cases

* remove old release note

* Update release note import

* fix release note

* `or_insert` can be omitted.

* cargo fmt

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 29, 2022
1 parent ced0310 commit 5b50f3f
Show file tree
Hide file tree
Showing 9 changed files with 1,319 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ Other Algorithm Functions
rustworkx.core_number
rustworkx.graph_greedy_color
rustworkx.metric_closure
rustworkx.is_planar

.. _generator_funcs:

Expand Down
12 changes: 12 additions & 0 deletions releasenotes/notes/is-planar-58bb8604ae00f1a1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
features:
- |
Implements a new function :func:`~rustworkx.is_planar` that
checks whether an undirected :class:`~rustworkx.PyGraph` is planar.
.. jupyter-execute::
import rustworkx as rx
graph = rx.generators.mesh_graph(5)
print('Is K_5 graph planar?', rx.is_planar(graph))
1 change: 1 addition & 0 deletions rustworkx-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub mod centrality;
pub mod connectivity;
/// Module for maximum weight matching algorithms.
pub mod max_weight_matching;
pub mod planar;
pub mod shortest_path;
pub mod traversal;
// These modules define additional data structures
Expand Down
Loading

0 comments on commit 5b50f3f

Please sign in to comment.