Skip to main content

graph_center

Function graph_center 

Source
pub fn graph_center(graph: &Graph, mode: EccMode) -> IgraphResult<Vec<VertexId>>
Expand description

Return the central vertices of a graph — those with minimum eccentricity.

For directed graphs, mode controls which direction BFS follows. For undirected graphs, all modes are equivalent.

Returns an empty vector for an empty graph.

§Examples

use rust_igraph::{Graph, graph_center, EccMode};

// Path 0-1-2-3-4: center is vertex 2
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 4).unwrap();
let center = graph_center(&g, EccMode::All).unwrap();
assert_eq!(center, vec![2]);