pub fn global_efficiency(graph: &Graph) -> IgraphResult<Option<f64>>Expand description
Global efficiency of graph — average inverse pairwise shortest
distance over all N*(N-1) ordered vertex pairs. Pairs that are
unreachable contribute 0.
Returns None when vcount() < 2 (no pairs).
For undirected graphs each unordered pair contributes twice (once
per direction); the divisor N*(N-1) mirrors that, so the formula
is the standard Latora–Marchiori definition.
Counterpart of
igraph_global_efficiency(_, NULL_weights, _, /*directed=*/true).
§Examples
use rust_igraph::{Graph, global_efficiency};
// K3: every ordered pair is at distance 1 → mean inverse distance = 1.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
assert_eq!(global_efficiency(&g).unwrap(), Some(1.0));
// Path 0-1-2-3: 12 ordered pairs. d=1 ×6 → 6; d=2 ×4 → 2; d=3 ×2 → 2/3.
// Sum = 26/3; /12 = 13/18.
let mut g = Graph::with_vertices(4);
for i in 0..3u32 { g.add_edge(i, i + 1).unwrap(); }
let e = global_efficiency(&g).unwrap().unwrap();
assert!((e - 13.0 / 18.0).abs() < 1e-12);