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

Use MNMG version of ECG in python layer instead, and remove legacy ECG and Louvain #4514

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/tests/lookup/lookup_src_dst_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,6 @@ INSTANTIATE_TEST_SUITE_P(
Tests_SGLookupEdgeSrcDst_Rmat,
::testing::Combine(
::testing::Values(EdgeSrcDstLookup_UseCase{false}),
::testing::Values(cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, false, false))));
::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, false, false))));

CUGRAPH_TEST_PROGRAM_MAIN()
2 changes: 1 addition & 1 deletion cpp/tests/lookup/mg_lookup_src_dst_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,6 @@ INSTANTIATE_TEST_SUITE_P(
Tests_MGLookupEdgeSrcDst_Rmat,
::testing::Combine(
::testing::Values(EdgeSrcDstLookup_UseCase{false}),
::testing::Values(cugraph::test::Rmat_Usecase(5, 32, 0.57, 0.19, 0.19, 0, true, false))));
::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, true, false))));

CUGRAPH_MG_TEST_PROGRAM_MAIN()
7 changes: 4 additions & 3 deletions notebooks/algorithms/community/Community-Clustering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"def compute_clusters(_graph) :\n",
"\n",
" # Compute ECG Clusters and normalize the column names\n",
" _e, _ = cugraph.ecg(_graph).rename(columns={'partition': 'cluster'})\n",
" _e, _ = cugraph.ecg(_graph)\n",
" _e = _e.rename(columns={'partition': 'cluster'})\n",
" \n",
" # Compute Louvain Clusters \n",
" _l, modularity = cugraph.louvain(_graph)\n",
Expand Down Expand Up @@ -354,7 +355,7 @@
"metadata": {},
"source": [
"___\n",
"Copyright (c) 2022, NVIDIA CORPORATION.\n",
"Copyright (c) 2022-2024, NVIDIA CORPORATION.\n",
"\n",
"Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n",
"\n",
Expand All @@ -379,7 +380,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.11.9"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
15 changes: 3 additions & 12 deletions notebooks/algorithms/community/ECG.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,7 @@
"outputs": [],
"source": [
"# Call ecg on the graph\n",
"df = cugraph.ecg(G) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.dtypes"
"df, _ = cugraph.ecg(G)"
]
},
{
Expand Down Expand Up @@ -215,7 +206,7 @@
"metadata": {},
"source": [
"___\n",
"Copyright (c) 2019-2023, NVIDIA CORPORATION.\n",
"Copyright (c) 2019-2024, NVIDIA CORPORATION.\n",
"\n",
"Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n",
"\n",
Expand All @@ -240,7 +231,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.11.9"
},
"vscode": {
"interpreter": {
Expand Down
48 changes: 24 additions & 24 deletions python/cugraph/cugraph/community/ecg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,13 @@
from pylibcugraph import ecg as pylibcugraph_ecg
from pylibcugraph import ResourceHandle

from cugraph.structure import Graph
import cudf
from typing import Union
from cugraph.utilities import (
ensure_cugraph_obj_for_nx,
df_score_to_dictionary,
)
from cugraph.utilities.utils import import_optional

# FIXME: the networkx.Graph type used in the type annotation for
# leiden() is specified using a string literal to avoid depending on
# and importing networkx. Instead, networkx is imported optionally, which may
# cause a problem for a type checker if run in an environment where networkx is
# not installed.
networkx = import_optional("networkx")
import warnings
from cugraph.utilities import ensure_cugraph_obj_for_nx, df_score_to_dictionary


def ecg(
input_graph: Union[Graph, "networkx.Graph"],
input_graph,
min_weight: float = 0.0001,
ensemble_size: int = 100,
max_level: int = 10,
Expand Down Expand Up @@ -91,6 +79,7 @@ def ecg(
defaults to a hash of process id, time, and hostname.

weight : str, optional (default=None)
Deprecated.
This parameter is here for NetworkX compatibility and
represents which NetworkX data column represents Edge weights.

Expand All @@ -100,9 +89,9 @@ def ecg(
GPU data frame of size V containing two columns, the vertex id and
the partition id it is assigned to.

df[vertex] : cudf.Series
parts[vertex] : cudf.Series
Contains the vertex identifiers
df[partition] : cudf.Series
parts[partition] : cudf.Series
Contains the partition assigned to the vertices

modularity_score : float
Expand All @@ -119,6 +108,19 @@ def ecg(

input_graph, isNx = ensure_cugraph_obj_for_nx(input_graph)

if isNx:
warning_msg = (
" We are deprecating support for handling "
"NetworkX types in the next release."
)
warnings.warn(warning_msg, UserWarning)
Comment on lines +111 to +116
Copy link
Contributor

Choose a reason for hiding this comment

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

This message doesn't hurt but isn't needed since ensure_cugraph_obj_for_nx() will handle the deprecation warning in this PR: https://github.com/rapidsai/cugraph/pull/4493/files#diff-62286c02304119d912dbd0491893a58c1dea11bd0addcc80fadb3d129d21029f


if weight is not None:
warning_msg = (
"This parameter is deprecated and will be removed in the next release."
)
warnings.warn(warning_msg, UserWarning)

vertex, partition, modularity_score = pylibcugraph_ecg(
resource_handle=ResourceHandle(),
random_state=random_state,
Expand All @@ -131,16 +133,14 @@ def ecg(
do_expensive_check=False,
)

df = cudf.DataFrame()
df["vertex"] = vertex
df["partition"] = partition
parts = cudf.DataFrame()
parts["vertex"] = vertex
parts["partition"] = partition

if input_graph.renumbered:
parts = input_graph.unrenumber(df, "vertex")
else:
parts = df
parts = input_graph.unrenumber(parts, "vertex")

if isNx is True:
parts = df_score_to_dictionary(df, "partition")
parts = df_score_to_dictionary(parts, "partition")

return parts, modularity_score
Loading