Skip to main content

graph_integrity

Function graph_integrity 

Source
pub fn graph_integrity(graph: &Graph) -> IgraphResult<f64>
Expand description

Compute the integrity of a graph.

I(G) = min_{S ⊂ V} (|S| + m(G-S))

where m(G-S) is the order (vertex count) of the largest connected component of G - S. Lower integrity means the graph is more vulnerable.

Brute-force — suitable for graphs with ≤ ~20 vertices.

§Examples

use rust_igraph::{Graph, graph_integrity};

// K_3: optimal is S=∅ → I = 0 + 3 = 3;
//       or S={0} → I = 1 + 2 = 3. Min = 3.
// Actually for S={0,1} → I = 2 + 1 = 3. Always 3 for K_3.
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let i = graph_integrity(&g).unwrap();
assert!((i - 3.0).abs() < 0.01);