Skip to main content

is_ptolemaic

Function is_ptolemaic 

Source
pub fn is_ptolemaic(graph: &Graph) -> IgraphResult<bool>
Expand description

Check whether a graph is ptolemaic.

A ptolemaic graph is both chordal and distance-hereditary.

Returns false for directed graphs.

An empty graph (0 vertices) is ptolemaic (vacuously). A single vertex is ptolemaic. Any tree is ptolemaic. Any complete graph is ptolemaic. Any block graph is ptolemaic.

ยงExamples

use rust_igraph::{Graph, is_ptolemaic};

// Tree: ptolemaic
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
assert!(is_ptolemaic(&g).unwrap());

// C4 is NOT ptolemaic (not chordal)
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 0).unwrap();
assert!(!is_ptolemaic(&g).unwrap());