Skip to main content

eigenvector_centrality

Function eigenvector_centrality 

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

Eigenvector centrality scores normalized so max == 1.

Returns Vec<f64> of length vcount. Empty graph returns empty. Directed graphs return crate::IgraphError::Unsupported for now — directed eigenvector centrality requires careful eigenvector choice (in-edges vs out-edges) and ships later.

Counterpart of igraph_eigenvector_centrality(_, _, NULL_eval, /*directed=*/false, /*scale=*/true, NULL_weights, NULL_options).

§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);