eigenvector_centrality(G, max_iter=100, tol=1e-06, nstart=None, weight=None)
Eigenvector centrality computes the centrality for a node based on the centrality of its neighbors. The eigenvector centrality for node $i$ is the $i$-th element of the vector $x$ defined by the equation
$$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 solution $x$, all of whose entries are positive, if $\lambda$ is the largest eigenvalue of the adjacency matrix $A$ ().
The measure was introduced by and is discussed in .
The power iteration method is used to compute the eigenvector and convergence is not guaranteed. Our method stops after max_iter
iterations or when the change in the computed vector between two iterations is smaller than an error tolerance of G.number_of_nodes() * tol
. This implementation uses ($A + I$) rather than the adjacency matrix $A$ because it shifts the spectrum to enable discerning the correct eigenvector even for networks with multiple dominant eigenvalues.
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()
.
A networkx graph
Maximum number of iterations in power method.
Error tolerance used to check convergence in power method iteration.
Starting value of eigenvector iteration for each node.
If None, all edge weights are considered equal. Otherwise holds the name of the edge attribute used as weight. In this measure the weight is interpreted as the connection strength.
If the graph G
is the null graph.
If each value in :None:None:`nstart`
is zero.
If the algorithm fails to converge to the specified tolerance within the specified number of iterations of the power iteration method.
Dictionary of nodes with eigenvector centrality as the value.
Compute the eigenvector centrality for the graph G
.
>>> G = nx.path_graph(4)See :
... centrality = nx.eigenvector_centrality(G)
... sorted((v, f"{c:0.2f}") for v, c in centrality.items()) [(0, '0.37'), (1, '0.60'), (2, '0.60'), (3, '0.37')]
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.centrality.closeness.incremental_closeness_centrality
networkx.algorithms.centrality.eigenvector.eigenvector_centrality_numpy
networkx.algorithms.centrality.katz.katz_centrality
networkx.algorithms.centrality.harmonic.harmonic_centrality
networkx.algorithms.centrality.eigenvector.eigenvector_centrality
networkx.algorithms.centrality.closeness.closeness_centrality
networkx.algorithms.traversal.beamsearch.bfs_beam_edges
networkx.algorithms.centrality.katz.katz_centrality_numpy
networkx.algorithms.centrality.degree_alg.degree_centrality
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them