Skip to main content

spectral_radius_ratio

Function spectral_radius_ratio 

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

Compute the spectral radius ratio.

λ₁ / sqrt(max_degree × (n-1)) — the spectral radius normalized by its theoretical upper bound (Cauchy-Schwarz). Values near 1 indicate the graph approaches the bound (e.g. stars); values near 0 indicate sparse, low-spectral-radius graphs. Returns 0.0 for trivial graphs.

§Examples

use rust_igraph::{Graph, spectral_radius_ratio};

// K_3: λ₁=2, max_deg=2, n=3 → 2/sqrt(2×2)=2/2=1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((spectral_radius_ratio(&g).unwrap() - 1.0).abs() < 0.05);