Skip to main content

is_proper_interval

Function is_proper_interval 

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

Check whether a graph is a proper interval graph.

A proper interval graph is chordal and claw-free. Equivalently, it can be represented by unit-length intervals on the real line.

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_proper_interval};

// Path `P_4` is a proper interval graph
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_proper_interval(&g).unwrap());

// Star `S_3` is NOT proper interval (has a claw)
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(0, 3).unwrap();
assert!(!is_proper_interval(&g).unwrap());