Skip to main content

eigenvector_centrality

Function eigenvector_centrality 

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

Backward-compatible undirected, unweighted entry point.

Returns just the centrality vector (max-1 normalised). Directed graphs return IgraphError::Unsupported — use eigenvector_centrality_directed or eigenvector_centrality_full for the directed paths.

Counterpart of igraph_eigenvector_centrality(g, &v, NULL, IGRAPH_ALL, NULL, NULL).

§Examples

use rust_igraph::{Graph, eigenvector_centrality};

// Triangle: every vertex has identical centrality 1.0.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
let ec = eigenvector_centrality(&g).unwrap();
assert!((ec[0] - 1.0).abs() < 1e-9);
assert!((ec[1] - 1.0).abs() < 1e-9);
assert!((ec[2] - 1.0).abs() < 1e-9);