Skip to main content

graph_energy

Function graph_energy 

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

Compute the graph energy.

E(G) = Σ_i |λ_i| — the sum of absolute adjacency eigenvalues. Originates from Hückel molecular orbital theory.

§Examples

use rust_igraph::{Graph, graph_energy};

// K_3: eigenvalues {2, -1, -1} → energy = 2 + 1 + 1 = 4
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let e = graph_energy(&g).unwrap();
assert!((e - 4.0).abs() < 0.01);