Skip to main content

local_efficiency

Function local_efficiency 

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

Per-vertex local efficiency. For each vertex v, computes the average inverse distance between every ordered pair of distinct vertices in N(v) (the unique non-self neighbours of v), measured in the subgraph obtained by removing v โ€” paths must not pass through v. Pairs unreachable in G \ {v} contribute 0.

local_efficiency[v] = 0 whenever |N(v)| < 2. For directed graphs, N(v) is the set of OUT-neighbours and BFS follows OUT edges (mirrors the simple directed=true, mode=OUT slice we expose for distances and global_efficiency).

Counterpart of igraph_local_efficiency(_, NULL_weights, _, igraph_vss_all(), /*directed=*/true, /*mode=*/IGRAPH_OUT).

ยงExamples

use rust_igraph::{Graph, local_efficiency};

// K4: each vertex has 3 neighbours forming a K3, all at distance 1
// in G \ {v} โ†’ local efficiency = 1.0 at every vertex.
let mut g = Graph::with_vertices(4);
for i in 0..4u32 {
    for j in (i + 1)..4u32 { g.add_edge(i, j).unwrap(); }
}
assert_eq!(local_efficiency(&g).unwrap(), vec![1.0, 1.0, 1.0, 1.0]);