Skip to main content

second_zagreb_entropy

Function second_zagreb_entropy 

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

Compute the second Zagreb entropy.

ENT_M2(G) = -Σ_e p_e·ln(p_e) where p_e = (du·dv)/M2(G).

Returns 0.0 for edgeless graphs.

§Examples

use rust_igraph::{Graph, second_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!((second_zagreb_entropy(&g).unwrap() - 3.0_f64.ln()).abs() < 1e-10);