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

The addition of DomiRank centrality to Networkx #7443

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mengsig
Copy link

@mengsig mengsig commented May 10, 2024

Hello all,

This contribution implements DomiRank centrality to networkx using scipy.sparse.csr_arrays, providing both an analytical and iterative solution (using Newton iteration). It would be great to have the addition of DomiRank as a centrality measure in networkx, as this has been requested to me a couple of times.

DomiRank centrality is a new metric that quantifies the dominance of nodes in their neighborhoods, where, the tunable competition parameter $\sigma$ provides a trade-off between the amount of local and global topological information considered. By setting $\sigma$ very large, you are finding the most 'dominant' nodes with respect to the entire system, and by setting $\sigma \to 0$, you are converging to degree centrality - i.e. only local information.

The paper that introduces domirank is hereunder:

Engsig, M., Tejedor, A., Moreno, Y. et al. DomiRank Centrality reveals structural fragility of complex networks via node dominance. Nat Commun 15, 56 (2024). https://doi.org/10.1038/s41467-023-44257-0

I would like to apologize in advance if I am not following the contribution standards 100%, this is my first time, and if there are additional things i need to do before this can be contributed, just let me know, and I will do it as soon as possible!

Also, there are some additional things to add - e.g. finding the optimal value of $\sigma$ for largest-connected-component deterioration with node removals. I already have this in DomiRank repository, however, lets start with just the non-automated DomiRank... first things first!

https://github.com/mengsig/DomiRank

Best,
Marcus

@Peiffap
Copy link

Peiffap commented Jun 8, 2024

This looks cool! I don't have the familiarity with the codebase required to judge whether this is an appropriate enhancement, but I wanted to say you should add from .domirank import * to the centrality __init__.py to fix (at least some of) the CI errors. It would also be nice to have some tests validating the algorithm.

Co-authored-by: Gilles Peiffer <gilles.peiffer@student.uclouvain.be>
@mengsig
Copy link
Author

mengsig commented Jun 8, 2024

Hello!

Thank you for your response! I will look into it and try to fix some of the CI errors. Thank you for your help. Perhaps, with this and your continued support, we can make this have 0 CI errors!

I saw your commit, and you are right, it was for path(5), good catch!

Best,

@Peiffap
Copy link

Peiffap commented Jun 8, 2024

we can make this have 0 CI errors!

Adding from .domirank import * to networkx/algorithms/centrality/__init__.py should do the trick. The error comes from your use of nx.domirank() in the example code (which is fine, but requires you to expose domirank() at the top level), which gets picked up on by running pytest with the --doctest-modules flag.
For some reason (@jarrodmillman?), all test jobs except the base job use this flag, hence why some of the CI tests pass (they aren't testing the docs) while the rest fails.

@mengsig
Copy link
Author

mengsig commented Jun 8, 2024

I have committed the suggested changes to the pull request. Lets see how it fares on the CI errors! Thanks again. This would really help my work, and it is also something that has been requested by numerous users / people. I can see it failed without scipy, which makes sense as I only have an implementaiton with Scipy. Is this an issue, as I can create a non-scipy dependent implementation as well?

I will also implement some test functions ASAP. I have a busy week but I will try and get it done!

Best,
Marcus

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.

None yet

3 participants