networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
katz_centrality_numpy(G, alpha=0.1, beta=1.0, normalized=True, weight=None)

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

$$x_i = \alpha \sum_{j} A_{ij} x_j + \beta,$$

where $A$ is the adjacency matrix of graph G with eigenvalues $\lambda$.

The parameter $\beta$ controls the initial centrality and

$$\alpha < \frac{1}{\lambda_{\max}}.$$

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 $\beta$. Connections made with distant neighbors are, however, penalized by an attenuation factor $\alpha$ 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 .

Notes

Katz centrality was introduced by .

This algorithm uses a direct linear solver to solve the above equation. The parameter alpha should be strictly less than the inverse of largest eigenvalue of the adjacency matrix for there to be a solution. You can use max(nx.adjacency_spectrum(G)) to get $\lambda_{\max}$ the largest eigenvalue of the adjacency matrix.

When $\alpha = 1/\lambda_{\max}$ and $\beta=0$, Katz centrality is the same as eigenvector centrality.

For directed graphs this finds "left" eigenvectors which corresponds to the in-edges in the graph. For out-edges Katz centrality first reverse the graph with G.reverse() .

Parameters

G : graph

A NetworkX graph

alpha : float

Attenuation factor

beta : scalar or dictionary, optional (default=1.0)

Weight attributed to the immediate neighborhood. If not a scalar the dictionary must have an value for every node.

normalized : bool

If True normalize the resulting values.

weight : None or string, optional

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.

Raises

NetworkXError

If the parameter :None:None:`beta` is not a scalar but lacks a value for at least one node

Returns

nodes : dictionary

Dictionary of nodes with Katz centrality as the value.

Compute the Katz centrality for the graph G.

See Also

eigenvector_centrality
eigenvector_centrality_numpy
hits
katz_centrality
pagerank

Examples

>>> import math
... G = nx.path_graph(4)
... phi = (1 + math.sqrt(5)) / 2.0 # largest eigenvalue of adj matrix
... centrality = nx.katz_centrality_numpy(G, 1 / phi)
... for n, c in sorted(centrality.items()):
...  print(f"{n} {c:.2f}") 0 0.37 1 0.60 2 0.60 3 0.37
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.centrality.katz.katz_centrality networkx.algorithms.centrality.katz.katz_centrality_numpy

Local connectivity graph

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


GitHub : /networkx/algorithms/centrality/katz.py#196
type: <class 'function'>
Commit: