pub fn node_homophily(graph: &Graph, labels: &[u32]) -> IgraphResult<f64>Expand description
Node homophily ratio: average proportion of same-label neighbors.
h_node = (1/|V|) Σ_v |{u ∈ N(v) : y_u = y_v}| / |N(v)|
Isolated vertices (degree 0) are excluded from the average. Range: [0, 1]. This per-node definition better captures local structure than the edge-level metric.
§Examples
use rust_igraph::{Graph, node_homophily};
// Path 0-1-2 with labels [0, 0, 1]:
// Node 0: 1 neighbor (1, same label) → 1.0
// Node 1: 2 neighbors (0=same, 2=diff) → 0.5
// Node 2: 1 neighbor (1, diff label) → 0.0
// Average = (1.0 + 0.5 + 0.0) / 3 = 0.5
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
let h = node_homophily(&g, &[0, 0, 1]).unwrap();
assert!((h - 0.5).abs() < 1e-10);