Skip to main content

periphery_fraction

Function periphery_fraction 

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

Compute the periphery fraction.

Fraction of vertices with coreness equal to 1 (the outermost shell). For trees all non-leaf vertices have coreness 1, so this can be high. Returns 0.0 for empty or edgeless graphs.

§Examples

use rust_igraph::{Graph, periphery_fraction};

// Star_5: center has coreness 1, leaves have coreness 1 → all are periphery
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(0,4)], false, Some(5)
).unwrap();
assert!((periphery_fraction(&g).unwrap() - 1.0).abs() < 1e-10);