Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions benchmarks/cugraph/pytest-based/bench_algos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down Expand Up @@ -197,31 +197,31 @@ def dataset(request, rmm_config):
@pytest.fixture(scope="module")
def edgelist(request, dataset):
df = dataset.get_edgelist()
return df
yield df


@pytest.fixture(scope="module")
def graph(request, dataset):
G = dataset.get_graph()
return G
yield G


@pytest.fixture(scope="module")
def unweighted_graph(request, dataset):
G = dataset.get_graph(ignore_weights=True)
return G
yield G


@pytest.fixture(scope="module")
def directed_graph(request, dataset):
G = dataset.get_graph(create_using=cugraph.Graph(directed=True))
return G
yield G


@pytest.fixture(scope="module")
def transposed_graph(request, dataset):
G = dataset.get_graph(store_transposed=True)
return G
yield G


###############################################################################
Expand Down
1 change: 0 additions & 1 deletion conda/environments/all_cuda-129_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ dependencies:
- pytest-benchmark
- pytest-cov
- pytest-xdist
- python-louvain
- pytorch>=2.4.1
- raft-dask==26.6.*,>=0.0.0a0
- rapids-build-backend>=0.4.0,<0.5.0
Expand Down
1 change: 0 additions & 1 deletion conda/environments/all_cuda-129_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ dependencies:
- pytest-benchmark
- pytest-cov
- pytest-xdist
- python-louvain
- pytorch>=2.4.1
- raft-dask==26.6.*,>=0.0.0a0
- rapids-build-backend>=0.4.0,<0.5.0
Expand Down
1 change: 0 additions & 1 deletion conda/environments/all_cuda-131_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ dependencies:
- pytest-benchmark
- pytest-cov
- pytest-xdist
- python-louvain
- pytorch>=2.4.1
- raft-dask==26.6.*,>=0.0.0a0
- rapids-build-backend>=0.4.0,<0.5.0
Expand Down
1 change: 0 additions & 1 deletion conda/environments/all_cuda-131_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ dependencies:
- pytest-benchmark
- pytest-cov
- pytest-xdist
- python-louvain
- pytorch>=2.4.1
- raft-dask==26.6.*,>=0.0.0a0
- rapids-build-backend>=0.4.0,<0.5.0
Expand Down
1 change: 0 additions & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ dependencies:
- networkx>=2.5.1
- *numpy
- packaging
- python-louvain
- scikit-learn>=0.23.1
test_python_pylibcugraph:
common:
Expand Down

This file was deleted.

This file was deleted.

52 changes: 7 additions & 45 deletions python/cugraph/cugraph/tests/community/test_louvain.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
# SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0

import gc

import pytest
import networkx as nx

import cugraph
import cupyx
import cudf
from cugraph.testing import utils, UNDIRECTED_DATASETS
from cugraph.testing import UNDIRECTED_DATASETS
from cugraph.datasets import karate_asymmetric


try:
import community
Comment thread
rlratzel marked this conversation as resolved.
except ModuleNotFoundError:
pytest.exit(
"community module not found\n"
"The python-louvain module needs to be installed\n"
"please run `pip install python-louvain`"
)


print("Networkx version : {} ".format(nx.__version__))


# =============================================================================
# Pytest Setup / Teardown - called for each test function
# =============================================================================
Expand All @@ -42,40 +28,16 @@ def cugraph_call(graph_file, edgevals=False, directed=False):
return parts, mod


def networkx_call(M):
# z = {k: 1.0/M.shape[0] for k in range(M.shape[0])}
Gnx = nx.from_pandas_edgelist(
M, source="0", target="1", edge_attr="weight", create_using=nx.Graph()
)
parts = community.best_partition(Gnx)

return parts


# The goal is to just test that the code runs and returns a result.
# The C/C++ test perform a check for accuracy, but the python test
# is not designed to be a 1:1 comparison with the C/C++ test.
@pytest.mark.sg
@pytest.mark.parametrize("graph_file", UNDIRECTED_DATASETS)
def test_louvain(graph_file):
dataset_path = graph_file.get_path()
M = utils.read_csv_for_nx(dataset_path)
cu_parts, cu_mod = cugraph_call(graph_file, edgevals=True)
nx_parts = networkx_call(M)

# Calculating modularity scores for comparison
Gnx = nx.from_pandas_edgelist(
M, source="0", target="1", edge_attr="weight", create_using=nx.Graph()
)

cu_parts = cu_parts.to_pandas()
cu_map = dict(zip(cu_parts["vertex"], cu_parts["partition"]))

assert set(nx_parts.keys()) == set(cu_map.keys())

cu_mod_nx = community.modularity(cu_map, Gnx)
nx_mod = community.modularity(nx_parts, Gnx)

assert len(cu_parts) == len(nx_parts)
assert cu_mod > (0.82 * nx_mod)
assert abs(cu_mod - cu_mod_nx) < 0.0001
assert len(cu_parts) > 0
assert cu_mod > 0.0


@pytest.mark.sg
Expand Down
43 changes: 39 additions & 4 deletions python/cugraph/cugraph/tests/sampling/test_egonet_mg.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0

import gc

import pytest

import cudf
import cugraph
import dask_cudf
import cugraph.dask as dcg
from cugraph.testing import utils
from cugraph.dask.common.mg_utils import is_single_gpu
from pylibcugraph.testing import gen_fixture_params_product
from cudf.testing.testing import assert_frame_equal, assert_series_equal

from pylibcugraph import ego_graph as pylibcugraph_ego_graph
from pylibcugraph import ResourceHandle

# =============================================================================
# Pytest Setup / Teardown - called for each test function
Expand Down Expand Up @@ -70,13 +72,46 @@ def input_expected_output(input_combo):
input_data_path, directed=directed, edgevals=True
)

sg_cugraph_ego_graphs = cugraph.batched_ego_graphs(G, seeds=seeds, radius=radius)
if isinstance(seeds, (int, list)):
seeds = cudf.Series(seeds)
if isinstance(seeds, cudf.Series):
if G.renumbered is True:
seeds = G.lookup_internal_vertex_id(seeds)
elif isinstance(seeds, cudf.DataFrame):
if G.renumbered is True:
seeds = G.lookup_internal_vertex_id(seeds, seeds.columns)

# Match the seed to the vertex dtype
n_type = G.edgelist.edgelist_df["src"].dtype
n = seeds.astype(n_type)
do_expensive_check = False

source, destination, weight, offset = pylibcugraph_ego_graph(
resource_handle=ResourceHandle(),
graph=G._plc_graph,
source_vertices=n,
radius=radius,
do_expensive_check=do_expensive_check,
)
Comment thread
rlratzel marked this conversation as resolved.

df = cudf.DataFrame()
df["src"] = source
df["dst"] = destination
if weight is not None:
df["weight"] = weight

if G.renumbered:
df, _ = G.unrenumber(df, "src", get_column_names=True)
df, _ = G.unrenumber(df, "dst", get_column_names=True)

offset = cudf.Series(offset)
sg_cugraph_ego_graphs = (df, offset)

# Save the results back to the input_combo dictionary to prevent redundant
# cuGraph runs. Other tests using the input_combo fixture will look for
# them, and if not present they will have to re-run the same cuGraph call.

input_combo["sg_cugraph_results"] = sg_cugraph_ego_graphs

chunksize = dcg.get_chunksize(input_data_path)
ddf = dask_cudf.read_csv(
input_data_path,
Expand Down
Loading
Loading