pub fn is_chordal(
graph: &Graph,
alpha: Option<&[u32]>,
) -> IgraphResult<ChordalResult>Expand description
Tests whether a graph is chordal.
A graph is chordal if every cycle of four or more nodes has a chord (an edge joining two non-adjacent nodes in the cycle). Equivalently, all chordless cycles have at most three nodes.
Uses the MCS ordering from maximum_cardinality_search and the
zero-fill-in test of Tarjan-Yannakakis 1984. Optionally computes
the fill-in edges needed to make the graph chordal (note: the
fill-in is not guaranteed to be minimal).
Edge directions are ignored. Self-loops and multi-edges are stripped internally.
§Arguments
graph— the input graph.alpha— optional pre-computed MCS ordering (alpha[v]= rank). IfNone, MCS is computed internally.
§Returns
A ChordalResult with chordal flag and fill_in edges.
§Complexity
O(|V| + |E|).
§Examples
use rust_igraph::{is_chordal, create};
// Triangle is chordal
let g = create(&[(0, 1), (1, 2), (2, 0)], 3, false).unwrap();
let r = is_chordal(&g, None).unwrap();
assert!(r.chordal);
assert!(r.fill_in.is_empty());
// 4-cycle is not chordal (needs one diagonal)
let g4 = create(&[(0, 1), (1, 2), (2, 3), (3, 0)], 4, false).unwrap();
let r4 = is_chordal(&g4, None).unwrap();
assert!(!r4.chordal);
assert!(!r4.fill_in.is_empty());