pub fn vertex_connectivity(graph: &Graph, checks: bool) -> IgraphResult<i64>Expand description
Vertex connectivity (cohesion) of a graph.
Returns the minimum number of internal vertices that must be
removed to disconnect some pair of vertices in graph. Equal
to min_{s ≠ t} st_vertex_connectivity(s, t, VconnNei::NumberOfNodes).
Counterpart of igraph_vertex_connectivity
(references/igraph/src/flow/flow.c:2158) and its alias
igraph_cohesion (flow.c:2470).
§Arguments
graph— input graph (directed or undirected).checks— whentrue, run the cheap short-circuits described in the module docs before falling back to theO(V^2)pairwise loop. Recommended for any non-trivial graph; the helpers costO(V + E)and can replace the whole pairwise loop. Equivalent to igraph C’schecksargument.
§Returns
The vertex connectivity as i64. Returns:
0whenvcount() < 2, or the graph is disconnected (some pair is already separated).1when there is a vertex with degree1(undirected) ormin(in, out) = 1(directed).vcount - 1when the graph is complete.- Otherwise, the result of the pairwise FL-013 loop.
§Errors
Propagates errors from st_vertex_connectivity,
connected_components, strongly_connected_components, and
is_complete. In practice these arise only from arithmetic
overflow on very large graphs, which is unreachable here.
§Examples
use rust_igraph::{Graph, vertex_connectivity};
// Undirected ring on 5 vertices — vc = 2 (any single vertex
// removal leaves the rest connected).
let mut g = Graph::new(5, false).unwrap();
for (u, v) in [(0u32, 1u32), (1, 2), (2, 3), (3, 4), (4, 0)] {
g.add_edge(u, v).unwrap();
}
assert_eq!(vertex_connectivity(&g, true).unwrap(), 2);
// Undirected path on 5 vertices — vc = 1 (the two endpoints
// each have degree 1).
let mut p = Graph::new(5, false).unwrap();
for (u, v) in [(0u32, 1u32), (1, 2), (2, 3), (3, 4)] {
p.add_edge(u, v).unwrap();
}
assert_eq!(vertex_connectivity(&p, true).unwrap(), 1);