pub fn smoothness_ratio(
graph: &Graph,
signal: &[f64],
weights: Option<&[f64]>,
) -> IgraphResult<f64>Expand description
Compute the smoothness ratio of a signal on a graph.
SR = 1 - E_D / (2 · Σ_{(u,v)} w · (f(u)² + f(v)²))
Bounded in [0, 1] for non-negative weights. A value of 1 means the
signal is perfectly smooth (constant on each connected component);
a value of 0 means maximally rough.
Returns 1.0 if the denominator is zero (no edges or all-zero signal).
§Examples
use rust_igraph::{Graph, smoothness_ratio};
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
// Constant signal → perfectly smooth
let sr = smoothness_ratio(&g, &[2.0, 2.0, 2.0], None).unwrap();
assert!((sr - 1.0).abs() < 1e-10);