Skip to main content

avg_neighbor_connectivity

Function avg_neighbor_connectivity 

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

Compute the average neighbor connectivity of the graph.

ANC = (1/n) Σ_v (Σ_{u∈N(v)} d(u)) / d(v)

For each vertex with degree > 0, the ratio of total neighbor degree to own degree, averaged over all such vertices. For regular graphs equals degree. Returns 0.0 for graphs with no edges.

§Examples

use rust_igraph::{Graph, avg_neighbor_connectivity};

// K_3: each vertex has 2 neighbors each with degree 2
// ratio = (2+2)/2 = 2.0 for each, mean = 2.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((avg_neighbor_connectivity(&g).unwrap() - 2.0).abs() < 1e-10);