pub fn edge_homophily(graph: &Graph, labels: &[u32]) -> IgraphResult<f64>Expand description
Edge homophily ratio: fraction of edges connecting same-label vertices.
h_edge = |{(u,v) ∈ E : y_u = y_v}| / |E|
Range: [0, 1]. Higher values indicate stronger homophily. This is the simplest and most common homophily metric in GNN papers.
§Examples
use rust_igraph::{Graph, edge_homophily};
// Triangle with uniform labels: all edges connect same label
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let h = edge_homophily(&g, &[0, 0, 0]).unwrap();
assert!((h - 1.0).abs() < 1e-10);