Heat diffusion on graphs — exact spectral solution via Jacobi eigendecomposition, zero external dependencies.
Simulates the discrete heat equation ∂u/∂t = -L·u on arbitrary graph structures. Uses exact eigendecomposition (Jacobi rotation) for time-stepping: project onto eigenvectors, multiply by exp(-λᵢ·dt), reconstruct. No iterative solvers, no approximation.
- Exact heat diffusion — no numerical drift, energy preserved by construction
- Jacobi eigendecomposition — all eigenvalues and eigenvectors computed from scratch
- Multiple initial conditions — single-node heat pulse, arbitrary temperature patterns
- Conservation tracking — total heat is conserved across diffusion steps
- Graph spectrum visualization — eigenvalue decay reveals graph connectivity
- Zero dependencies — pure Rust, no linear algebra crates
use heat_spectral::HeatState;
// Build adjacency matrix for a 10-node path graph
let adj = path_graph(10);
let mut sim = HeatState::new(&adj);
sim.set_heat(0, 1.0); // heat pulse at node 0
for _ in 0..100 {
sim.step(0.1); // exact step: eigenvector projection × exp(-λ·dt)
}cargo run # demo: heat diffusion on path, cycle, and complete graphs- Build the graph Laplacian L = D - A from adjacency matrix
- Compute all eigenvalues and eigenvectors via Jacobi rotation
- For each time step: project temperature onto eigenvectors, multiply by exp(-λᵢ·dt), reconstruct
The Jacobi method iteratively applies plane rotations to zero off-diagonal elements, converging to the eigenbasis. No external dependencies required.
cargo test
cargo run[dependencies]
heat-spectral = { git = "https://github.com/SuperInstance/heat-spectral" }Part of the SuperInstance ecosystem:
- heat-spectral — Parabolic PDE on graphs (this repo)
- wave-conservation — Hyperbolic PDE (waves) on graphs
- graph-neural — GNN spectral primitives
MIT