Skip to main content

is_p5_free

Function is_p5_free 

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

Check whether a graph is P_5-free (no induced path on 5 vertices).

An induced P_5 is 5 distinct vertices a-b-c-d-e forming a path with edges {a-b, b-c, c-d, d-e} and no other edges among them.

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_p5_free};

// `P_4` is `P_5`-free
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_p5_free(&g).unwrap());

// `P_5` is NOT `P_5`-free
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 4).unwrap();
assert!(!is_p5_free(&g).unwrap());