Skip to main content

degree_palma

Function degree_palma 

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

Compute the Palma ratio of the degree sequence.

Ratio of total degree held by the top 10% of vertices to the total degree held by the bottom 40%, where vertices are ranked by degree in ascending order.

Returns f64::INFINITY if the bottom 40% hold zero degree. Returns 0.0 for the empty graph or graphs with fewer than 2 vertices (undefined).

§Examples

use rust_igraph::{Graph, degree_palma};

// K_3: all degrees equal → top 10% ≈ bottom 40% ratio → 1/n ratios
// With 3 vertices: bottom 40% = 1 vertex (d=2), top 10% = 0 vertices → 0/2 = 0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let p = degree_palma(&g).unwrap();
assert!(p.abs() < 1e-10); // top 10% of 3 = 0 vertices → 0