Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an error in the documentation of the katz centrality #6294

Merged
merged 2 commits into from Oct 31, 2023

Conversation

BrunoBaldissera
Copy link
Contributor

Issue #6279 reported a sentence in the documentation of the method stating

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

I replaced $\beta=0$ with $\beta=1$, according to the issue's suggestion (and fixed a small typo along the way).

@dschult
Copy link
Member

dschult commented Dec 23, 2022

There is another typo in a comment on line 172: It has the formula as "-" Beta when the code clearly uses "+".

Thanks for this!

@dschult dschult linked an issue Jan 6, 2023 that may be closed by this pull request
@Qudirah
Copy link
Contributor

Qudirah commented Mar 10, 2023

@BrunoBaldissera are you done with this issue?

@vigna
Copy link
Contributor

vigna commented Mar 14, 2023

For $\alpha = 1/\lambda_\mathrm{max}$ the summation does not converge. Convergence is possible only when $\alpha < 1/\lambda_\mathrm{max}$.

In the limit case, for $\alpha \to 1/\lambda_\mathrm{max}$ there is some theory that will tell you where Katz index is going, and in particular for strongly connected graphs (of at least for a semisimple $\lambda_\mathrm{max}$) it is the dominant eigenvector, but when the graph is not strongly connected there are many such vectors and the situation is a bit complicated. I know because I proved the result in full generality. What you get is the projection of the preference vector onto the eigenspace.

@dschult
Copy link
Member

dschult commented Mar 14, 2023

Excellent @vigna
Can you suggest some wording here relating it to the eigenvector centrality? Or is that difficult....

Maybe something like: For strongly connected graphs, as $\alpha \to 1/\lambda_\mathrm{max}$ and $beta=1$ this approaches the result for eigenvector centrality.

@vigna
Copy link
Contributor

vigna commented Mar 14, 2023

OK, I just read the definition and actually it's a bit weird but the original statement was correct. If $\beta=0$, this is not Katz centrality. It is eigenvector centrality, period. And it will have a solution only if $\alpha$ is the reciprocal of an eigenvalue. Simply, in the definition, it should be $\beta > 0$.

What is true is when $\beta > 0$ if you let $\alpha$ go to the limit value you will tend in the direction of the dominant eigenvector, or more generally in the direction of the projection of the preference vector onto the dominant eigenspace. (You'll need to renormalize tho as the vector norm will go to infinity).

BTW, $\beta$ can be different for every node, and the code allows that, so probably it would be better to have a definition matching the code, with a parameter $\beta_i$ instead of the same $\beta$ for all nodes.

Said that, I've always seen Katz centrality defined as $\beta \sum_{n\geq 0}A^nx^n$ (here $\beta$ is a vector but I can't bold it), and while this definition is equivalent, I don't think it is really idiomatic. The original formulation by Katz is in terms of an attenuated path summation (voters of voters of voters...). The linear recurrence in the paper is derived much later.

@vigna
Copy link
Contributor

vigna commented Mar 14, 2023

Excellent @vigna Can you suggest some wording here relating it to the eigenvector centrality? Or is that difficult....

Maybe something like: For strongly connected graphs, as α→1/λmax and beta=1 this approaches the result for eigenvector centrality.

Yes, this is correct for every $\beta\neq 0$. If you want a precise explanation for the non-strongly-connected case just put a reference to my paper, it is definitely not something you want to explain in general documentation...

@vigna
Copy link
Contributor

vigna commented Jun 22, 2023

Can this be merged?

@dschult
Copy link
Member

dschult commented Jun 23, 2023

It can be merged once it is clear what the good resolution of the issue is. Can you suggest some wording for the docs to make this all clear? The discussion above makes me believe that the change to the documentation should not be beta=1. But there's a lot of other information you added that is not included in the doc_string. If you can write out what you think this change ought to be then it would help move this PR closer to merging.

@vigna
Copy link
Contributor

vigna commented Jun 25, 2023

Oops. I didn't even realize this is not my branch. I guess I should fork from this branch or something like that?

@dschult
Copy link
Member

dschult commented Jun 26, 2023

You could load the branch by making a git "remote" to it, but you still couldn't push to it. You could make a PR to the PR-branch, but that still relies on the original author responding. Another approach would be to pull the branch from a git remote and then add some commits, push it to your fork of networkx and make a new PR. But maybe that's more than needed.

How complex are the changes you are thinking about? Can you make a suggestion in the comments?
I can make changes to the PR if you want to make a suggestion.

Copy link
Member

@dschult dschult left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for taking so long to get to this documentation change.
I think it is all ready to merge.

@jarrodmillman jarrodmillman merged commit 6ced50a into networkx:main Oct 31, 2023
35 checks passed
@jarrodmillman jarrodmillman added this to the 3.3 milestone Oct 31, 2023
cvanelteren pushed a commit to cvanelteren/networkx that referenced this pull request Apr 22, 2024
…6294)

* fixed a sentence in the documentation relating the parameter beta and the eigenvector centrality

* choose ev-cent docs wording, fix formula, remove comment

---------

Co-authored-by: Dan Schult <dschult@colgate.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Error in documentation of katz_centrality?
5 participants