Skip to content

Commit

Permalink
Merge pull request #4102 from rapidsai/branch-24.02
Browse files Browse the repository at this point in the history
Forward-merge branch-24.02 to branch-24.04
  • Loading branch information
GPUtester authored Jan 19, 2024
2 parents dd8cf64 + ec65907 commit 7d41573
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"complete_graph",
"complete_multipartite_graph",
"connected_components",
"core_number",
"cubical_graph",
"cycle_graph",
"davis_southern_women_graph",
Expand Down Expand Up @@ -127,6 +128,7 @@
"bfs_successors": "`sort_neighbors` parameter is not yet supported.",
"bfs_tree": "`sort_neighbors` parameter is not yet supported.",
"clustering": "Directed graphs and `weight` parameter are not yet supported.",
"core_number": "Directed graphs are not yet supported.",
"edge_betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.",
"eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.",
"from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.",
Expand Down
30 changes: 29 additions & 1 deletion python/nx-cugraph/nx_cugraph/algorithms/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,42 @@
import pylibcugraph as plc

import nx_cugraph as nxcg
from nx_cugraph.convert import _to_undirected_graph
from nx_cugraph.utils import (
_get_int_dtype,
index_dtype,
networkx_algorithm,
not_implemented_for,
)

__all__ = ["k_truss"]
__all__ = ["core_number", "k_truss"]


@not_implemented_for("directed")
@not_implemented_for("multigraph")
@networkx_algorithm(is_incomplete=True, plc="core_number", version_added="24.02")
def core_number(G):
"""Directed graphs are not yet supported."""
G = _to_undirected_graph(G)
if len(G) == 0:
return {}
if nxcg.number_of_selfloops(G) > 0:
raise nx.NetworkXNotImplemented(
"Input graph has self loops which is not permitted; "
"Consider using G.remove_edges_from(nx.selfloop_edges(G))."
)
node_ids, core_numbers = plc.core_number(
resource_handle=plc.ResourceHandle(),
graph=G._get_plc_graph(),
degree_type="bidirectional",
do_expensive_check=False,
)
return G._nodearrays_to_dict(node_ids, core_numbers)


@core_number._can_run
def _(G):
return not G.is_directed()


@not_implemented_for("directed")
Expand Down

0 comments on commit 7d41573

Please sign in to comment.