pub fn neighborhood_graphs(
graph: &Graph,
order: i32,
) -> IgraphResult<Vec<Graph>>Expand description
Per-vertex induced subgraphs of k-hop neighbourhoods (mode = All, mindist = 0).
For each vertex v, computes its order-hop neighbourhood (the set
of vertices within distance order of v, including v itself) and
returns the induced subgraph on that vertex set. The result is a
Vec<Graph> of length graph.vcount().
Counterpart of igraph_neighborhood_graphs(graph, _, igraph_vss_all(), order, IGRAPH_ALL, /*mindist=*/0).
§Errors
IgraphError::InvalidArgumentiforder >= 0and internal constraints are violated (same asneighborhood_with_mode).
§Examples
use rust_igraph::{Graph, neighborhood_graphs};
// Path graph: 0 - 1 - 2 - 3
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
let gs = neighborhood_graphs(&g, 1).unwrap();
assert_eq!(gs.len(), 4);
// Vertex 0's 1-hop neighborhood: {0, 1}, induced subgraph has 1 edge
assert_eq!(gs[0].vcount(), 2);
assert_eq!(gs[0].ecount(), 1);
// Vertex 1's 1-hop neighborhood: {0, 1, 2}, induced subgraph has 2 edges
assert_eq!(gs[1].vcount(), 3);
assert_eq!(gs[1].ecount(), 2);