Skip to main content

is_cricket_free

Function is_cricket_free 

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

Check whether a graph is cricket-free.

The cricket is a triangle with two pendant edges from the same triangle vertex. A cricket-free graph has no induced cricket.

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_cricket_free};

// Triangle is cricket-free
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
assert!(is_cricket_free(&g).unwrap());

// Cricket: triangle {0,1,2}, pendants 1-3 and 1-4
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(1, 3).unwrap();
g.add_edge(1, 4).unwrap();
assert!(!is_cricket_free(&g).unwrap());