Skip to main content

is_c5_free

Function is_c5_free 

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

Check whether a graph is C_5-free (no induced 5-cycle).

An induced C_5 is a set of 5 vertices forming a cycle with exactly 5 edges and no chords (diagonals).

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_c5_free};

// Triangle is `C_5`-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_c5_free(&g).unwrap());

// 5-cycle is NOT `C_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();
g.add_edge(4, 0).unwrap();
assert!(!is_c5_free(&g).unwrap());