Skip to main content

normalized_dirichlet_energy

Function normalized_dirichlet_energy 

Source
pub fn normalized_dirichlet_energy(
    graph: &Graph,
    signal: &[f64],
    weights: Option<&[f64]>,
) -> IgraphResult<f64>
Expand description

Compute the normalized Dirichlet energy (Rayleigh quotient form).

E_norm = Σ_{(u,v)∈E} w(u,v)·(f(u)-f(v))² / Σ_v deg(v)·f(v)²

This equals the Rayleigh quotient f^T L f / f^T D f of the graph Laplacian, bounded in [0, 2] for undirected graphs. Values near 0 indicate smooth signals; values near 2 indicate maximally varying signals.

Returns 0.0 if the denominator is zero (all-zero signal or isolated vertices).

§Examples

use rust_igraph::{Graph, normalized_dirichlet_energy};

// Constant non-zero signal → 0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let e = normalized_dirichlet_energy(&g, &[3.0, 3.0, 3.0], None).unwrap();
assert!(e.abs() < 1e-10);