Skip to content

Commit

Permalink
choose ev-cent docs wording, fix formula, remove comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dschult committed Oct 23, 2023
1 parent 9ce0b8a commit 3122117
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions networkx/algorithms/centrality/katz.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ def katz_centrality(
The iteration will stop after ``max_iter`` iterations or an error tolerance of
``number_of_nodes(G) * tol`` has been reached.
When $\alpha = 1/\lambda_{\max}$ and $\beta=1$, Katz centrality is the same
as eigenvector centrality.
For strongly connected graphs, as $\alpha \to 1/\lambda_{\max}$, and $\beta > 0$,
Katz centrality approaches the results for eigenvector centrality.
For directed graphs this finds "left" eigenvectors which corresponds
to the in-edges in the graph. For out-edges Katz centrality
to the in-edges in the graph. For out-edges Katz centrality,
first reverse the graph with ``G.reverse()``.
References
Expand Down Expand Up @@ -183,7 +183,6 @@ def katz_centrality(
# normalize vector
try:
s = 1.0 / math.hypot(*x.values())
# this should never be zero?
except ZeroDivisionError:
s = 1.0
else:
Expand Down Expand Up @@ -289,11 +288,11 @@ def katz_centrality_numpy(G, alpha=0.1, beta=1.0, normalized=True, weight=None):
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 strongly connected graphs, as $\alpha \to 1/\lambda_{\max}$, and $\beta > 0$,
Katz centrality approaches the results for eigenvector centrality.
For directed graphs this finds "left" eigenvectors which corresponds
to the in-edges in the graph. For out-edges Katz centrality
to the in-edges in the graph. For out-edges Katz centrality,
first reverse the graph with ``G.reverse()``.
References
Expand Down

0 comments on commit 3122117

Please sign in to comment.