Skip to main content

is_bull_free

Function is_bull_free 

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

Check whether a graph is bull-free.

The bull graph is a triangle with two pendant edges from distinct triangle vertices. A bull-free graph has no induced bull.

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_bull_free};

// Triangle is bull-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_bull_free(&g).unwrap());

// Bull: triangle 0-1-2, pendants 1-3 and 2-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(2, 4).unwrap();
assert!(!is_bull_free(&g).unwrap());