Skip to main content

largest_component_fraction

Function largest_component_fraction 

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

Compute the largest component fraction.

max_component_size / n — how much of the graph is in the largest connected component. Equals 1.0 for connected graphs. Returns 0.0 for empty graphs.

§Examples

use rust_igraph::{Graph, largest_component_fraction};

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