Skip to main content

is_claw_free

Function is_claw_free 

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

Check whether a graph is claw-free.

A claw-free graph has no induced K_{1,3}. This is checked by verifying that for every vertex, no three of its neighbors are mutually non-adjacent.

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_claw_free};

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

// Star `K_{1,3}` IS 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_claw_free(&g).unwrap());