Skip to main content

is_net_free

Function is_net_free 

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

Check whether a graph is net-free (no induced net subgraph).

The net has 6 vertices: a triangle {a, b, c} plus pendants {d, e, f} where d-a, e-b, f-c are the pendant edges. The algorithm checks all 6-vertex subsets.

Directed graphs are treated as undirected.

ยงExamples

use rust_igraph::{Graph, is_net_free};

// Triangle: no induced net (too few vertices for net)
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_net_free(&g).unwrap());

// Net graph itself: NOT net-free
let mut g = Graph::with_vertices(6);
// Triangle 0-1-2
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
// Pendants
g.add_edge(0, 3).unwrap();
g.add_edge(1, 4).unwrap();
g.add_edge(2, 5).unwrap();
assert!(!is_net_free(&g).unwrap());