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

nx-cugraph: add eigenvector_centrality, katz_centrality, hits, pagerank #3968

Merged
merged 23 commits into from
Nov 22, 2023

Conversation

eriknw
Copy link
Contributor

@eriknw eriknw commented Nov 1, 2023

Add eigenvector_centrality, katz_centrality, and hits. I may add pagerank next.

@eriknw eriknw requested a review from a team as a code owner November 1, 2023 03:11
@eriknw eriknw changed the title Add eigenvector_centrality and katz_centrality nx-cugraph: add eigenvector_centrality, katz_centrality, and hits Nov 1, 2023
@eriknw eriknw changed the title nx-cugraph: add eigenvector_centrality, katz_centrality, and hits nx-cugraph: add eigenvector_centrality, katz_centrality, hits, pagerank Nov 1, 2023
@eriknw
Copy link
Contributor Author

eriknw commented Nov 1, 2023

This is ready for review. There is nothing more I plan to add.

Comment on lines 66 to 67
if nstart is None
else cp.arange(N, dtype=index_dtype), # Why is this necessary?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find it strange that we need to provide node indices here (and 12 lines below). I think other places in PLC assume 0, 1, ..., N-1 if indices aren't given.

@eriknw
Copy link
Contributor Author

eriknw commented Nov 2, 2023

Idea: perhaps we could add dtype= keyword argument specific to the nx-cugraph backend for algorithms such as in this PR. Would users want this? There are performance and memory implications. Other backends with native data structures could have the same pattern.

Comment on lines 23 to 30
@networkx_algorithm(
extra_params={
'weight : string or None, optional (default="weight")': (
"The edge attribute to use as the edge weight."
)
}
)
def hits(G, max_iter=100, tol=1.0e-8, nstart=None, normalized=True, *, weight="weight"):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

XREF: networkx/networkx#7081

weight= argument may be added to networkx soon.

if max_iter <= 0:
if nx.__version__[:3] <= "3.2":
raise ValueError("`maxiter` must be a positive integer.")
raise nx.PowerIterationFailedConvergence(max_iter)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

XREF: this (and PowerIterationFailedConvergence below) presumes this gets merged: networkx/networkx#7084

@rlratzel rlratzel added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Nov 2, 2023
Comment on lines 71 to 76
key(
"test_eigenvector_centrality.py:TestEigenvectorCentrality.test_P3"
): "Power iteration failed (don't know why; networkx converges in 8 steps)",
key(
"test_hits.py:TestHITS.test_hits_not_convergent"
): "HITS doesn't raise after failing to converge after max_iter iterations",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rlratzel, I may not be able to test this PR with #3979 before my PTO. Hopefully, #3979 will allow us to delete these xfail cases. CI will guide you, and delete things here as necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to remove the eigenvector_centrality xfail, but we still need the hits xfail for NX versions <= 3.2.1 that don't have your NX update.

@BradReesWork BradReesWork added this to the 23.12 milestone Nov 15, 2023
@rlratzel
Copy link
Contributor

/merge

@rapids-bot rapids-bot bot merged commit f2df81d into rapidsai:branch-23.12 Nov 22, 2023
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants