Skip to main content

edge_degree_entropy

Function edge_degree_entropy 

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

Shannon entropy of the edge degree-pair distribution.

Each edge (u, v) is classified by the ordered pair (min(deg(u), deg(v)), max(deg(u), deg(v))). This function computes the Shannon entropy (in nats) of the resulting distribution over all distinct degree-pair classes.

Returns 0.0 for graphs with no edges.

§Examples

use rust_igraph::{Graph, edge_degree_entropy};

// K3: all edges have degree pair (2,2) → single class → entropy = 0
let g = Graph::from_edges(&[(0, 1), (1, 2), (0, 2)], false, Some(3)).unwrap();
assert!(edge_degree_entropy(&g).unwrap().abs() < 1e-10);