Skip to main content

first_zagreb_entropy

Function first_zagreb_entropy 

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

Compute the first Zagreb entropy.

ENT_M1(G) = -Σ_e p_e·ln(p_e) where p_e = (du+dv)/M1(G).

Returns 0.0 for edgeless graphs.

§Examples

use rust_igraph::{Graph, first_zagreb_entropy};

// K_3: all weights equal (4,4,4) → ln(3)
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((first_zagreb_entropy(&g).unwrap() - 3.0_f64.ln()).abs() < 1e-10);