Skip to main content

clustering_entropy

Function clustering_entropy 

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

Normalised Shannon entropy of the clustering coefficient distribution.

Bins the local clustering coefficients into 10 equal-width bins on [0, 1] and computes the Shannon entropy of the resulting histogram, normalised by ln(num_non_empty_bins) so the result is in [0, 1].

Returns 0.0 if fewer than 2 vertices have defined clustering coefficients or if all values fall in a single bin.

§Examples

use rust_igraph::{Graph, clustering_entropy};

// K4: all CC = 1.0, single bin → entropy = 0
let g = Graph::from_edges(
    &[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)],
    false,
    Some(4),
)
.unwrap();
assert!(clustering_entropy(&g).unwrap().abs() < 1e-10);