Skip to main content

degree_isolated_ratio

Function degree_isolated_ratio 

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

Compute the isolated ratio (fraction of degree-0 vertices).

Returns the fraction of vertices with degree 0. Returns 0.0 for empty graphs. Returns 1.0 for edgeless non-empty graphs.

§Examples

use rust_igraph::{Graph, degree_isolated_ratio};

// 3 isolated + 2 connected → 3/5 = 0.6
let mut g = Graph::with_vertices(5);
g.add_edge(3, 4).unwrap();
assert!((degree_isolated_ratio(&g).unwrap() - 0.6).abs() < 1e-10);