pub fn is_planar(graph: &Graph) -> IgraphResult<bool>Expand description
Test whether a graph is planar.
Uses the Left-Right Planarity Test (Brandes 2009) which runs in O(V + E) time. Directed graphs are tested as if undirected. Self-loops and multi-edges are handled (self-loops are ignored; multi-edges contribute to the edge count for Euler’s criterion).
§Examples
use rust_igraph::{Graph, is_planar};
// K_4 is planar
let mut g = Graph::with_vertices(4);
for i in 0..4u32 {
for j in (i+1)..4 {
g.add_edge(i, j).unwrap();
}
}
assert!(is_planar(&g).unwrap());
// K_5 is NOT planar
let mut g = Graph::with_vertices(5);
for i in 0..5u32 {
for j in (i+1)..5 {
g.add_edge(i, j).unwrap();
}
}
assert!(!is_planar(&g).unwrap());