pub fn heat_kernel_diffuse(
graph: &Graph,
signal: &[f64],
t: f64,
max_terms: usize,
) -> IgraphResult<Vec<f64>>Expand description
Diffuse a signal on the graph using the heat kernel.
Approximates exp(-t·L)·signal where L = I - D⁻¹A is the random-walk
normalized Laplacian. Uses a truncated Taylor expansion:
exp(-t·L) ≈ Σ_{k=0}^{K} (-t)^k / k! · L^k
Equivalently this iterates: s_{k+1} = D⁻¹A · s_k and accumulates
the weighted sum Σ (t^k · e^{-t} / k!) · s_k (Poisson weights).
§Parameters
graph— Undirected graph.signal— Input signal of lengthvcount.t— Diffusion time (heat parameter, t > 0). Larger = more smoothing.max_terms— Maximum number of Taylor terms (default: 20).
§Returns
The diffused signal as Vec<f64> of length vcount.
§Examples
use rust_igraph::{Graph, heat_kernel_diffuse};
// Path graph: signal on first vertex spreads to neighbors
let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
let signal = vec![1.0, 0.0, 0.0, 0.0];
let diffused = heat_kernel_diffuse(&g, &signal, 1.0, 20).unwrap();
// Signal should have spread: vertex 0 < 1.0, vertex 1 > 0.0
assert!(diffused[0] < 1.0);
assert!(diffused[1] > 0.0);
// Total signal is approximately preserved (heat kernel is doubly stochastic
// on regular graphs, approximately preserved on irregular ones)