Skip to main content

is_paw_free

Function is_paw_free 

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

Check whether a graph is paw-free.

The paw is a triangle plus a pendant edge. A paw-free graph has no induced paw. Equivalently, every connected component is either triangle-free or complete.

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_paw_free};

// Triangle is paw-free (no pendant vertex)
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_paw_free(&g).unwrap());

// Triangle + pendant: paw!
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
g.add_edge(2, 3).unwrap();
assert!(!is_paw_free(&g).unwrap());