Skip to main content

connectivity_index

Function connectivity_index 

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

Compute the connectivity index of the graph.

CI = (2m/n) / (n - 1)

Average degree divided by the maximum possible average degree (for a simple graph). Equals the graph density for simple undirected graphs. Returns 0.0 for graphs with fewer than 2 vertices.

ยงExamples

use rust_igraph::{Graph, connectivity_index};

// K_3: avg_deg=2, max_avg_deg=2, CI=1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((connectivity_index(&g).unwrap() - 1.0).abs() < 1e-10);