pub fn neighborhood_size(graph: &Graph, order: i32) -> IgraphResult<Vec<u32>>Expand description
k-hop neighbourhood size for every vertex (mode = All, mindist = 0).
For each vertex v returns the number of vertices within order
hops (inclusive), counting v itself. Negative order means
infinity (every reachable vertex is counted).
Counterpart of igraph_neighborhood_size(graph, _, igraph_vss_all(), order, IGRAPH_ALL, /*mindist=*/0).
§Errors
IgraphError::InvalidArgumentiforder >= 0butordercannot be represented as a non-negative integer (always satisfied fori32 >= 0, so this can only fail via the with-mode variant whenmindist > order).
§Examples
use rust_igraph::{Graph, neighborhood_size};
// Path P5: 0-1-2-3-4
let mut g = Graph::with_vertices(5);
for (u, v) in [(0, 1), (1, 2), (2, 3), (3, 4)] {
g.add_edge(u, v).unwrap();
}
// Order 1: self + immediate neighbours.
assert_eq!(neighborhood_size(&g, 1).unwrap(), vec![2, 3, 3, 3, 2]);
// Order 2: self + 2-hop ball.
assert_eq!(neighborhood_size(&g, 2).unwrap(), vec![3, 4, 5, 4, 3]);