This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.


eigenvector_centrality(graph, weight_fn=None, default_weight=1.0, max_iter=100, tol=1e-06)[source]#

Compute the eigenvector centrality of a graph.

For details on the eigenvector centrality refer to:

Phillip Bonacich. “Power and Centrality: A Family of Measures.” American Journal of Sociology 92(5):1170–1182, 1986 <>

This function uses a power iteration method to compute the eigenvector and convergence is not guaranteed. The function will stop when max_iter iterations is reached or when the computed vector between two iterations is smaller than the error tolerance multiplied by the number of nodes. The implementation of this algorithm is based on the NetworkX eigenvector_centrality() function.

In the case of multigraphs the weights of any parallel edges will be summed when computing the eigenvector centrality.

  • graph – Graph to be used. Can either be a PyGraph or PyDiGraph.

  • weight_fn – An optional input callable that will be passed the edge’s payload object and is expected to return a float weight for that edge. If this is not specified default_weight will be used as the weight for every edge in graph

  • default_weight (float) – If weight_fn is not set the default weight value to use for the weight of all edges

  • max_iter (int) – The maximum number of iterations in the power method. If not specified a default value of 100 is used.

  • tol (float) – The error tolerance used when checking for convergence in the power method. If this is not specified default value of 1e-6 is used.


a read-only dict-like object whose keys are the node indices and values are the centrality score for that node.

Return type: