pub fn is_planar<G>(graph: G) -> boolwhere
G: GraphProp<EdgeType = Undirected> + NodeCount + EdgeCount + IntoEdges + IntoNodeIdentifiers + Visitable,
G::NodeId: Hash + Eq,
Expand description
Check if an undirected graph is planar.
A graph is planar iff it can be drawn in a plane without any edge intersections.
The planarity check algorithm is based on the Left-Right Planarity Test:
Ulrik Brandes: The Left-Right Planarity Test (2009)
ยงExample:
use rustworkx_core::petgraph::graph::UnGraph;
use rustworkx_core::planar::is_planar;
let grid = UnGraph::<(), ()>::from_edges(&[
// row edges
(0, 1), (1, 2), (3, 4), (4, 5), (6, 7), (7, 8),
// col edges
(0, 3), (3, 6), (1, 4), (4, 7), (2, 5), (5, 8),
]);
assert!(is_planar(&grid))