Compute the Katz centrality for the nodes of the graph G.
Katz centrality is related to eigenvalue centrality and PageRank. The Katz centrality for node is
where is the adjacency matrix of the graph G with eigenvalues .
The parameter controls the initial centrality and
Katz centrality computes the relative influence of a node within a network by measuring the number of the immediate neighbors (first degree nodes) and also all other nodes in the network that connect to the node under consideration through these immediate neighbors.
Extra weight can be provided to immediate neighbors through the parameter . Connections made with distant neighbors are, however, penalized by an attenuation factor which should be strictly less than the inverse largest eigenvalue of the adjacency matrix in order for the Katz centrality to be computed correctly. More information is provided in [R175] .
Parameters : | G : graph
alpha : float
beta : scalar or dictionary, optional (default=1.0)
max_iter : integer, optional (default=1000)
tol : float, optional (default=1.0e-6)
nstart : dictionary, optional
normalized : bool, optional (default=True)
|
---|---|
Returns : | nodes : dictionary
|
See also
katz_centrality_numpy, eigenvector_centrality, eigenvector_centrality_numpy, pagerank, hits
Notes
This algorithm it uses the power method to find the eigenvector corresponding to the largest eigenvalue of the adjacency matrix of G. The constant alpha should be strictly less than the inverse of largest eigenvalue of the adjacency matrix for the algorithm to converge. The iteration will stop after max_iter iterations or an error tolerance of number_of_nodes(G)*tol has been reached.
When and Katz centrality is the same as eigenvector centrality.
References
[R175] | (1, 2) M. Newman, Networks: An Introduction. Oxford University Press, USA, 2010, p. 720. |
Examples
>>> import math
>>> G = nx.path_graph(4)
>>> phi = (1+math.sqrt(5))/2.0 # largest eigenvalue of adj matrix
>>> centrality = nx.katz_centrality(G,1/phi-0.01)
>>> for n,c in sorted(centrality.items()):
... print("%d %0.2f"%(n,c))
0 0.37
1 0.60
2 0.60
3 0.37