Skip to main content

giant_component_gap

Function giant_component_gap 

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

Compute the giant component gap.

(largest - second_largest) / n — the dominance of the largest component. Close to 1.0 means a single giant component dominates; close to 0 means two similarly-sized components exist. Returns 0.0 for graphs with fewer than 2 components or empty graphs.

§Examples

use rust_igraph::{Graph, giant_component_gap};

// K_3: single component → gap = (3 - 0) / 3 = 1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((giant_component_gap(&g).unwrap() - 1.0).abs() < 1e-10);