Skip to main content

edge_weight_balance

Function edge_weight_balance 

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

Normalised entropy of the edge degree-pair distribution.

This is edge_degree_entropy divided by ln(number_of_distinct_classes), yielding a value in [0, 1]. A value of 1 means edges are uniformly distributed across all degree-pair classes; 0 means all edges belong to a single class.

Returns 0.0 for graphs with fewer than 2 distinct degree-pair classes.

§Examples

use rust_igraph::{Graph, edge_weight_balance};

// Path 0-1-2: edges (0,1) has pair (1,2), edge (1,2) has pair (1,2)
// Single class → balance = 0
let g = Graph::from_edges(&[(0, 1), (1, 2)], false, Some(3)).unwrap();
assert!(edge_weight_balance(&g).unwrap().abs() < 1e-10);