Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

# networkx.algorithms.centrality.eigenvector_centrality_numpy¶

eigenvector_centrality_numpy(G, weight=None, max_iter=50, tol=0)[source]

Compute the eigenvector centrality for the graph G.

Eigenvector centrality computes the centrality for a node based on the centrality of its neighbors. The eigenvector centrality for node $$i$$ is

$Ax = \lambda x$

where $$A$$ is the adjacency matrix of the graph G with eigenvalue $$\lambda$$. By virtue of the Perron–Frobenius theorem, there is a unique and positive solution if $$\lambda$$ is the largest eigenvalue associated with the eigenvector of the adjacency matrix $$A$$ ([2]).

Parameters
Ggraph

A networkx graph

weightNone or string, optional (default=None)

The name of the edge attribute used as weight. If None, all edge weights are considered equal. In this measure the weight is interpreted as the connection strength.

max_iterinteger, optional (default=100)

Maximum number of iterations in power method.

tolfloat, optional (default=1.0e-6)

Relative accuracy for eigenvalues (stopping criterion). The default value of 0 implies machine precision.

Returns
nodesdictionary

Dictionary of nodes with eigenvector centrality as the value.

Raises
NetworkXPointlessConcept

If the graph G is the null graph.

eigenvector_centrality
pagerank
hits

Notes

The measure was introduced by [1].

This algorithm uses the SciPy sparse eigenvalue solver (ARPACK) to find the largest eigenvalue/eigenvector pair.

For directed graphs this is “left” eigenvector centrality which corresponds to the in-edges in the graph. For out-edges eigenvector centrality first reverse the graph with G.reverse().

References

1

Phillip Bonacich: Power and Centrality: A Family of Measures. American Journal of Sociology 92(5):1170–1182, 1986 http://www.leonidzhukov.net/hse/2014/socialnetworks/papers/Bonacich-Centrality.pdf

2

Mark E. J. Newman: Networks: An Introduction. Oxford University Press, USA, 2010, pp. 169.

Examples

>>> G = nx.path_graph(4)
>>> centrality = nx.eigenvector_centrality_numpy(G)
>>> print([f"{node} {centrality[node]:0.2f}" for node in centrality])
['0 0.37', '1 0.60', '2 0.60', '3 0.37']