From beecde06538893d0b0ee4ac16455ac17b95f197b Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Wed, 12 Jul 2023 20:48:29 +0000 Subject: [PATCH 01/20] Use download_dir to store results files in datasets dir, instead of temp location in testing --- python/cugraph/cugraph/testing/__init__.py | 8 +- python/cugraph/cugraph/testing/resultset.py | 244 ++++++++ python/cugraph/cugraph/testing/utils.py | 68 +++ .../cugraph/tests/traversal/test_bfs.py | 123 ++--- .../cugraph/tests/traversal/test_bfs_old.py | 479 ++++++++++++++++ .../cugraph/tests/traversal/test_paths.py | 64 +-- .../cugraph/tests/traversal/test_paths_old.py | 208 +++++++ .../cugraph/tests/traversal/test_sssp.py | 129 +++-- .../cugraph/tests/traversal/test_sssp_old.py | 519 ++++++++++++++++++ 9 files changed, 1675 insertions(+), 167 deletions(-) create mode 100644 python/cugraph/cugraph/testing/resultset.py create mode 100644 python/cugraph/cugraph/tests/traversal/test_bfs_old.py create mode 100644 python/cugraph/cugraph/tests/traversal/test_paths_old.py create mode 100644 python/cugraph/cugraph/tests/traversal/test_sssp_old.py diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index db1c574de21..03785d0ee49 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -12,5 +12,11 @@ # limitations under the License. from cugraph.testing.utils import ( - RAPIDS_DATASET_ROOT_DIR_PATH, + RAPIDS_DATASET_ROOT_DIR_PATH, ResultSet ) + +from cugraph.testing.resultset import ( + get_bfs_results, + get_sssp_results, + get_paths_results, +) \ No newline at end of file diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py new file mode 100644 index 00000000000..1611fc730ea --- /dev/null +++ b/python/cugraph/cugraph/testing/resultset.py @@ -0,0 +1,244 @@ +# Copyright (c) 2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from tempfile import NamedTemporaryFile +import random +import os +from pathlib import Path + +# import json +import pickle + +# import pandas as pd +# import cupy as cp +import numpy as np + +import cudf +import networkx as nx +import cugraph +from cugraph.experimental.datasets import ( + dolphins, + netscience, + karate_disjoint, + karate, + polbooks, +) +from cugraph.testing import utils, ResultSet + +default_results_upload_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" + +# ============================================================================= +# Parameters +# ============================================================================= +# This will be refactored once the datasets variables are fixed/changed +SEEDS = [42] + +DIRECTED_GRAPH_OPTIONS = [True, False] + +DEPTH_LIMITS = [None, 1, 5, 18] + +DATASETS = [dolphins, netscience, karate_disjoint] + +DATASETS_SMALL = [karate, dolphins, polbooks] + + +# ============================================================================= +# tests/traversal/test_bfs.py +# ============================================================================= +test_bfs_results = {} +test_bfs_starts = {} + +for ds in DATASETS + [karate]: + for seed in SEEDS: + for depth_limit in DEPTH_LIMITS: + for dirctd in DIRECTED_GRAPH_OPTIONS: + # this does the work of get_cu_graph_nx_results_and_params + Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=dirctd) + + random.seed(seed) + start_vertex = random.sample(list(Gnx.nodes()), 1)[0] + nx_values = nx.single_source_shortest_path_length( + Gnx, start_vertex, cutoff=depth_limit + ) + + test_bfs_results[ + "{},{},{},{}".format(seed, depth_limit, ds, dirctd) + ] = nx_values + test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex + +for dirctd in DIRECTED_GRAPH_OPTIONS: + Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) + result = cugraph.bfs_edges(Gnx, source=7) + cugraph_df = cudf.from_pandas(result) + test_bfs_results[ + "{},{},{}".format(ds, dirctd, "nonnative-nx") + ] = cugraph_df + + +# ============================================================================= +# tests/traversal/test_sssp.py +# ============================================================================= +test_sssp_results = {} + +SOURCES = [1] + +for ds in DATASETS_SMALL: + for source in SOURCES: + Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) + nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths + + M = utils.read_csv_for_nx(ds.get_path(), read_weights_in_sp=True) + edge_attr = "weight" + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr=edge_attr, + create_using=nx.DiGraph(), + ) + + M["weight"] = M["weight"].astype(np.int32) + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr="weight", + create_using=nx.DiGraph(), + ) + test_sssp_results[ + "nx_paths,data_type_conversion,{}".format(ds) + ] = nx.single_source_dijkstra_path_length(Gnx, source) + +for dirctd in DIRECTED_GRAPH_OPTIONS: + for source in SOURCES: + Gnx = utils.generate_nx_graph_from_file( + karate.get_path(), directed=dirctd, edgevals=True + ) + if dirctd: + test_sssp_results[ + "nonnative_input,nx.DiGraph,{}".format(source) + ] = cugraph.sssp(Gnx, source) + else: + test_sssp_results[ + "nonnative_input,nx.Graph,{}".format(source) + ] = cugraph.sssp(Gnx, source) + + +G = nx.Graph() +G.add_edge(0, 1, other=10) +G.add_edge(1, 2, other=20) +df = cugraph.sssp(G, 0, edge_attr="other") +test_sssp_results["network_edge_attr"] = df + + +# ============================================================================= +# tests/traversal/test_paths.py +# ============================================================================= +CONNECTED_GRAPH = """1,5,3 +1,4,1 +1,2,1 +1,6,2 +1,7,2 +4,5,1 +2,3,1 +7,6,2 +""" + +DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" + +paths = [("1", "1"), ("1", "5"), ("1", "3"), ("1", "6")] +invalid_paths = { + "connected": [("-1", "1"), ("0", "42")], + "disconnected": [("1", "10"), ("1", "8")], +} + +test_paths_results = {} + +# CONNECTED_GRAPH +with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: + graph_tf.writelines(CONNECTED_GRAPH) + graph_tf.seek(0) + Gnx = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") + + graph_tf.writelines(DISCONNECTED_GRAPH) + graph_tf.seek(0) + Gnx_DIS = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") + +for path in paths: + nx_path_length = nx.shortest_path_length( + Gnx, path[0], target=path[1], weight="weight" + ) + cu_path_length = cugraph.shortest_path_length(Gnx, path[0], target=path[1]) + test_paths_results[ + "{},{},{},nx".format(path[0], path[1], "connected") + ] = nx_path_length + test_paths_results[ + "{},{},{},cu".format(path[0], path[1], "connected") + ] = cu_path_length + +# INVALID +for graph in ["connected", "disconnected"]: + if graph == "connected": + G = Gnx + else: + G = Gnx_DIS + paths = invalid_paths[graph] + for path in paths: + try: + test_paths_results[ + "{},{},{},invalid".format(path[0], path[1], graph) + ] = cugraph.shortest_path_length(G, path[0], path[1]) + except ValueError: + test_paths_results[ + "{},{},{},invalid".format(path[0], path[1], graph) + ] = "ValueError" + +# test_shortest_path_length_no_target +test_paths_results["1,notarget,nx"] = nx.shortest_path_length( + Gnx_DIS, source="1", weight="weight" +) +test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length( + Gnx_DIS, "1" +) + + +# serial_bfs_results = pickle.dumps(test_bfs_results) +# serial_sssp_results = pickle.dumps(test_sssp_results) +# serial_paths_results = pickle.dumps(test_paths_results) + +# pickle.dump(test_bfs_results, open("testing/bfs_results.pkl", "wb")) +# pickle.dump(test_sssp_results, open("testing/sssp_results.pkl", "wb")) +# pickle.dump(test_paths_results, open("testing/paths_results.pkl", "wb")) + +pickle.dump(test_bfs_results, open(default_results_upload_dir / "bfs_results.pkl", "wb")) +pickle.dump(test_sssp_results, open(default_results_upload_dir / "sssp_results.pkl", "wb")) +pickle.dump(test_paths_results, open(default_results_upload_dir / "paths_results.pkl", "wb")) + +# Example of how ResultSet is used in each individual testing script +# my_bfs_results = ResultSet(local_result_file="bfs_results.pkl") +# my_sssp_results = ResultSet(local_result_file="sssp_results.pkl") +# my_paths_results = ResultSet(local_result_file="paths_results.pkl") + + +# GETTERS (these are now unused and ready to be gone) +def get_bfs_results(test_params): + return test_bfs_results[test_params] + + +def get_sssp_results(test_params): + return test_sssp_results[test_params] + + +def get_paths_results(test_params): + return test_paths_results[test_params] diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index 0dae17ed14e..add4f56687a 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -12,6 +12,7 @@ # limitations under the License. import os +import pickle # Assume test environment has the following dependencies installed import pytest @@ -31,6 +32,7 @@ import cugraph from cugraph.dask.common.mg_utils import get_client +# from cugraph.experimental.datasets import default_download_dir CUPY_MATRIX_TYPES = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] @@ -412,3 +414,69 @@ def compare_mst(mst_cugraph, mst_nx): print(cg_sum) print(nx_sum) assert np.isclose(cg_sum, nx_sum) + + +"""def convert_nx_view_to_dict(Gnx): + Gnx_dict = {} + for u in Gnx.nodes: + Gnx_dict[u] = {} + for v in Gnx[u]: + Gnx_dict[u][v] = Gnx[u][v] + return Gnx_dict""" + +default_results_download_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" + +class ResultSet: + """ + A Resultset Object, which imports output data from networkX algs or cuGraph algs + with networkX inputs. This is to be used in the testing module, as to fully remove + nx as a dependency. + Parameters + ---------- + local_file_name : str + The string path for the pickled results file, stored locally somewhere. + cloud_file_name : str + The string path for the pickled results file, stored on the cloud. (s3) + """ + + # unsure about naming of 'cloud_result_file' + def __init__(self, local_result_file=None, cloud_result_file=None): + self._path = None + + # self._result_file = None + if cloud_result_file is not None and local_result_file is not None: + raise ValueError( + "only one of cloud_result_file or local_result_file can be specified" + ) + elif cloud_result_file is not None: + raise NotImplementedError("results files are not yet on cloud bucket") + # self._path=Path("https://data.rapids.ai/cugraph/tsting/"+cloud_result_file) + # not right syntax but the overall process would be similar to below: vv + elif local_result_file is not None: + self._path = default_results_download_dir / local_result_file + # breakpoint() + if self._path.exists() is False: + # try to load results, if file doesn't exist raise pref. RuntimeError + raise FileNotFoundError(local_result_file) + else: + with open(default_results_download_dir / local_result_file, "rb") as file: + self.results = pickle.load(file) + else: + raise ValueError( + "must specify either local_result_file or cloud_result_file" + ) + + +def load_all_results(force=False): + """ + Fetches all pickled results files from s3 bucket, stores them locally..somewhere + Parameters + force : Boolean (default=False) + Overwrite any existing copies of datafiles + """ + raise NotImplementedError("results files are not yet on cloud bucket") + + +# Example of intended behavior: +# bfs_results = ResultSet("bfs_results.pkl") +# bfs_results["1,nonnative-nx"] diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs.py b/python/cugraph/cugraph/tests/traversal/test_bfs.py index 7446b32ee5d..fa0333f7706 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs.py @@ -12,7 +12,7 @@ # limitations under the License. import gc -import random +# import random import pytest import pandas as pd @@ -28,21 +28,9 @@ from pylibcugraph.testing.utils import gen_fixture_params_product import cugraph -from cugraph.testing import utils +from cugraph.testing import utils, ResultSet from cugraph.experimental import datasets -# Temporarily suppress warnings till networkX fixes deprecation warnings -# (Using or importing the ABCs from 'collections' instead of from -# 'collections.abc' is deprecated, and in 3.8 it will stop working) for -# python 3.7. Also, this import networkx needs to be relocated in the -# third-party group once this gets fixed. -import warnings - -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - import networkx as nx - import networkx.algorithms.centrality.betweenness as nxacb - # ============================================================================= # Parameters @@ -59,8 +47,6 @@ # connected_components calls. cuGraph_input_output_map = { cugraph.Graph: cudf.DataFrame, - nx.Graph: pd.DataFrame, - nx.DiGraph: pd.DataFrame, cp_coo_matrix: tuple, cp_csr_matrix: tuple, cp_csc_matrix: tuple, @@ -70,6 +56,8 @@ } cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] +bfs_results = ResultSet(local_result_file="bfs_results.pkl") + # ============================================================================= # Pytest Setup / Teardown - called for each test function @@ -94,8 +82,8 @@ def convert_output_to_cudf(input_G_or_matrix, cugraph_result): if expected_return_type is cudf.DataFrame: return cugraph_result - elif expected_return_type is pd.DataFrame: - return cudf.from_pandas(cugraph_result) + # elif expected_return_type is pd.DataFrame: + # return cudf.from_pandas(cugraph_result) # A CuPy/SciPy input means the return value will be a 2-tuple of: # distance: cupy.ndarray @@ -155,7 +143,7 @@ def compare_single_sp_counter(result, expected, epsilon=DEFAULT_EPSILON): def compare_bfs(benchmark_callable, G, nx_values, start_vertex, depth_limit): """ - Genereate both cugraph and reference bfs traversal. + Generate both cugraph and reference bfs traversal. """ if isinstance(start_vertex, int): result = benchmark_callable(cugraph.bfs_edges, G, start_vertex) @@ -256,34 +244,32 @@ def _compare_bfs(cugraph_df, nx_distances, source): assert invalid_predecessor_error == 0, "There are invalid predecessors" -def get_cu_graph_nx_graph_and_params(dataset, directed): +def get_cu_graph_and_params(dataset, directed): """ - Helper for fixtures returning a Nx graph obj and params. + Helper for fixtures returning a cuGraph obj and params. """ # create graph G = dataset.get_graph(create_using=cugraph.Graph(directed=directed)) dataset_path = dataset.get_path() - - return ( - G, - dataset_path, - directed, - utils.generate_nx_graph_from_file(dataset_path, directed), - ) + dataset_name = dataset.metadata["name"] + return (G, dataset_path, dataset_name, directed) -def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, Gnx): +def get_cu_graph_nx_results_and_params( + seed, depth_limit, G, dataset_path, dataset_name, directed +): """ Helper for fixtures returning Nx results and params. """ - random.seed(seed) - start_vertex = random.sample(list(Gnx.nodes()), 1)[0] + # start_vertex = get_bfs_results("{},{},starts".format(seed, dataset_name)) + start_vertex = bfs_results.results["{},{},starts".format(seed, dataset_name)] - nx_values = nx.single_source_shortest_path_length( - Gnx, start_vertex, cutoff=depth_limit - ) + # nx_values = get_bfs_results( + # "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) + # ) + nx_values = bfs_results.results["{},{},{},{}".format(seed, depth_limit, dataset_name, directed)] - return (G, dataset, directed, nx_values, start_vertex, depth_limit) + return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) # ============================================================================= @@ -312,6 +298,7 @@ def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd") ) + # The single param list variants are used when only 1 param combination is # needed (eg. testing non-native input types where tests for other combinations # was covered elsewhere). @@ -328,18 +315,18 @@ def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, # combination. These return the path to the dataset, a bool indicating if a # directed graph is being used, and the Nx graph object. @pytest.fixture(scope="module", params=graph_fixture_params) -def dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) +def dataset_nx_results(request): + return get_cu_graph_and_params(*request.param) @pytest.fixture(scope="module", params=small_graph_fixture_params) -def small_dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) +def small_dataset_nx_results(request): + return get_cu_graph_and_params(*request.param) @pytest.fixture(scope="module", params=single_small_graph_fixture_params) -def single_small_dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) +def single_small_dataset_nx_results(request): + return get_cu_graph_and_params(*request.param) # Fixtures that result in a test-per (dataset_nx_graph combinations X algo_test @@ -348,21 +335,21 @@ def single_small_dataset_nx_graph(request): # results, the starting vertex for BFS, and flag if shortes path counting was # used. @pytest.fixture(scope="module", params=algo_test_fixture_params) -def dataset_nxresults_startvertex_spc(dataset_nx_graph, request): - return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_graph) +def dataset_nxresults_startvertex_spc(dataset_nx_results, request): + return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_results) @pytest.fixture(scope="module", params=single_algo_test_fixture_params) -def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_graph, request): +def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_results, request): return get_cu_graph_nx_results_and_params( - *request.param, *single_small_dataset_nx_graph + *request.param, *single_small_dataset_nx_results ) -@pytest.fixture(scope="module") -def dataset_nxresults_allstartvertices_spc(small_dataset_nx_graph): +"""@pytest.fixture(scope="module") +def dataset_nxresults_allstartvertices_spc(small_dataset_nx_results): - dataset, directed, Gnx = small_dataset_nx_graph + dataset, directed, Gnx = small_dataset_nx_results use_spc = True start_vertices = [start_vertex for start_vertex in Gnx] @@ -375,7 +362,7 @@ def dataset_nxresults_allstartvertices_spc(small_dataset_nx_graph): nx_values = nx_sp_counter all_nx_values.append(nx_values) - return (dataset, directed, all_nx_values, start_vertices, use_spc) + return (dataset, directed, all_nx_values, start_vertices, use_spc)""" # ============================================================================= @@ -396,15 +383,9 @@ def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type depth_limit, ) = dataset_nxresults_startvertex_spc - # special case: ensure cugraph and Nx Graph types are DiGraphs if - # "directed" is set, since the graph type parameterization is currently - # independent of the directed parameter. Unfortunately this does not - # change the "id" in the pytest output. Ignore for nonnative inputs if directed: if isinstance(cugraph_input_type, cugraph.Graph): cugraph_input_type = cugraph.Graph(directed=True) - elif cugraph_input_type is nx.Graph: - cugraph_input_type = nx.DiGraph if not isinstance(cugraph_input_type, cugraph.Graph): G_or_matrix = utils.create_obj_from_csv(dataset, cugraph_input_type) @@ -415,28 +396,38 @@ def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type @pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_bfs_nonnative_inputs( +@pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) +def test_bfs_nonnative_inputs_matrix( gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type ): test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) @pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs_invalid_start( - gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type +@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) +def test_bfs_nonnative_inputs_nx( + gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type ): ( - G, - dataset, + _, + _, directed, nx_values, start_vertex, - depth_limit, - ) = dataset_nxresults_startvertex_spc + _, + ) = single_dataset_nxresults_startvertex_spc + + cugraph_df = bfs_results.results["{},{},{}".format("karate", directed, "nonnative-nx")] + compare_func = _compare_bfs + compare_func(cugraph_df, nx_values, start_vertex) + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) +def test_bfs_invalid_start( + gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type +): + (G, _, _, _, start_vertex, depth_limit) = dataset_nxresults_startvertex_spc el = G.view_edge_list() diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_old.py b/python/cugraph/cugraph/tests/traversal/test_bfs_old.py new file mode 100644 index 00000000000..7446b32ee5d --- /dev/null +++ b/python/cugraph/cugraph/tests/traversal/test_bfs_old.py @@ -0,0 +1,479 @@ +# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +import random + +import pytest +import pandas as pd +import cupy as cp +import numpy as np +from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix +from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix +from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix +from scipy.sparse import coo_matrix as sp_coo_matrix +from scipy.sparse import csr_matrix as sp_csr_matrix +from scipy.sparse import csc_matrix as sp_csc_matrix +import cudf +from pylibcugraph.testing.utils import gen_fixture_params_product + +import cugraph +from cugraph.testing import utils +from cugraph.experimental import datasets + +# Temporarily suppress warnings till networkX fixes deprecation warnings +# (Using or importing the ABCs from 'collections' instead of from +# 'collections.abc' is deprecated, and in 3.8 it will stop working) for +# python 3.7. Also, this import networkx needs to be relocated in the +# third-party group once this gets fixed. +import warnings + +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + import networkx as nx + import networkx.algorithms.centrality.betweenness as nxacb + + +# ============================================================================= +# Parameters +# ============================================================================= +DIRECTED_GRAPH_OPTIONS = [True, False] + +SUBSET_SEED_OPTIONS = [42] + +DEFAULT_EPSILON = 1e-6 + +DEPTH_LIMITS = [None, 1, 5, 18] + +# Map of cuGraph input types to the expected output type for cuGraph +# connected_components calls. +cuGraph_input_output_map = { + cugraph.Graph: cudf.DataFrame, + nx.Graph: pd.DataFrame, + nx.DiGraph: pd.DataFrame, + cp_coo_matrix: tuple, + cp_csr_matrix: tuple, + cp_csc_matrix: tuple, + sp_coo_matrix: tuple, + sp_csr_matrix: tuple, + sp_csc_matrix: tuple, +} +cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] + + +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= +def setup_function(): + gc.collect() + + +# ============================================================================= +# Helper functions +# ============================================================================= +def convert_output_to_cudf(input_G_or_matrix, cugraph_result): + """ + Convert cugraph_result to a cudf DataFrame. The conversion is based on the + type of input_G_or_matrix, since different input types result in different + cugraph_result types (see cugraph_input_output_map). + """ + input_type = type(input_G_or_matrix) + expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] + assert type(cugraph_result) is expected_return_type + + if expected_return_type is cudf.DataFrame: + return cugraph_result + + elif expected_return_type is pd.DataFrame: + return cudf.from_pandas(cugraph_result) + + # A CuPy/SciPy input means the return value will be a 2-tuple of: + # distance: cupy.ndarray + # ndarray of shortest distances between source and vertex. + # predecessor: cupy.ndarray + # ndarray of predecessors of a vertex on the path from source, which + # can be used to reconstruct the shortest paths. + # or a 3-tuple of the above 2 plus + # sp_counter: cupy.ndarray + # for the i'th position in the array, the number of shortest paths + # leading to the vertex at position i in the (input) vertex array. + elif expected_return_type is tuple: + if input_type in cupy_types: + assert type(cugraph_result[0]) is cp.ndarray + assert type(cugraph_result[1]) is cp.ndarray + if len(cugraph_result) == 3: + assert type(cugraph_result[2]) is cp.ndarray + else: + assert type(cugraph_result[0]) is np.ndarray + assert type(cugraph_result[1]) is np.ndarray + if len(cugraph_result) == 3: + assert type(cugraph_result[2]) is np.ndarray + + # Get unique verts from input since they are not incuded in output + if type(input_G_or_matrix) in [ + cp_csr_matrix, + cp_csc_matrix, + sp_csr_matrix, + sp_csc_matrix, + ]: + coo = input_G_or_matrix.tocoo(copy=False) + else: + coo = input_G_or_matrix + verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) + dists = [n.item() for n in cugraph_result[0]] + preds = [n.item() for n in cugraph_result[1]] + assert len(verts) == len(dists) == len(preds) + + d = {"vertex": verts, "distance": dists, "predecessor": preds} + + if len(cugraph_result) == 3: + counters = [n.item() for n in cugraph_result[2]] + assert len(counters) == len(verts) + d.update({"sp_counter": counters}) + + return cudf.DataFrame(d) + + else: + raise RuntimeError(f"unsupported return type: {expected_return_type}") + + +# NOTE: We need to use relative error, the values of the shortest path +# counters can reach extremely high values 1e+80 and above +def compare_single_sp_counter(result, expected, epsilon=DEFAULT_EPSILON): + return np.isclose(result, expected, rtol=epsilon) + + +def compare_bfs(benchmark_callable, G, nx_values, start_vertex, depth_limit): + """ + Genereate both cugraph and reference bfs traversal. + """ + if isinstance(start_vertex, int): + result = benchmark_callable(cugraph.bfs_edges, G, start_vertex) + cugraph_df = convert_output_to_cudf(G, result) + compare_func = _compare_bfs + + # NOTE: We need to take 2 different path for verification as the nx + # functions used as reference return dictionaries that might + # not contain all the vertices while the cugraph version return + # a cudf.DataFrame with all the vertices, also some verification + # become slow with the data transfer + compare_func(cugraph_df, nx_values, start_vertex) + + elif isinstance(start_vertex, list): # For other Verifications + all_nx_values = nx_values + all_cugraph_distances = [] + + def func_to_benchmark(): + for sv in start_vertex: + cugraph_df = cugraph.bfs_edges(G, sv, depth_limit=depth_limit) + all_cugraph_distances.append(cugraph_df) + + benchmark_callable(func_to_benchmark) + + compare_func = _compare_bfs + for (i, sv) in enumerate(start_vertex): + cugraph_df = convert_output_to_cudf(G, all_cugraph_distances[i]) + + compare_func(cugraph_df, all_nx_values[i], sv) + + else: # Unknown type given to seed + raise NotImplementedError("Invalid type for start_vertex") + + +def _compare_bfs(cugraph_df, nx_distances, source): + # This call should only contain 3 columns: + # 'vertex', 'distance', 'predecessor' + # It also confirms wether or not 'sp_counter' has been created by the call + # 'sp_counter' triggers atomic operations in BFS, thus we want to make + # sure that it was not the case + # NOTE: 'predecessor' is always returned while the C++ function allows to + # pass a nullptr + assert len(cugraph_df.columns) == 3, ( + "The result of the BFS has an invalid " "number of columns" + ) + cu_distances = { + vertex: dist + for vertex, dist in zip( + cugraph_df["vertex"].to_numpy(), cugraph_df["distance"].to_numpy() + ) + } + cu_predecessors = { + vertex: dist + for vertex, dist in zip( + cugraph_df["vertex"].to_numpy(), cugraph_df["predecessor"].to_numpy() + ) + } + + # FIXME: The following only verifies vertices that were reached + # by cugraph's BFS. + # We assume that the distances are given back as integers in BFS + # max_val = np.iinfo(df['distance'].dtype).max + # Unreached vertices have a distance of max_val + + missing_vertex_error = 0 + distance_mismatch_error = 0 + invalid_predecessor_error = 0 + for vertex in nx_distances: + if vertex in cu_distances: + result = cu_distances[vertex] + expected = nx_distances[vertex] + if result != expected: + print( + "[ERR] Mismatch on distances: " + "vid = {}, cugraph = {}, nx = {}".format(vertex, result, expected) + ) + distance_mismatch_error += 1 + if vertex not in cu_predecessors: + missing_vertex_error += 1 + else: + pred = cu_predecessors[vertex] + if vertex != source and pred not in nx_distances: + invalid_predecessor_error += 1 + else: + # The graph is unweighted thus, predecessors are 1 away + if vertex != source and ( + (nx_distances[pred] + 1 != cu_distances[vertex]) + ): + print( + "[ERR] Invalid on predecessors: " + "vid = {}, cugraph = {}".format(vertex, pred) + ) + invalid_predecessor_error += 1 + else: + missing_vertex_error += 1 + assert missing_vertex_error == 0, "There are missing vertices" + assert distance_mismatch_error == 0, "There are invalid distances" + assert invalid_predecessor_error == 0, "There are invalid predecessors" + + +def get_cu_graph_nx_graph_and_params(dataset, directed): + """ + Helper for fixtures returning a Nx graph obj and params. + """ + # create graph + G = dataset.get_graph(create_using=cugraph.Graph(directed=directed)) + dataset_path = dataset.get_path() + + return ( + G, + dataset_path, + directed, + utils.generate_nx_graph_from_file(dataset_path, directed), + ) + + +def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, Gnx): + """ + Helper for fixtures returning Nx results and params. + """ + random.seed(seed) + start_vertex = random.sample(list(Gnx.nodes()), 1)[0] + + nx_values = nx.single_source_shortest_path_length( + Gnx, start_vertex, cutoff=depth_limit + ) + + return (G, dataset, directed, nx_values, start_vertex, depth_limit) + + +# ============================================================================= +# Pytest Fixtures +# ============================================================================= +SEEDS = [pytest.param(s) for s in SUBSET_SEED_OPTIONS] +DIRECTED = [pytest.param(d) for d in DIRECTED_GRAPH_OPTIONS] +DATASETS = [pytest.param(d) for d in datasets.DATASETS] +DATASETS_SMALL = [pytest.param(d) for d in datasets.DATASETS_SMALL] +DEPTH_LIMIT = [pytest.param(d) for d in DEPTH_LIMITS] + +# Call gen_fixture_params_product() to caluculate the cartesian product of +# multiple lists of params. This is required since parameterized fixtures do +# not do this automatically (unlike multiply-parameterized tests). The 2nd +# item in the tuple is a label for the param value used when displaying the +# full test name. +algo_test_fixture_params = gen_fixture_params_product( + (SEEDS, "seed"), (DEPTH_LIMIT, "depth_limit") +) + +graph_fixture_params = gen_fixture_params_product( + (DATASETS, "ds"), (DIRECTED, "dirctd") +) + +small_graph_fixture_params = gen_fixture_params_product( + (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd") +) + +# The single param list variants are used when only 1 param combination is +# needed (eg. testing non-native input types where tests for other combinations +# was covered elsewhere). +single_algo_test_fixture_params = gen_fixture_params_product( + ([SEEDS[0]], "seed"), ([DEPTH_LIMIT[0]], "depth_limit") +) + +single_small_graph_fixture_params = gen_fixture_params_product( + ([DATASETS_SMALL[0]], "ds"), (DIRECTED, "dirctd") +) + + +# Fixtures that result in a test-per (dataset X directed/undirected) +# combination. These return the path to the dataset, a bool indicating if a +# directed graph is being used, and the Nx graph object. +@pytest.fixture(scope="module", params=graph_fixture_params) +def dataset_nx_graph(request): + return get_cu_graph_nx_graph_and_params(*request.param) + + +@pytest.fixture(scope="module", params=small_graph_fixture_params) +def small_dataset_nx_graph(request): + return get_cu_graph_nx_graph_and_params(*request.param) + + +@pytest.fixture(scope="module", params=single_small_graph_fixture_params) +def single_small_dataset_nx_graph(request): + return get_cu_graph_nx_graph_and_params(*request.param) + + +# Fixtures that result in a test-per (dataset_nx_graph combinations X algo_test +# param combinations) combination. These run Nx BFS on the Nx graph obj and +# return the path to the dataset, if a directed graph is being used, the Nx BFS +# results, the starting vertex for BFS, and flag if shortes path counting was +# used. +@pytest.fixture(scope="module", params=algo_test_fixture_params) +def dataset_nxresults_startvertex_spc(dataset_nx_graph, request): + return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_graph) + + +@pytest.fixture(scope="module", params=single_algo_test_fixture_params) +def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_graph, request): + return get_cu_graph_nx_results_and_params( + *request.param, *single_small_dataset_nx_graph + ) + + +@pytest.fixture(scope="module") +def dataset_nxresults_allstartvertices_spc(small_dataset_nx_graph): + + dataset, directed, Gnx = small_dataset_nx_graph + use_spc = True + + start_vertices = [start_vertex for start_vertex in Gnx] + + all_nx_values = [] + for start_vertex in start_vertices: + _, _, nx_sp_counter = nxacb._single_source_shortest_path_basic( + Gnx, start_vertex + ) + nx_values = nx_sp_counter + all_nx_values.append(nx_values) + + return (dataset, directed, all_nx_values, start_vertices, use_spc) + + +# ============================================================================= +# Tests +# ============================================================================= +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) +def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type): + """ + Test BFS traversal on random source with distance and predecessors + """ + ( + G, + dataset, + directed, + nx_values, + start_vertex, + depth_limit, + ) = dataset_nxresults_startvertex_spc + + # special case: ensure cugraph and Nx Graph types are DiGraphs if + # "directed" is set, since the graph type parameterization is currently + # independent of the directed parameter. Unfortunately this does not + # change the "id" in the pytest output. Ignore for nonnative inputs + if directed: + if isinstance(cugraph_input_type, cugraph.Graph): + cugraph_input_type = cugraph.Graph(directed=True) + elif cugraph_input_type is nx.Graph: + cugraph_input_type = nx.DiGraph + + if not isinstance(cugraph_input_type, cugraph.Graph): + G_or_matrix = utils.create_obj_from_csv(dataset, cugraph_input_type) + else: + G_or_matrix = G + + compare_bfs(gpubenchmark, G_or_matrix, nx_values, start_vertex, depth_limit) + + +@pytest.mark.sg +@pytest.mark.parametrize( + "cugraph_input_type", utils.NX_INPUT_TYPES + utils.MATRIX_INPUT_TYPES +) +def test_bfs_nonnative_inputs( + gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type +): + test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) +def test_bfs_invalid_start( + gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type +): + ( + G, + dataset, + directed, + nx_values, + start_vertex, + depth_limit, + ) = dataset_nxresults_startvertex_spc + + el = G.view_edge_list() + + newval = max(el.src.max(), el.dst.max()) + 1 + start_vertex = newval + + with pytest.raises(ValueError): + cugraph.bfs(G, start_vertex, depth_limit=depth_limit) + + +@pytest.mark.sg +def test_scipy_api_compat(): + graph_file = datasets.DATASETS[0] + dataset_path = graph_file.get_path() + + input_cugraph_graph = graph_file.get_graph(ignore_weights=True) + + input_coo_matrix = utils.create_obj_from_csv( + dataset_path, cp_coo_matrix, edgevals=True + ) + # Ensure scipy-only options are rejected for cugraph inputs + with pytest.raises(TypeError): + cugraph.bfs(input_cugraph_graph, start=0, directed=False) + with pytest.raises(TypeError): + cugraph.bfs(input_cugraph_graph) # required arg missing + + # Ensure cugraph-compatible options work as expected + cugraph.bfs(input_cugraph_graph, i_start=0) + cugraph.bfs(input_cugraph_graph, i_start=0) + # cannot have start and i_start + with pytest.raises(TypeError): + cugraph.bfs(input_cugraph_graph, start=0, i_start=0) + + # Ensure SciPy options for matrix inputs work as expected + cugraph.bfs(input_coo_matrix, i_start=0) + cugraph.bfs(input_coo_matrix, i_start=0, directed=True) + cugraph.bfs(input_coo_matrix, i_start=0, directed=False) + result = cugraph.bfs(input_coo_matrix, i_start=0) + assert type(result) is tuple + assert len(result) == 2 diff --git a/python/cugraph/cugraph/tests/traversal/test_paths.py b/python/cugraph/cugraph/tests/traversal/test_paths.py index 8938ae74553..5d029500849 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths.py @@ -18,7 +18,8 @@ import cudf from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix import cupy -import networkx as nx + +from cugraph.testing import ResultSet import pytest import cugraph @@ -36,6 +37,8 @@ DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" +paths_results = ResultSet(local_result_file="paths_results.pkl") + @pytest.fixture def graphs(request): @@ -43,7 +46,6 @@ def graphs(request): graph_tf.writelines(request.param) graph_tf.seek(0) - nx_G = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") cudf_df = cudf.read_csv( graph_tf.name, names=["src", "dst", "data"], @@ -74,57 +76,48 @@ def graphs(request): (weights, (i, j)), shape=(largest_vertex + 1, largest_vertex + 1) ) - yield cugraph_G, nx_G, cupy_df + yield cugraph_G, cupy_df @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_connected_graph_shortest_path_length(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) assert path_1_to_1_length == 0.0 - assert path_1_to_1_length == nx.shortest_path_length( - nx_G, "1", target="1", weight="weight" - ) - assert path_1_to_1_length == cugraph.shortest_path_length(nx_G, "1", "1") + assert path_1_to_1_length == paths_results.results["1,1,connected,nx"] + assert path_1_to_1_length == paths_results.results["1,1,connected,cu"] assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) assert path_1_to_5_length == 2.0 - assert path_1_to_5_length == nx.shortest_path_length( - nx_G, "1", target="5", weight="weight" - ) - assert path_1_to_5_length == cugraph.shortest_path_length(nx_G, "1", "5") + assert path_1_to_5_length == paths_results.results["1,5,connected,nx"] + assert path_1_to_5_length == paths_results.results["1,5,connected,cu"] assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) assert path_1_to_3_length == 2.0 - assert path_1_to_3_length == nx.shortest_path_length( - nx_G, "1", target="3", weight="weight" - ) - assert path_1_to_3_length == cugraph.shortest_path_length(nx_G, "1", "3") + assert path_1_to_3_length == paths_results.results["1,3,connected,nx"] + assert path_1_to_3_length == paths_results.results["1,3,connected,cu"] assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) assert path_1_to_6_length == 2.0 - assert path_1_to_6_length == nx.shortest_path_length( - nx_G, "1", target="6", weight="weight" - ) - assert path_1_to_6_length == cugraph.shortest_path_length(nx_G, "1", "6") + assert path_1_to_6_length == paths_results.results["1,6,connected,nx"] + assert path_1_to_6_length == paths_results.results["1,6,connected,cu"] assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_source(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, -1, 1) - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "-1", "1") + assert "ValueError" == paths_results.results["-1,1,connected,invalid"] with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, -1, 1) @@ -133,13 +126,12 @@ def test_shortest_path_length_invalid_source(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_target(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 1, 10) - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "1", "10") + assert "ValueError" == paths_results.results["1,10,disconnected,invalid"] with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, 1, 10) @@ -148,13 +140,12 @@ def test_shortest_path_length_invalid_target(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_vertexes(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 0, 42) - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "0", "42") + assert "ValueError" == paths_results.results["0,42,connected,invalid"] with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, 0, 42) @@ -163,7 +154,7 @@ def test_shortest_path_length_invalid_vertexes(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_no_path(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs # FIXME: In case there is no path between two vertices, the # result can be either the max of float32 or float64 @@ -171,18 +162,23 @@ def test_shortest_path_length_no_path(graphs): path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) assert path_1_to_8 == sys.float_info.max - assert cugraph.shortest_path_length(nx_G, "1", "8") in [max_float_32, path_1_to_8] + assert paths_results.results["1,8,disconnected,invalid"] in [ + max_float_32, + path_1_to_8, + ] assert path_1_to_8 == cugraph.shortest_path_length(cupy_df, 1, 8) @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_no_target(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - nx_path_1_to_all = nx.shortest_path_length(nx_G, source="1", weight="weight") - nx_gpu_path_1_to_all = cugraph.shortest_path_length(nx_G, "1") + # nx_path_1_to_all = get_paths_results("1,notarget,nx") + # nx_gpu_path_1_to_all = cudf.DataFrame.from_dict(get_paths_results("1,notarget,cu")) + nx_path_1_to_all = paths_results.results["1,notarget,nx"] + nx_gpu_path_1_to_all = cudf.DataFrame.from_dict(paths_results.results["1,notarget,cu"]) cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) # Cast networkx graph on cugraph vertex column type from str to int. diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_old.py b/python/cugraph/cugraph/tests/traversal/test_paths_old.py new file mode 100644 index 00000000000..8938ae74553 --- /dev/null +++ b/python/cugraph/cugraph/tests/traversal/test_paths_old.py @@ -0,0 +1,208 @@ +# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +from tempfile import NamedTemporaryFile +import math + +import cudf +from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix +import cupy +import networkx as nx +import pytest + +import cugraph + + +CONNECTED_GRAPH = """1,5,3 +1,4,1 +1,2,1 +1,6,2 +1,7,2 +4,5,1 +2,3,1 +7,6,2 +""" + +DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" + + +@pytest.fixture +def graphs(request): + with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: + graph_tf.writelines(request.param) + graph_tf.seek(0) + + nx_G = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") + cudf_df = cudf.read_csv( + graph_tf.name, + names=["src", "dst", "data"], + delimiter=",", + dtype=["int32", "int32", "float64"], + ) + cugraph_G = cugraph.Graph() + cugraph_G.from_cudf_edgelist( + cudf_df, source="src", destination="dst", edge_attr="data" + ) + + # construct cupy coo_matrix graph + i = [] + j = [] + weights = [] + for index in range(cudf_df.shape[0]): + vertex1 = cudf_df.iloc[index]["src"] + vertex2 = cudf_df.iloc[index]["dst"] + weight = cudf_df.iloc[index]["data"] + i += [vertex1, vertex2] + j += [vertex2, vertex1] + weights += [weight, weight] + i = cupy.array(i) + j = cupy.array(j) + weights = cupy.array(weights) + largest_vertex = max(cupy.amax(i), cupy.amax(j)) + cupy_df = cupy_coo_matrix( + (weights, (i, j)), shape=(largest_vertex + 1, largest_vertex + 1) + ) + + yield cugraph_G, nx_G, cupy_df + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) +def test_connected_graph_shortest_path_length(graphs): + cugraph_G, nx_G, cupy_df = graphs + + path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) + assert path_1_to_1_length == 0.0 + assert path_1_to_1_length == nx.shortest_path_length( + nx_G, "1", target="1", weight="weight" + ) + assert path_1_to_1_length == cugraph.shortest_path_length(nx_G, "1", "1") + assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) + + path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) + assert path_1_to_5_length == 2.0 + assert path_1_to_5_length == nx.shortest_path_length( + nx_G, "1", target="5", weight="weight" + ) + assert path_1_to_5_length == cugraph.shortest_path_length(nx_G, "1", "5") + assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) + + path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) + assert path_1_to_3_length == 2.0 + assert path_1_to_3_length == nx.shortest_path_length( + nx_G, "1", target="3", weight="weight" + ) + assert path_1_to_3_length == cugraph.shortest_path_length(nx_G, "1", "3") + assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) + + path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) + assert path_1_to_6_length == 2.0 + assert path_1_to_6_length == nx.shortest_path_length( + nx_G, "1", target="6", weight="weight" + ) + assert path_1_to_6_length == cugraph.shortest_path_length(nx_G, "1", "6") + assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_invalid_source(graphs): + cugraph_G, nx_G, cupy_df = graphs + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cugraph_G, -1, 1) + + with pytest.raises(ValueError): + cugraph.shortest_path_length(nx_G, "-1", "1") + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cupy_df, -1, 1) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_invalid_target(graphs): + cugraph_G, nx_G, cupy_df = graphs + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cugraph_G, 1, 10) + + with pytest.raises(ValueError): + cugraph.shortest_path_length(nx_G, "1", "10") + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cupy_df, 1, 10) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_invalid_vertexes(graphs): + cugraph_G, nx_G, cupy_df = graphs + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cugraph_G, 0, 42) + + with pytest.raises(ValueError): + cugraph.shortest_path_length(nx_G, "0", "42") + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cupy_df, 0, 42) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_no_path(graphs): + cugraph_G, nx_G, cupy_df = graphs + + # FIXME: In case there is no path between two vertices, the + # result can be either the max of float32 or float64 + max_float_32 = (2 - math.pow(2, -23)) * math.pow(2, 127) + + path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) + assert path_1_to_8 == sys.float_info.max + assert cugraph.shortest_path_length(nx_G, "1", "8") in [max_float_32, path_1_to_8] + assert path_1_to_8 == cugraph.shortest_path_length(cupy_df, 1, 8) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_no_target(graphs): + cugraph_G, nx_G, cupy_df = graphs + + cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) + nx_path_1_to_all = nx.shortest_path_length(nx_G, source="1", weight="weight") + nx_gpu_path_1_to_all = cugraph.shortest_path_length(nx_G, "1") + cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) + + # Cast networkx graph on cugraph vertex column type from str to int. + # SSSP preserves vertex type, convert for comparison + nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") + + assert cugraph_path_1_to_all == nx_gpu_path_1_to_all + assert cugraph_path_1_to_all == cupy_path_1_to_all + + # results for vertex 8 and 9 are not returned + assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 + + for index in range(cugraph_path_1_to_all.shape[0]): + + vertex = str(cugraph_path_1_to_all["vertex"][index].item()) + distance = cugraph_path_1_to_all["distance"][index].item() + + # verify cugraph against networkx + if vertex in {"8", "9"}: + # Networkx does not return distances for these vertexes. + assert distance == sys.float_info.max + else: + assert distance == nx_path_1_to_all[vertex] diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp.py b/python/cugraph/cugraph/tests/traversal/test_sssp.py index 1c99123f866..a3c8d419fea 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp.py @@ -12,7 +12,6 @@ # limitations under the License. import gc -import time import numpy as np import pytest @@ -30,30 +29,14 @@ from cugraph.experimental.datasets import DATASETS_UNDIRECTED import cugraph -from cugraph.testing import utils +from cugraph.testing import utils, ResultSet from cugraph.experimental import datasets -# Temporarily suppress warnings till networkX fixes deprecation warnings -# (Using or importing the ABCs from 'collections' instead of from -# 'collections.abc' is deprecated, and in 3.8 it will stop working) for -# python 3.7. Also, this import networkx needs to be relocated in the -# third-party group once this gets fixed. -import warnings - -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - import networkx as nx - -print("Networkx version : {} ".format(nx.__version__)) - - # Map of cuGraph input types to the expected output type for cuGraph # connected_components calls. cuGraph_input_output_map = { cugraph.Graph: cudf.DataFrame, - nx.Graph: pd.DataFrame, - nx.DiGraph: pd.DataFrame, cp_coo_matrix: tuple, cp_csr_matrix: tuple, cp_csc_matrix: tuple, @@ -63,6 +46,8 @@ } cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] +sssp_results = ResultSet(local_result_file="sssp_results.pkl") + # ============================================================================= # Pytest Setup / Teardown - called for each test function @@ -142,43 +127,30 @@ def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=Tru def networkx_call(graph_file, source, edgevals=True): dataset_path = graph_file.get_path() - M = utils.read_csv_for_nx(dataset_path, read_weights_in_sp=True) - # Directed NetworkX graph - edge_attr = "weight" if edgevals else None - - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr=edge_attr, - create_using=nx.DiGraph(), - ) - print("NX Solving... ") - t1 = time.time() + dataset_name = graph_file.metadata["name"] if edgevals is False: - nx_paths = nx.single_source_shortest_path_length(Gnx, source) + # FIXME: no test coverage if edgevals is False, this assertion is never reached + assert False + nx_paths = sssp_results.results["{},{},ssspl".format(dataset_name, source)] else: # FIXME: The nx call below doesn't return accurate results as it seems to # not support 'weights'. It matches cuGraph result only if the weight column # is 1s. - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + nx_paths = sssp_results.results["{},{},ssdpl".format(dataset_name, source)] G = graph_file.get_graph( create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals ) - t2 = time.time() - t1 - print("NX Time : " + str(t2)) - - return (G, dataset_path, source, nx_paths, Gnx) + return (G, dataset_path, graph_file, source, nx_paths) # ============================================================================= # Pytest fixtures # ============================================================================= -# Call gen_fixture_params_product() to caluculate the cartesian product of +# Call gen_fixture_params_product() to calculate the cartesian product of # multiple lists of params. This is required since parameterized fixtures do # not do this automatically (unlike multiply-parameterized tests). The 2nd # item in the tuple is a label for the param value used when displaying the @@ -225,7 +197,7 @@ def single_dataset_source_nxresults_weighted(request): @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): # Extract the params generated from the fixture - (G, dataset_path, source, nx_paths, Gnx) = dataset_source_nxresults + (G, dataset_path, _, source, nx_paths) = dataset_source_nxresults if not isinstance(cugraph_input_type, cugraph.Graph): input_G_or_matrix = utils.create_obj_from_csv( @@ -259,7 +231,7 @@ def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_input_type): - (G, _, source, nx_paths, Gnx) = dataset_source_nxresults + (G, _, _, source, _) = dataset_source_nxresults el = G.view_edge_list() newval = max(el.src.max(), el.dst.max()) + 1 @@ -270,22 +242,58 @@ def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_inpu @pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_sssp_nonnative_inputs( +@pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) +def test_sssp_nonnative_inputs_matrix( gpubenchmark, single_dataset_source_nxresults, cugraph_input_type ): test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) +def test_sssp_nonnative_inputs_nx( + gpubenchmark, single_dataset_source_nxresults, cugraph_input_type +): + (_, _, _, source, nx_paths) = single_dataset_source_nxresults + result = sssp_results.results["nonnative_input,{},{}".format(cugraph_input_type, source)] + # ^^ should be a pd dataframe + result = cudf.from_pandas(result) + if np.issubdtype(result["distance"].dtype, np.integer): + max_val = np.iinfo(result["distance"].dtype).max + else: + max_val = np.finfo(result["distance"].dtype).max + verts = result["vertex"].to_numpy() + dists = result["distance"].to_numpy() + preds = result["predecessor"].to_numpy() + cu_paths = dict(zip(verts, zip(dists, preds))) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + 1 = current dist (since unweighted) + pred = cu_paths[vid][1] + if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) def test_sssp_edgevals( gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type ): # Extract the params generated from the fixture - (G, _, source, nx_paths, Gnx) = dataset_source_nxresults_weighted + (G, _, dataset, source, nx_paths) = dataset_source_nxresults_weighted input_G_or_matrix = G cu_paths, max_val = cugraph_call( @@ -298,19 +306,20 @@ def test_sssp_edgevals( # Validate vertices that are reachable # NOTE : If distance type is float64 then cu_paths[vid][0] # should be compared against np.finfo(np.float64).max) + distances = cugraph.sssp(G, source=vid) if cu_paths[vid][0] != max_val: if cu_paths[vid][0] != nx_paths[vid]: err = err + 1 # check pred dist + edge_weight = current dist if vid != source: pred = cu_paths[vid][1] - edge_weight = Gnx[pred][vid]["weight"] + if G.has_edge(pred, vid): + edge_weight = distances[distances["vertex"] == pred].iloc[0, 0] if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: err = err + 1 else: if vid in nx_paths.keys(): err = err + 1 - assert err == 0 @@ -331,7 +340,7 @@ def test_sssp_edgevals_nonnative_inputs( @pytest.mark.parametrize("source", SOURCES) def test_sssp_data_type_conversion(graph_file, source): dataset_path = graph_file.get_path() - M = utils.read_csv_for_nx(dataset_path) + dataset_name = graph_file.metadata["name"] cu_M = utils.read_csv_file(dataset_path) # cugraph call with int32 weights @@ -346,19 +355,7 @@ def test_sssp_data_type_conversion(graph_file, source): dist_np = df["distance"].to_numpy() pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - - # networkx call with int32 weights - M["weight"] = M["weight"].astype(np.int32) - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr="weight", - create_using=nx.DiGraph(), - ) - # assert nx weights is int - assert type(list(Gnx.edges(data=True))[0][2]["weight"]) is int - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + nx_paths = sssp_results.results["nx_paths,data_type_conversion,{}".format(dataset_name)] # Calculating mismatch err = 0 @@ -366,13 +363,15 @@ def test_sssp_data_type_conversion(graph_file, source): # Validate vertices that are reachable # NOTE : If distance type is float64 then cu_paths[vid][0] # should be compared against np.finfo(np.float64).max) + distances = cugraph.sssp(G, source=vid) if cu_paths[vid][0] != max_val: if cu_paths[vid][0] != nx_paths[vid]: err = err + 1 # check pred dist + edge_weight = current dist if vid != source: pred = cu_paths[vid][1] - edge_weight = Gnx[pred][vid]["weight"] + if G.has_edge(pred, vid): + edge_weight = distances[distances["vertex"] == pred].iloc[0, 0] if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: err = err + 1 else: @@ -384,10 +383,8 @@ def test_sssp_data_type_conversion(graph_file, source): @pytest.mark.sg def test_sssp_networkx_edge_attr(): - G = nx.Graph() - G.add_edge(0, 1, other=10) - G.add_edge(1, 2, other=20) - df = cugraph.sssp(G, 0, edge_attr="other") + df = sssp_results.results["network_edge_attr"] + df = cudf.DataFrame(df) df = df.set_index("vertex") assert df.loc[0, "distance"] == 0 assert df.loc[1, "distance"] == 10 diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp_old.py b/python/cugraph/cugraph/tests/traversal/test_sssp_old.py new file mode 100644 index 00000000000..1c99123f866 --- /dev/null +++ b/python/cugraph/cugraph/tests/traversal/test_sssp_old.py @@ -0,0 +1,519 @@ +# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +import time + +import numpy as np +import pytest +import pandas as pd +import cupy as cp +import cupyx +from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix +from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix +from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix +from scipy.sparse import coo_matrix as sp_coo_matrix +from scipy.sparse import csr_matrix as sp_csr_matrix +from scipy.sparse import csc_matrix as sp_csc_matrix +import cudf +from pylibcugraph.testing.utils import gen_fixture_params_product +from cugraph.experimental.datasets import DATASETS_UNDIRECTED + +import cugraph +from cugraph.testing import utils +from cugraph.experimental import datasets + + +# Temporarily suppress warnings till networkX fixes deprecation warnings +# (Using or importing the ABCs from 'collections' instead of from +# 'collections.abc' is deprecated, and in 3.8 it will stop working) for +# python 3.7. Also, this import networkx needs to be relocated in the +# third-party group once this gets fixed. +import warnings + +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + import networkx as nx + +print("Networkx version : {} ".format(nx.__version__)) + + +# Map of cuGraph input types to the expected output type for cuGraph +# connected_components calls. +cuGraph_input_output_map = { + cugraph.Graph: cudf.DataFrame, + nx.Graph: pd.DataFrame, + nx.DiGraph: pd.DataFrame, + cp_coo_matrix: tuple, + cp_csr_matrix: tuple, + cp_csc_matrix: tuple, + sp_coo_matrix: tuple, + sp_csr_matrix: tuple, + sp_csc_matrix: tuple, +} +cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] + + +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= +def setup_function(): + gc.collect() + + +# ============================================================================= +# Helper functions +# ============================================================================= +def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=True): + """ + Call cugraph.sssp on input_G_or_matrix, then convert the result to a + standard format (dictionary of vertex IDs to (distance, predecessor) + tuples) for easy checking in the test code. + """ + result = gpu_benchmark_callable(cugraph.sssp, input_G_or_matrix, source) + + input_type = type(input_G_or_matrix) + expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] + assert type(result) is expected_return_type + + # Convert cudf and pandas: DF of 3 columns: (vertex, distance, predecessor) + if expected_return_type in [cudf.DataFrame, pd.DataFrame]: + if expected_return_type is pd.DataFrame: + result = cudf.from_pandas(result) + + if np.issubdtype(result["distance"].dtype, np.integer): + max_val = np.iinfo(result["distance"].dtype).max + else: + max_val = np.finfo(result["distance"].dtype).max + verts = result["vertex"].to_numpy() + dists = result["distance"].to_numpy() + preds = result["predecessor"].to_numpy() + + # A CuPy/SciPy input means the return value will be a 2-tuple of: + # distance: cupy.ndarray + # ndarray of shortest distances between source and vertex. + # predecessor: cupy.ndarray + # ndarray of predecessors of a vertex on the path from source, which + # can be used to reconstruct the shortest paths. + elif expected_return_type is tuple: + if input_type in cupy_types: + assert type(result[0]) is cp.ndarray + assert type(result[1]) is cp.ndarray + else: + assert type(result[0]) is np.ndarray + assert type(result[1]) is np.ndarray + + if np.issubdtype(result[0].dtype, np.integer): + max_val = np.iinfo(result[0].dtype).max + else: + max_val = np.finfo(result[0].dtype).max + + # Get unique verts from input since they are not incuded in output + if type(input_G_or_matrix) in [ + cp_csr_matrix, + cp_csc_matrix, + sp_csr_matrix, + sp_csc_matrix, + ]: + coo = input_G_or_matrix.tocoo(copy=False) + else: + coo = input_G_or_matrix + verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) + dists = [n.item() for n in result[0]] + preds = [n.item() for n in result[1]] + assert len(verts) == len(dists) == len(preds) + + else: + raise RuntimeError(f"unsupported return type: {expected_return_type}") + + result_dict = dict(zip(verts, zip(dists, preds))) + return result_dict, max_val + + +def networkx_call(graph_file, source, edgevals=True): + dataset_path = graph_file.get_path() + M = utils.read_csv_for_nx(dataset_path, read_weights_in_sp=True) + # Directed NetworkX graph + edge_attr = "weight" if edgevals else None + + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr=edge_attr, + create_using=nx.DiGraph(), + ) + print("NX Solving... ") + t1 = time.time() + + if edgevals is False: + nx_paths = nx.single_source_shortest_path_length(Gnx, source) + else: + # FIXME: The nx call below doesn't return accurate results as it seems to + # not support 'weights'. It matches cuGraph result only if the weight column + # is 1s. + nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + + G = graph_file.get_graph( + create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals + ) + + t2 = time.time() - t1 + print("NX Time : " + str(t2)) + + return (G, dataset_path, source, nx_paths, Gnx) + + +# ============================================================================= +# Pytest fixtures +# ============================================================================= + +# Call gen_fixture_params_product() to caluculate the cartesian product of +# multiple lists of params. This is required since parameterized fixtures do +# not do this automatically (unlike multiply-parameterized tests). The 2nd +# item in the tuple is a label for the param value used when displaying the +# full test name. +# FIXME: tests with datasets like 'netscience' which has a weight column different +# than than 1's fail because it looks like netwokX doesn't consider weights during +# the computation. +DATASETS = [pytest.param(d) for d in datasets.DATASETS_SMALL] +SOURCES = [pytest.param(1)] +fixture_params = gen_fixture_params_product((DATASETS, "ds"), (SOURCES, "src")) +fixture_params_single_dataset = gen_fixture_params_product( + ([DATASETS[0]], "ds"), (SOURCES, "src") +) + + +# These fixtures will call networkx BFS algos and save the result. The networkx +# call is only made only once per input param combination. +@pytest.fixture(scope="module", params=fixture_params) +def dataset_source_nxresults(request): + # request.param is a tuple of params from fixture_params. When expanded + # with *, will be passed to networkx_call() as args (graph_file, source) + return networkx_call(*(request.param)) + + +@pytest.fixture(scope="module", params=fixture_params_single_dataset) +def single_dataset_source_nxresults(request): + return networkx_call(*(request.param)) + + +@pytest.fixture(scope="module", params=fixture_params) +def dataset_source_nxresults_weighted(request): + return networkx_call(*(request.param), edgevals=True) + + +@pytest.fixture(scope="module", params=fixture_params_single_dataset) +def single_dataset_source_nxresults_weighted(request): + return networkx_call(*(request.param), edgevals=True) + + +# ============================================================================= +# Tests +# ============================================================================= +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) +def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): + # Extract the params generated from the fixture + (G, dataset_path, source, nx_paths, Gnx) = dataset_source_nxresults + + if not isinstance(cugraph_input_type, cugraph.Graph): + input_G_or_matrix = utils.create_obj_from_csv( + dataset_path, cugraph_input_type, edgevals=True + ) + else: + input_G_or_matrix = G + + cu_paths, max_val = cugraph_call(gpubenchmark, input_G_or_matrix, source) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + 1 = current dist (since unweighted) + pred = cu_paths[vid][1] + if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) +def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_input_type): + (G, _, source, nx_paths, Gnx) = dataset_source_nxresults + el = G.view_edge_list() + + newval = max(el.src.max(), el.dst.max()) + 1 + source = newval + + with pytest.raises(ValueError): + cugraph_call(gpubenchmark, G, source) + + +@pytest.mark.sg +@pytest.mark.parametrize( + "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES +) +def test_sssp_nonnative_inputs( + gpubenchmark, single_dataset_source_nxresults, cugraph_input_type +): + test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) +def test_sssp_edgevals( + gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type +): + # Extract the params generated from the fixture + (G, _, source, nx_paths, Gnx) = dataset_source_nxresults_weighted + input_G_or_matrix = G + + cu_paths, max_val = cugraph_call( + gpubenchmark, input_G_or_matrix, source, edgevals=True + ) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + edge_weight = current dist + if vid != source: + pred = cu_paths[vid][1] + edge_weight = Gnx[pred][vid]["weight"] + if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + +@pytest.mark.sg +@pytest.mark.parametrize( + "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES +) +def test_sssp_edgevals_nonnative_inputs( + gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type +): + test_sssp_edgevals( + gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type + ) + + +@pytest.mark.sg +@pytest.mark.parametrize("graph_file", DATASETS) +@pytest.mark.parametrize("source", SOURCES) +def test_sssp_data_type_conversion(graph_file, source): + dataset_path = graph_file.get_path() + M = utils.read_csv_for_nx(dataset_path) + cu_M = utils.read_csv_file(dataset_path) + + # cugraph call with int32 weights + cu_M["2"] = cu_M["2"].astype(np.int32) + G = cugraph.Graph(directed=True) + G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") + # assert cugraph weights is int32 + assert G.edgelist.edgelist_df["weights"].dtype == np.int32 + df = cugraph.sssp(G, source) + max_val = np.finfo(df["distance"].dtype).max + verts_np = df["vertex"].to_numpy() + dist_np = df["distance"].to_numpy() + pred_np = df["predecessor"].to_numpy() + cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) + + # networkx call with int32 weights + M["weight"] = M["weight"].astype(np.int32) + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr="weight", + create_using=nx.DiGraph(), + ) + # assert nx weights is int + assert type(list(Gnx.edges(data=True))[0][2]["weight"]) is int + nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + edge_weight = current dist + if vid != source: + pred = cu_paths[vid][1] + edge_weight = Gnx[pred][vid]["weight"] + if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + +@pytest.mark.sg +def test_sssp_networkx_edge_attr(): + G = nx.Graph() + G.add_edge(0, 1, other=10) + G.add_edge(1, 2, other=20) + df = cugraph.sssp(G, 0, edge_attr="other") + df = df.set_index("vertex") + assert df.loc[0, "distance"] == 0 + assert df.loc[1, "distance"] == 10 + assert df.loc[2, "distance"] == 30 + + +@pytest.mark.sg +def test_scipy_api_compat(): + graph_file = datasets.DATASETS[0] + dataset_path = graph_file.get_path() + input_cugraph_graph = graph_file.get_graph() + input_coo_matrix = utils.create_obj_from_csv( + dataset_path, cp_coo_matrix, edgevals=True + ) + + # Ensure scipy-only options are rejected for cugraph inputs + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, directed=False) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, unweighted=False) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, overwrite=False) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, return_predecessors=False) + + # Ensure cugraph-compatible options work as expected + # cannot set both source and indices, but must set one + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, indices=0) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph) + with pytest.raises(ValueError): + cugraph.shortest_path(input_cugraph_graph, source=0, method="BF") + cugraph.shortest_path(input_cugraph_graph, indices=0) + with pytest.raises(ValueError): + cugraph.shortest_path(input_cugraph_graph, indices=[0, 1, 2]) + cugraph.shortest_path(input_cugraph_graph, source=0, method="auto") + + # Ensure SciPy options for matrix inputs work as expected + # cannot set both source and indices, but must set one + with pytest.raises(TypeError): + cugraph.shortest_path(input_coo_matrix, source=0, indices=0) + with pytest.raises(TypeError): + cugraph.shortest_path(input_coo_matrix) + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, method="BF") + cugraph.shortest_path(input_coo_matrix, source=0, method="auto") + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, directed=3) + cugraph.shortest_path(input_coo_matrix, source=0, directed=True) + cugraph.shortest_path(input_coo_matrix, source=0, directed=False) + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, return_predecessors=3) + (distances, preds) = cugraph.shortest_path( + input_coo_matrix, source=0, return_predecessors=True + ) + distances = cugraph.shortest_path( + input_coo_matrix, source=0, return_predecessors=False + ) + assert type(distances) != tuple + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, unweighted=False) + cugraph.shortest_path(input_coo_matrix, source=0, unweighted=True) + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, overwrite=True) + cugraph.shortest_path(input_coo_matrix, source=0, overwrite=False) + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, indices=[0, 1, 2]) + cugraph.shortest_path(input_coo_matrix, indices=0) + + +@pytest.mark.sg +@pytest.mark.parametrize("graph_file", DATASETS_UNDIRECTED) +def test_sssp_csr_graph(graph_file): + df = graph_file.get_edgelist() + + M = cupyx.scipy.sparse.coo_matrix( + (df["wgt"].to_cupy(), (df["src"].to_cupy(), df["dst"].to_cupy())) + ) + M = M.tocsr() + + offsets = cudf.Series(M.indptr) + indices = cudf.Series(M.indices) + weights = cudf.Series(M.data) + G_csr = cugraph.Graph() + G_coo = graph_file.get_graph() + + source = G_coo.select_random_vertices(num_vertices=1)[0] + + print("source = ", source) + + G_csr.from_cudf_adjlist(offsets, indices, weights) + + result_csr = cugraph.sssp(G_csr, source) + result_coo = cugraph.sssp(G_coo, source) + + result_csr = result_csr.sort_values("vertex").reset_index(drop=True) + result_sssp = ( + result_coo.sort_values("vertex") + .reset_index(drop=True) + .rename(columns={"distance": "distance_coo", "predecessor": "predecessor_coo"}) + ) + result_sssp["distance_csr"] = result_csr["distance"] + result_sssp["predecessor_csr"] = result_csr["predecessor"] + + distance_diffs = result_sssp.query("distance_csr != distance_coo") + predecessor_diffs = result_sssp.query("predecessor_csr != predecessor_coo") + + assert len(distance_diffs) == 0 + assert len(predecessor_diffs) == 0 + + +@pytest.mark.sg +def test_sssp_unweighted_graph(): + karate = DATASETS_UNDIRECTED[0] + G = karate.get_graph(ignore_weights=True) + + error_msg = ( + "'SSSP' requires the input graph to be weighted." + "'BFS' should be used instead of 'SSSP' for unweighted graphs." + ) + + with pytest.raises(RuntimeError, match=error_msg): + cugraph.sssp(G, 1) From 5386a29c5b739801e5ae507c2fc857e861cf7625 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Wed, 12 Jul 2023 21:09:10 +0000 Subject: [PATCH 02/20] Style check --- python/cugraph/cugraph/testing/__init__.py | 6 ++--- python/cugraph/cugraph/testing/resultset.py | 22 ++++++++++--------- python/cugraph/cugraph/testing/utils.py | 10 +++++++-- .../cugraph/tests/traversal/test_bfs.py | 10 ++++++--- .../cugraph/tests/traversal/test_paths.py | 6 ++--- .../cugraph/tests/traversal/test_sssp.py | 8 +++++-- 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 03785d0ee49..777ee70794e 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -11,12 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cugraph.testing.utils import ( - RAPIDS_DATASET_ROOT_DIR_PATH, ResultSet -) +from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH, ResultSet from cugraph.testing.resultset import ( get_bfs_results, get_sssp_results, get_paths_results, -) \ No newline at end of file +) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 1611fc730ea..ec3a9705095 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -33,7 +33,7 @@ karate, polbooks, ) -from cugraph.testing import utils, ResultSet +from cugraph.testing import utils default_results_upload_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" @@ -80,9 +80,7 @@ Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) result = cugraph.bfs_edges(Gnx, source=7) cugraph_df = cudf.from_pandas(result) - test_bfs_results[ - "{},{},{}".format(ds, dirctd, "nonnative-nx") - ] = cugraph_df + test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df # ============================================================================= @@ -208,9 +206,7 @@ test_paths_results["1,notarget,nx"] = nx.shortest_path_length( Gnx_DIS, source="1", weight="weight" ) -test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length( - Gnx_DIS, "1" -) +test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length(Gnx_DIS, "1") # serial_bfs_results = pickle.dumps(test_bfs_results) @@ -221,9 +217,15 @@ # pickle.dump(test_sssp_results, open("testing/sssp_results.pkl", "wb")) # pickle.dump(test_paths_results, open("testing/paths_results.pkl", "wb")) -pickle.dump(test_bfs_results, open(default_results_upload_dir / "bfs_results.pkl", "wb")) -pickle.dump(test_sssp_results, open(default_results_upload_dir / "sssp_results.pkl", "wb")) -pickle.dump(test_paths_results, open(default_results_upload_dir / "paths_results.pkl", "wb")) +pickle.dump( + test_bfs_results, open(default_results_upload_dir / "bfs_results.pkl", "wb") +) +pickle.dump( + test_sssp_results, open(default_results_upload_dir / "sssp_results.pkl", "wb") +) +pickle.dump( + test_paths_results, open(default_results_upload_dir / "paths_results.pkl", "wb") +) # Example of how ResultSet is used in each individual testing script # my_bfs_results = ResultSet(local_result_file="bfs_results.pkl") diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index add4f56687a..ef69be35072 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -32,6 +32,7 @@ import cugraph from cugraph.dask.common.mg_utils import get_client + # from cugraph.experimental.datasets import default_download_dir @@ -424,7 +425,10 @@ def compare_mst(mst_cugraph, mst_nx): Gnx_dict[u][v] = Gnx[u][v] return Gnx_dict""" -default_results_download_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" +default_results_download_dir = ( + Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" +) + class ResultSet: """ @@ -459,7 +463,9 @@ def __init__(self, local_result_file=None, cloud_result_file=None): # try to load results, if file doesn't exist raise pref. RuntimeError raise FileNotFoundError(local_result_file) else: - with open(default_results_download_dir / local_result_file, "rb") as file: + with open( + default_results_download_dir / local_result_file, "rb" + ) as file: self.results = pickle.load(file) else: raise ValueError( diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs.py b/python/cugraph/cugraph/tests/traversal/test_bfs.py index fa0333f7706..5d5ea8ffcc2 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs.py @@ -12,10 +12,10 @@ # limitations under the License. import gc + # import random import pytest -import pandas as pd import cupy as cp import numpy as np from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix @@ -267,7 +267,9 @@ def get_cu_graph_nx_results_and_params( # nx_values = get_bfs_results( # "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) # ) - nx_values = bfs_results.results["{},{},{},{}".format(seed, depth_limit, dataset_name, directed)] + nx_values = bfs_results.results[ + "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) + ] return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) @@ -417,7 +419,9 @@ def test_bfs_nonnative_inputs_nx( _, ) = single_dataset_nxresults_startvertex_spc - cugraph_df = bfs_results.results["{},{},{}".format("karate", directed, "nonnative-nx")] + cugraph_df = bfs_results.results[ + "{},{},{}".format("karate", directed, "nonnative-nx") + ] compare_func = _compare_bfs compare_func(cugraph_df, nx_values, start_vertex) diff --git a/python/cugraph/cugraph/tests/traversal/test_paths.py b/python/cugraph/cugraph/tests/traversal/test_paths.py index 5d029500849..8b6330ac095 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths.py @@ -175,10 +175,10 @@ def test_shortest_path_length_no_target(graphs): cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - # nx_path_1_to_all = get_paths_results("1,notarget,nx") - # nx_gpu_path_1_to_all = cudf.DataFrame.from_dict(get_paths_results("1,notarget,cu")) nx_path_1_to_all = paths_results.results["1,notarget,nx"] - nx_gpu_path_1_to_all = cudf.DataFrame.from_dict(paths_results.results["1,notarget,cu"]) + nx_gpu_path_1_to_all = cudf.DataFrame.from_dict( + paths_results.results["1,notarget,cu"] + ) cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) # Cast networkx graph on cugraph vertex column type from str to int. diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp.py b/python/cugraph/cugraph/tests/traversal/test_sssp.py index a3c8d419fea..72db4999813 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp.py @@ -255,7 +255,9 @@ def test_sssp_nonnative_inputs_nx( gpubenchmark, single_dataset_source_nxresults, cugraph_input_type ): (_, _, _, source, nx_paths) = single_dataset_source_nxresults - result = sssp_results.results["nonnative_input,{},{}".format(cugraph_input_type, source)] + result = sssp_results.results[ + "nonnative_input,{},{}".format(cugraph_input_type, source) + ] # ^^ should be a pd dataframe result = cudf.from_pandas(result) if np.issubdtype(result["distance"].dtype, np.integer): @@ -355,7 +357,9 @@ def test_sssp_data_type_conversion(graph_file, source): dist_np = df["distance"].to_numpy() pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - nx_paths = sssp_results.results["nx_paths,data_type_conversion,{}".format(dataset_name)] + nx_paths = sssp_results.results[ + "nx_paths,data_type_conversion,{}".format(dataset_name) + ] # Calculating mismatch err = 0 From 0d6930ca9e321d2721b78a08529fef805dd51092 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Thu, 20 Jul 2023 00:33:51 +0000 Subject: [PATCH 03/20] Modified results file generation, refactored traversal tests, no precommit --- python/cugraph/cugraph/testing/__init__.py | 10 +- ...('source', '1'), ('weight', 'weight')).csv | 10 + ...raph_directed', False), ('source', 1)).csv | 35 ++ ...graph_directed', True), ('source', 1)).csv | 35 ++ ...tive'), ('test', 'network_edge_attr')).csv | 4 + ...raph_directed', False), ('source', 7)).csv | 35 ++ ...graph_directed', True), ('source', 7)).csv | 35 ++ ...('source', '1'), ('weight', 'weight')).csv | 8 + ...graph_directed', True), ('source', 1)).csv | 63 +++ ... 1), ('test', 'data_type_conversion')).csv | 63 +++ ...graph_directed', True), ('source', 1)).csv | 35 ++ ... 1), ('test', 'data_type_conversion')).csv | 35 ++ ...graph_directed', True), ('source', 1)).csv | 106 ++++ ... 1), ('test', 'data_type_conversion')).csv | 106 ++++ ...rected', False), ('start_vertex', 16)).csv | 8 + ...irected', True), ('start_vertex', 16)).csv | 8 + ...irected', False), ('start_vertex', 7)).csv | 6 + ...directed', True), ('start_vertex', 7)).csv | 6 + ...rected', False), ('start_vertex', 19)).csv | 5 + ...irected', True), ('start_vertex', 19)).csv | 5 + ...cted', False), ('start_vertex', 1237)).csv | 3 + ...ected', True), ('start_vertex', 1237)).csv | 3 + ...rected', False), ('start_vertex', 16)).csv | 63 +++ ...irected', True), ('start_vertex', 16)).csv | 63 +++ ...irected', False), ('start_vertex', 7)).csv | 35 ++ ...directed', True), ('start_vertex', 7)).csv | 35 ++ ...rected', False), ('start_vertex', 19)).csv | 35 ++ ...irected', True), ('start_vertex', 19)).csv | 35 ++ ...cted', False), ('start_vertex', 1237)).csv | 3 + ...ected', True), ('start_vertex', 1237)).csv | 3 + ...rected', False), ('start_vertex', 16)).csv | 60 ++ ...irected', True), ('start_vertex', 16)).csv | 60 ++ ...irected', False), ('start_vertex', 7)).csv | 35 ++ ...directed', True), ('start_vertex', 7)).csv | 35 ++ ...rected', False), ('start_vertex', 19)).csv | 35 ++ ...irected', True), ('start_vertex', 19)).csv | 35 ++ ...cted', False), ('start_vertex', 1237)).csv | 3 + ...ected', True), ('start_vertex', 1237)).csv | 3 + ...rected', False), ('start_vertex', 16)).csv | 63 +++ ...irected', True), ('start_vertex', 16)).csv | 63 +++ ...irected', False), ('start_vertex', 7)).csv | 35 ++ ...directed', True), ('start_vertex', 7)).csv | 35 ++ ...rected', False), ('start_vertex', 19)).csv | 35 ++ ...irected', True), ('start_vertex', 19)).csv | 35 ++ ...cted', False), ('start_vertex', 1237)).csv | 3 + ...ected', True), ('start_vertex', 1237)).csv | 3 + python/cugraph/cugraph/testing/resultset.py | 28 +- .../cugraph/cugraph/testing/resultset_2308.py | 263 +++++++++ .../cugraph/cugraph/testing/resultset_pr.py | 55 ++ python/cugraph/cugraph/testing/utils.py | 60 +- .../cugraph/tests/traversal/BLUEPRINT.py | 50 ++ .../{test_bfs.py => test_bfs_current.py} | 37 +- .../cugraph/tests/traversal/test_bfs_old.py | 135 ++--- .../tests/traversal/test_bfs_withnx.py | 479 ++++++++++++++++ .../tests/traversal/test_paths_current.py | 239 ++++++++ .../cugraph/tests/traversal/test_paths_old.py | 108 ++-- .../{test_paths.py => test_paths_withnx.py} | 64 ++- .../{test_sssp.py => test_sssp_current.py} | 59 +- .../cugraph/tests/traversal/test_sssp_old.py | 133 ++--- .../tests/traversal/test_sssp_withnx.py | 519 ++++++++++++++++++ 60 files changed, 3384 insertions(+), 279 deletions(-) create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv create mode 100644 python/cugraph/cugraph/testing/resultset_2308.py create mode 100644 python/cugraph/cugraph/testing/resultset_pr.py create mode 100644 python/cugraph/cugraph/tests/traversal/BLUEPRINT.py rename python/cugraph/cugraph/tests/traversal/{test_bfs.py => test_bfs_current.py} (93%) create mode 100644 python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py create mode 100644 python/cugraph/cugraph/tests/traversal/test_paths_current.py rename python/cugraph/cugraph/tests/traversal/{test_paths.py => test_paths_withnx.py} (77%) rename python/cugraph/cugraph/tests/traversal/{test_sssp.py => test_sssp_current.py} (88%) create mode 100644 python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 777ee70794e..9cbc542354f 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -11,10 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH, ResultSet +from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH -from cugraph.testing.resultset import ( - get_bfs_results, - get_sssp_results, - get_paths_results, -) +from cugraph.testing.resultset_pr import ( + get_resultset +) \ No newline at end of file diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv new file mode 100644 index 00000000000..6872ef337f8 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv @@ -0,0 +1,10 @@ +,vertex,distance +0,2,1.0 +1,4,1.0 +2,6,2.0 +3,7,2.0 +4,5,2.0 +5,3,2.0 +6,1,0.0 +7,9,3.402823466e+38 +8,8,3.402823466e+38 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv new file mode 100644 index 00000000000..d09b494fe6d --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv @@ -0,0 +1,35 @@ +,distance,vertex,predecessor +0,2.0,33,13 +1,1.0,0,1 +2,2.0,32,2 +3,1.0,2,1 +4,0.0,1,-1 +5,1.0,3,1 +6,2.0,31,0 +7,2.0,8,0 +8,1.0,13,1 +9,3.0,23,33 +10,2.0,5,0 +11,2.0,6,0 +12,1.0,7,1 +13,2.0,27,2 +14,3.0,29,33 +15,1.0,30,1 +16,2.0,4,0 +17,2.0,10,0 +18,1.0,19,1 +19,3.0,24,31 +20,3.0,25,31 +21,2.0,28,2 +22,2.0,9,2 +23,2.0,12,0 +24,3.0,14,33 +25,3.0,15,33 +26,3.0,16,5 +27,1.0,17,1 +28,3.0,18,33 +29,3.0,20,33 +30,1.0,21,1 +31,3.0,22,33 +32,3.0,26,33 +33,2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv new file mode 100644 index 00000000000..d09b494fe6d --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv @@ -0,0 +1,35 @@ +,distance,vertex,predecessor +0,2.0,33,13 +1,1.0,0,1 +2,2.0,32,2 +3,1.0,2,1 +4,0.0,1,-1 +5,1.0,3,1 +6,2.0,31,0 +7,2.0,8,0 +8,1.0,13,1 +9,3.0,23,33 +10,2.0,5,0 +11,2.0,6,0 +12,1.0,7,1 +13,2.0,27,2 +14,3.0,29,33 +15,1.0,30,1 +16,2.0,4,0 +17,2.0,10,0 +18,1.0,19,1 +19,3.0,24,31 +20,3.0,25,31 +21,2.0,28,2 +22,2.0,9,2 +23,2.0,12,0 +24,3.0,14,33 +25,3.0,15,33 +26,3.0,16,5 +27,1.0,17,1 +28,3.0,18,33 +29,3.0,20,33 +30,1.0,21,1 +31,3.0,22,33 +32,3.0,26,33 +33,2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv new file mode 100644 index 00000000000..4918d7cf3b7 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv @@ -0,0 +1,4 @@ +,distance,vertex,predecessor +0,10.0,1,0 +1,0.0,0,-1 +2,30.0,2,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv new file mode 100644 index 00000000000..44531380162 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance,predecessor +0,33,3,32 +1,0,1,7 +2,32,2,2 +3,2,1,7 +4,1,1,7 +5,3,1,7 +6,31,2,0 +7,8,2,0 +8,13,2,0 +9,23,3,32 +10,5,2,0 +11,6,2,0 +12,7,0,-1 +13,27,2,2 +14,29,3,32 +15,30,2,1 +16,4,2,0 +17,10,2,0 +18,19,2,0 +19,24,3,31 +20,25,3,31 +21,28,2,2 +22,9,2,2 +23,12,2,0 +24,14,3,32 +25,15,3,32 +26,16,3,5 +27,17,2,0 +28,18,3,32 +29,20,3,32 +30,21,2,0 +31,22,3,32 +32,26,4,33 +33,11,2,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv new file mode 100644 index 00000000000..44531380162 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance,predecessor +0,33,3,32 +1,0,1,7 +2,32,2,2 +3,2,1,7 +4,1,1,7 +5,3,1,7 +6,31,2,0 +7,8,2,0 +8,13,2,0 +9,23,3,32 +10,5,2,0 +11,6,2,0 +12,7,0,-1 +13,27,2,2 +14,29,3,32 +15,30,2,1 +16,4,2,0 +17,10,2,0 +18,19,2,0 +19,24,3,31 +20,25,3,31 +21,28,2,2 +22,9,2,2 +23,12,2,0 +24,14,3,32 +25,15,3,32 +26,16,3,5 +27,17,2,0 +28,18,3,32 +29,20,3,32 +30,21,2,0 +31,22,3,32 +32,26,4,33 +33,11,2,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv new file mode 100644 index 00000000000..15d88268d5d --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv @@ -0,0 +1,8 @@ +,vertex,distance +0,1,0.0 +1,4,1.0 +2,2,1.0 +3,6,2.0 +4,7,2.0 +5,5,2.0 +6,3,2.0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv new file mode 100644 index 00000000000..a4adf34daa2 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv @@ -0,0 +1,63 @@ +,vertex,distance +0,1,0 +1,17,1 +2,19,1 +3,26,1 +4,27,1 +5,28,1 +6,36,1 +7,41,1 +8,54,1 +9,6,2 +10,9,2 +11,13,2 +12,22,2 +13,25,2 +14,31,2 +15,57,2 +16,7,2 +17,30,2 +18,8,2 +19,20,2 +20,47,2 +21,23,2 +22,37,2 +23,39,2 +24,40,2 +25,59,2 +26,56,3 +27,5,3 +28,32,3 +29,48,3 +30,42,3 +31,3,3 +32,45,3 +33,16,3 +34,18,3 +35,38,3 +36,44,3 +37,50,3 +38,0,3 +39,10,3 +40,51,3 +41,14,3 +42,21,3 +43,33,3 +44,34,3 +45,43,3 +46,61,3 +47,15,3 +48,52,3 +49,60,4 +50,2,4 +51,24,4 +52,29,4 +53,58,4 +54,4,4 +55,11,4 +56,55,4 +57,12,4 +58,49,4 +59,46,4 +60,53,4 +61,35,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv new file mode 100644 index 00000000000..a4adf34daa2 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv @@ -0,0 +1,63 @@ +,vertex,distance +0,1,0 +1,17,1 +2,19,1 +3,26,1 +4,27,1 +5,28,1 +6,36,1 +7,41,1 +8,54,1 +9,6,2 +10,9,2 +11,13,2 +12,22,2 +13,25,2 +14,31,2 +15,57,2 +16,7,2 +17,30,2 +18,8,2 +19,20,2 +20,47,2 +21,23,2 +22,37,2 +23,39,2 +24,40,2 +25,59,2 +26,56,3 +27,5,3 +28,32,3 +29,48,3 +30,42,3 +31,3,3 +32,45,3 +33,16,3 +34,18,3 +35,38,3 +36,44,3 +37,50,3 +38,0,3 +39,10,3 +40,51,3 +41,14,3 +42,21,3 +43,33,3 +44,34,3 +45,43,3 +46,61,3 +47,15,3 +48,52,3 +49,60,4 +50,2,4 +51,24,4 +52,29,4 +53,58,4 +54,4,4 +55,11,4 +56,55,4 +57,12,4 +58,49,4 +59,46,4 +60,53,4 +61,35,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv new file mode 100644 index 00000000000..d3ce8fd103c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,1,0 +1,0,1 +2,2,1 +3,3,1 +4,7,1 +5,13,1 +6,17,1 +7,19,1 +8,21,1 +9,30,1 +10,4,2 +11,5,2 +12,6,2 +13,8,2 +14,10,2 +15,11,2 +16,12,2 +17,31,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,33,2 +23,16,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv new file mode 100644 index 00000000000..d3ce8fd103c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,1,0 +1,0,1 +2,2,1 +3,3,1 +4,7,1 +5,13,1 +6,17,1 +7,19,1 +8,21,1 +9,30,1 +10,4,2 +11,5,2 +12,6,2 +13,8,2 +14,10,2 +15,11,2 +16,12,2 +17,31,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,33,2 +23,16,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv new file mode 100644 index 00000000000..f2771559775 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv @@ -0,0 +1,106 @@ +,vertex,distance +0,1,0 +1,0,1 +2,3,1 +3,5,1 +4,6,1 +5,2,2 +6,4,2 +7,8,2 +8,9,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,14,2 +14,15,2 +15,16,2 +16,17,2 +17,18,2 +18,19,2 +19,20,2 +20,21,2 +21,22,2 +22,23,2 +23,24,2 +24,25,2 +25,26,2 +26,27,2 +27,7,2 +28,29,2 +29,28,3 +30,30,3 +31,31,3 +32,32,3 +33,33,3 +34,35,3 +35,37,3 +36,40,3 +37,41,3 +38,42,3 +39,43,3 +40,44,3 +41,45,3 +42,46,3 +43,47,3 +44,48,3 +45,49,3 +46,50,3 +47,51,3 +48,52,3 +49,38,3 +50,39,3 +51,55,3 +52,56,3 +53,36,3 +54,54,3 +55,57,3 +56,58,3 +57,77,3 +58,53,3 +59,71,3 +60,85,3 +61,66,4 +62,72,4 +63,67,4 +64,70,4 +65,73,4 +66,74,4 +67,75,4 +68,76,4 +69,79,4 +70,80,4 +71,82,4 +72,83,4 +73,84,4 +74,86,4 +75,93,4 +76,99,4 +77,78,4 +78,91,4 +79,34,4 +80,102,4 +81,64,4 +82,65,4 +83,69,4 +84,68,4 +85,81,4 +86,88,5 +87,89,5 +88,90,5 +89,96,5 +90,97,5 +91,100,5 +92,87,5 +93,92,5 +94,103,5 +95,104,5 +96,94,5 +97,95,5 +98,98,5 +99,60,5 +100,62,5 +101,101,5 +102,61,5 +103,59,5 +104,63,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv new file mode 100644 index 00000000000..f2771559775 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv @@ -0,0 +1,106 @@ +,vertex,distance +0,1,0 +1,0,1 +2,3,1 +3,5,1 +4,6,1 +5,2,2 +6,4,2 +7,8,2 +8,9,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,14,2 +14,15,2 +15,16,2 +16,17,2 +17,18,2 +18,19,2 +19,20,2 +20,21,2 +21,22,2 +22,23,2 +23,24,2 +24,25,2 +25,26,2 +26,27,2 +27,7,2 +28,29,2 +29,28,3 +30,30,3 +31,31,3 +32,32,3 +33,33,3 +34,35,3 +35,37,3 +36,40,3 +37,41,3 +38,42,3 +39,43,3 +40,44,3 +41,45,3 +42,46,3 +43,47,3 +44,48,3 +45,49,3 +46,50,3 +47,51,3 +48,52,3 +49,38,3 +50,39,3 +51,55,3 +52,56,3 +53,36,3 +54,54,3 +55,57,3 +56,58,3 +57,77,3 +58,53,3 +59,71,3 +60,85,3 +61,66,4 +62,72,4 +63,67,4 +64,70,4 +65,73,4 +66,74,4 +67,75,4 +68,76,4 +69,79,4 +70,80,4 +71,82,4 +72,83,4 +73,84,4 +74,86,4 +75,93,4 +76,99,4 +77,78,4 +78,91,4 +79,34,4 +80,102,4 +81,64,4 +82,65,4 +83,69,4 +84,68,4 +85,81,4 +86,88,5 +87,89,5 +88,90,5 +89,96,5 +90,97,5 +91,100,5 +92,87,5 +93,92,5 +94,103,5 +95,104,5 +96,94,5 +97,95,5 +98,98,5 +99,60,5 +100,62,5 +101,101,5 +102,61,5 +103,59,5 +104,63,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..a5146501cd9 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv @@ -0,0 +1,8 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..a5146501cd9 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv @@ -0,0 +1,8 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..f0105fbeebb --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv @@ -0,0 +1,6 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..f0105fbeebb --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv @@ -0,0 +1,6 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..cc0d15c1b90 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv @@ -0,0 +1,5 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..cc0d15c1b90 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv @@ -0,0 +1,5 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..1395a419102 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv @@ -0,0 +1,63 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 +7,0,2 +8,3,2 +9,24,2 +10,34,2 +11,40,2 +12,43,2 +13,52,2 +14,8,2 +15,18,2 +16,28,2 +17,36,2 +18,44,2 +19,47,2 +20,12,2 +21,21,2 +22,45,2 +23,61,2 +24,58,2 +25,42,2 +26,51,2 +27,10,3 +28,15,3 +29,59,3 +30,29,3 +31,49,3 +32,7,3 +33,46,3 +34,53,3 +35,1,3 +36,30,3 +37,23,3 +38,39,3 +39,2,3 +40,4,3 +41,11,3 +42,55,3 +43,35,4 +44,19,4 +45,27,4 +46,54,4 +47,17,4 +48,26,4 +49,41,4 +50,57,4 +51,25,5 +52,6,5 +53,13,5 +54,9,5 +55,22,5 +56,31,5 +57,5,5 +58,48,5 +59,56,6 +60,32,6 +61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..1395a419102 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv @@ -0,0 +1,63 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 +7,0,2 +8,3,2 +9,24,2 +10,34,2 +11,40,2 +12,43,2 +13,52,2 +14,8,2 +15,18,2 +16,28,2 +17,36,2 +18,44,2 +19,47,2 +20,12,2 +21,21,2 +22,45,2 +23,61,2 +24,58,2 +25,42,2 +26,51,2 +27,10,3 +28,15,3 +29,59,3 +30,29,3 +31,49,3 +32,7,3 +33,46,3 +34,53,3 +35,1,3 +36,30,3 +37,23,3 +38,39,3 +39,2,3 +40,4,3 +41,11,3 +42,55,3 +43,35,4 +44,19,4 +45,27,4 +46,54,4 +47,17,4 +48,26,4 +49,41,4 +50,57,4 +51,25,5 +52,6,5 +53,13,5 +54,9,5 +55,22,5 +56,31,5 +57,5,5 +58,48,5 +59,56,6 +60,32,6 +61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..2240fd7b022 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 +5,4,2 +6,5,2 +7,6,2 +8,8,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,17,2 +14,19,2 +15,21,2 +16,31,2 +17,30,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,16,3 +23,33,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..2240fd7b022 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 +5,4,2 +6,5,2 +7,6,2 +8,8,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,17,2 +14,19,2 +15,21,2 +16,31,2 +17,30,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,16,3 +23,33,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..a46f001b4ea --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 +4,2,2 +5,3,2 +6,4,2 +7,5,2 +8,6,2 +9,7,2 +10,8,2 +11,10,2 +12,11,2 +13,12,2 +14,13,2 +15,17,2 +16,21,2 +17,31,2 +18,30,2 +19,9,2 +20,14,2 +21,15,2 +22,18,2 +23,20,2 +24,22,2 +25,23,2 +26,26,2 +27,27,2 +28,28,2 +29,29,2 +30,32,2 +31,16,3 +32,24,3 +33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..a46f001b4ea --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 +4,2,2 +5,3,2 +6,4,2 +7,5,2 +8,6,2 +9,7,2 +10,8,2 +11,10,2 +12,11,2 +13,12,2 +14,13,2 +15,17,2 +16,21,2 +17,31,2 +18,30,2 +19,9,2 +20,14,2 +21,15,2 +22,18,2 +23,20,2 +24,22,2 +25,23,2 +26,26,2 +27,27,2 +28,28,2 +29,29,2 +30,32,2 +31,16,3 +32,24,3 +33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..733866596fb --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv @@ -0,0 +1,60 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 +7,0,2 +8,3,2 +9,24,2 +10,34,2 +11,40,2 +12,43,2 +13,52,2 +14,8,2 +15,18,2 +16,28,2 +17,36,2 +18,44,2 +19,47,2 +20,12,2 +21,21,2 +22,45,2 +23,61,2 +24,58,2 +25,42,2 +26,51,2 +27,10,3 +28,15,3 +29,59,3 +30,29,3 +31,49,3 +32,7,3 +33,46,3 +34,53,3 +35,1,3 +36,30,3 +37,23,3 +38,39,3 +39,2,3 +40,4,3 +41,11,3 +42,55,3 +43,35,4 +44,19,4 +45,27,4 +46,54,4 +47,17,4 +48,26,4 +49,41,4 +50,57,4 +51,25,5 +52,6,5 +53,13,5 +54,9,5 +55,22,5 +56,31,5 +57,5,5 +58,48,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..733866596fb --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv @@ -0,0 +1,60 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 +7,0,2 +8,3,2 +9,24,2 +10,34,2 +11,40,2 +12,43,2 +13,52,2 +14,8,2 +15,18,2 +16,28,2 +17,36,2 +18,44,2 +19,47,2 +20,12,2 +21,21,2 +22,45,2 +23,61,2 +24,58,2 +25,42,2 +26,51,2 +27,10,3 +28,15,3 +29,59,3 +30,29,3 +31,49,3 +32,7,3 +33,46,3 +34,53,3 +35,1,3 +36,30,3 +37,23,3 +38,39,3 +39,2,3 +40,4,3 +41,11,3 +42,55,3 +43,35,4 +44,19,4 +45,27,4 +46,54,4 +47,17,4 +48,26,4 +49,41,4 +50,57,4 +51,25,5 +52,6,5 +53,13,5 +54,9,5 +55,22,5 +56,31,5 +57,5,5 +58,48,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..2240fd7b022 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 +5,4,2 +6,5,2 +7,6,2 +8,8,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,17,2 +14,19,2 +15,21,2 +16,31,2 +17,30,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,16,3 +23,33,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..2240fd7b022 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 +5,4,2 +6,5,2 +7,6,2 +8,8,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,17,2 +14,19,2 +15,21,2 +16,31,2 +17,30,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,16,3 +23,33,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..a46f001b4ea --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 +4,2,2 +5,3,2 +6,4,2 +7,5,2 +8,6,2 +9,7,2 +10,8,2 +11,10,2 +12,11,2 +13,12,2 +14,13,2 +15,17,2 +16,21,2 +17,31,2 +18,30,2 +19,9,2 +20,14,2 +21,15,2 +22,18,2 +23,20,2 +24,22,2 +25,23,2 +26,26,2 +27,27,2 +28,28,2 +29,29,2 +30,32,2 +31,16,3 +32,24,3 +33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..a46f001b4ea --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 +4,2,2 +5,3,2 +6,4,2 +7,5,2 +8,6,2 +9,7,2 +10,8,2 +11,10,2 +12,11,2 +13,12,2 +14,13,2 +15,17,2 +16,21,2 +17,31,2 +18,30,2 +19,9,2 +20,14,2 +21,15,2 +22,18,2 +23,20,2 +24,22,2 +25,23,2 +26,26,2 +27,27,2 +28,28,2 +29,29,2 +30,32,2 +31,16,3 +32,24,3 +33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..1395a419102 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv @@ -0,0 +1,63 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 +7,0,2 +8,3,2 +9,24,2 +10,34,2 +11,40,2 +12,43,2 +13,52,2 +14,8,2 +15,18,2 +16,28,2 +17,36,2 +18,44,2 +19,47,2 +20,12,2 +21,21,2 +22,45,2 +23,61,2 +24,58,2 +25,42,2 +26,51,2 +27,10,3 +28,15,3 +29,59,3 +30,29,3 +31,49,3 +32,7,3 +33,46,3 +34,53,3 +35,1,3 +36,30,3 +37,23,3 +38,39,3 +39,2,3 +40,4,3 +41,11,3 +42,55,3 +43,35,4 +44,19,4 +45,27,4 +46,54,4 +47,17,4 +48,26,4 +49,41,4 +50,57,4 +51,25,5 +52,6,5 +53,13,5 +54,9,5 +55,22,5 +56,31,5 +57,5,5 +58,48,5 +59,56,6 +60,32,6 +61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv new file mode 100644 index 00000000000..1395a419102 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv @@ -0,0 +1,63 @@ +,vertex,distance +0,16,0 +1,14,1 +2,20,1 +3,33,1 +4,37,1 +5,38,1 +6,50,1 +7,0,2 +8,3,2 +9,24,2 +10,34,2 +11,40,2 +12,43,2 +13,52,2 +14,8,2 +15,18,2 +16,28,2 +17,36,2 +18,44,2 +19,47,2 +20,12,2 +21,21,2 +22,45,2 +23,61,2 +24,58,2 +25,42,2 +26,51,2 +27,10,3 +28,15,3 +29,59,3 +30,29,3 +31,49,3 +32,7,3 +33,46,3 +34,53,3 +35,1,3 +36,30,3 +37,23,3 +38,39,3 +39,2,3 +40,4,3 +41,11,3 +42,55,3 +43,35,4 +44,19,4 +45,27,4 +46,54,4 +47,17,4 +48,26,4 +49,41,4 +50,57,4 +51,25,5 +52,6,5 +53,13,5 +54,9,5 +55,22,5 +56,31,5 +57,5,5 +58,48,5 +59,56,6 +60,32,6 +61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..2240fd7b022 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 +5,4,2 +6,5,2 +7,6,2 +8,8,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,17,2 +14,19,2 +15,21,2 +16,31,2 +17,30,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,16,3 +23,33,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv new file mode 100644 index 00000000000..2240fd7b022 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,7,0 +1,0,1 +2,1,1 +3,2,1 +4,3,1 +5,4,2 +6,5,2 +7,6,2 +8,8,2 +9,10,2 +10,11,2 +11,12,2 +12,13,2 +13,17,2 +14,19,2 +15,21,2 +16,31,2 +17,30,2 +18,9,2 +19,27,2 +20,28,2 +21,32,2 +22,16,3 +23,33,3 +24,24,3 +25,25,3 +26,23,3 +27,14,3 +28,15,3 +29,18,3 +30,20,3 +31,22,3 +32,29,3 +33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..a46f001b4ea --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 +4,2,2 +5,3,2 +6,4,2 +7,5,2 +8,6,2 +9,7,2 +10,8,2 +11,10,2 +12,11,2 +13,12,2 +14,13,2 +15,17,2 +16,21,2 +17,31,2 +18,30,2 +19,9,2 +20,14,2 +21,15,2 +22,18,2 +23,20,2 +24,22,2 +25,23,2 +26,26,2 +27,27,2 +28,28,2 +29,29,2 +30,32,2 +31,16,3 +32,24,3 +33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv new file mode 100644 index 00000000000..a46f001b4ea --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv @@ -0,0 +1,35 @@ +,vertex,distance +0,19,0 +1,0,1 +2,1,1 +3,33,1 +4,2,2 +5,3,2 +6,4,2 +7,5,2 +8,6,2 +9,7,2 +10,8,2 +11,10,2 +12,11,2 +13,12,2 +14,13,2 +15,17,2 +16,21,2 +17,31,2 +18,30,2 +19,9,2 +20,14,2 +21,15,2 +22,18,2 +23,20,2 +24,22,2 +25,23,2 +26,26,2 +27,27,2 +28,28,2 +29,29,2 +30,32,2 +31,16,3 +32,24,3 +33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv new file mode 100644 index 00000000000..b35d461bbe6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv @@ -0,0 +1,3 @@ +,vertex,distance +0,1237,0 +1,1238,1 diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index ec3a9705095..dcd2e795c76 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -36,7 +36,10 @@ from cugraph.testing import utils default_results_upload_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" +alt_results_dir = Path("testing/nxresults") +# This script is intended to generate all results for each of the corresponding results files. +# Currently, its location is in testing, but that won't be the final location # ============================================================================= # Parameters # ============================================================================= @@ -56,7 +59,7 @@ # tests/traversal/test_bfs.py # ============================================================================= test_bfs_results = {} -test_bfs_starts = {} + for ds in DATASETS + [karate]: for seed in SEEDS: @@ -203,21 +206,27 @@ ] = "ValueError" # test_shortest_path_length_no_target -test_paths_results["1,notarget,nx"] = nx.shortest_path_length( - Gnx_DIS, source="1", weight="weight" -) -test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length(Gnx_DIS, "1") +res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") +test_paths_results["1,notarget,nx"] = res1 +# res1 = cudf.DataFrame.from_dict(res1, orient="index") +# res1.to_csv(alt_results_dir / "nx/shortest_path_length/DISCONNECTEDnx/1.csv", index=True) + +res2 = cugraph.shortest_path_length(Gnx_DIS, "1") +test_paths_results["1,notarget,cu"] = res2 +# res2.to_csv(alt_results_dir / "cugraph/shortest_path_length/DISCONNECTEDnx/1.csv", index=False) # serial_bfs_results = pickle.dumps(test_bfs_results) # serial_sssp_results = pickle.dumps(test_sssp_results) # serial_paths_results = pickle.dumps(test_paths_results) +# One way of generating pkl files (NOW OUTDATED) # pickle.dump(test_bfs_results, open("testing/bfs_results.pkl", "wb")) # pickle.dump(test_sssp_results, open("testing/sssp_results.pkl", "wb")) # pickle.dump(test_paths_results, open("testing/paths_results.pkl", "wb")) -pickle.dump( +# Another way of generating pkl files (NOW OUTDATED) +"""pickle.dump( test_bfs_results, open(default_results_upload_dir / "bfs_results.pkl", "wb") ) pickle.dump( @@ -225,16 +234,15 @@ ) pickle.dump( test_paths_results, open(default_results_upload_dir / "paths_results.pkl", "wb") -) +)""" # Example of how ResultSet is used in each individual testing script # my_bfs_results = ResultSet(local_result_file="bfs_results.pkl") # my_sssp_results = ResultSet(local_result_file="sssp_results.pkl") # my_paths_results = ResultSet(local_result_file="paths_results.pkl") - # GETTERS (these are now unused and ready to be gone) -def get_bfs_results(test_params): +"""def get_bfs_results(test_params): return test_bfs_results[test_params] @@ -243,4 +251,4 @@ def get_sssp_results(test_params): def get_paths_results(test_params): - return test_paths_results[test_params] + return test_paths_results[test_params]""" diff --git a/python/cugraph/cugraph/testing/resultset_2308.py b/python/cugraph/cugraph/testing/resultset_2308.py new file mode 100644 index 00000000000..ffc2fad029d --- /dev/null +++ b/python/cugraph/cugraph/testing/resultset_2308.py @@ -0,0 +1,263 @@ +# Copyright (c) 2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from tempfile import NamedTemporaryFile +import random +import os +from pathlib import Path + +# import json +import pickle + +import numpy as np + +import cudf +import networkx as nx +import cugraph +from cugraph.experimental.datasets import ( + dolphins, + netscience, + karate_disjoint, + karate, + polbooks, +) +from cugraph.testing import utils + +results_dir = Path("testing/results") + +class ResultSet: + def __init__(self, data_dictionary): + self._data_dictionary = data_dictionary + + def get_cudf_dataframe(self): + # THIS IS CALLED IN RESULTS GENERATION BEFORE WRITING ALL RESULTS TO FILES + # cu algs on nx input (dict) + # nx algs on nx input (dict, but requires renaming,tweaking) + return cudf.DataFrame(self._data_dictionary) + +_resultsets = {} + +def add_resultset(result_data_dictionary, **kwargs): + rs = ResultSet(result_data_dictionary) + hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) + _resultsets[hashable_dict_repr] = rs + +def get_resultset(**kwargs): + # THIS IS CALLED IN TESTS + hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) + return _resultsets.get(hashable_dict_repr) + +def get_resultset_dev(**kwargs): + hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) + resultset_path = results_dir / (str(hashable_dict_repr) + ".csv") + return cudf.read_csv(resultset_path) + +""" +def get_resultset(**kwargs): + hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) + desired = results_dir / (str(hashable_dict_repr) + ".csv") + return cudf.read_csv(desired) +""" + + + +# ============================================================================= +# Parameters +# ============================================================================= +# This will be refactored once the datasets variables are fixed/changed +SEEDS = [42] + +DIRECTED_GRAPH_OPTIONS = [True, False] + +DEPTH_LIMITS = [None, 1, 5, 18] + +DATASETS = [dolphins, netscience, karate_disjoint] + +DATASETS_SMALL = [karate, dolphins, polbooks] + +# ============================================================================= +# tests/traversal/test_bfs.py +# ============================================================================= +test_bfs_results = {} + +for ds in DATASETS + [karate]: + for seed in SEEDS: + for depth_limit in DEPTH_LIMITS: + for dirctd in DIRECTED_GRAPH_OPTIONS: + # this does the work of get_cu_graph_nx_results_and_params + Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=dirctd) + random.seed(seed) + start_vertex = random.sample(list(Gnx.nodes()), 1)[0] + nx_values = nx.single_source_shortest_path_length( + Gnx, start_vertex, cutoff=depth_limit + ) + test_bfs_results[ + "{},{},{},{},{}".format(seed, depth_limit, ds, dirctd, start_vertex) + ] = nx_values + vertices = cudf.Series(nx_values.keys()) + distances = cudf.Series(nx_values.values()) + add_resultset({"vertex": vertices, "distance": distances}, + graph_dataset=ds.metadata["name"], + graph_directed=dirctd, + algo="nx.single_source_shortest_path_length", + start_vertex=start_vertex, + cutoff=depth_limit) + # prob don't need to store in resultset + # test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex + +# these are pandas dataframes +for dirctd in DIRECTED_GRAPH_OPTIONS: + Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) + result = cugraph.bfs_edges(Gnx, source=7) + cugraph_df = cudf.from_pandas(result) + test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df + add_resultset(cugraph_df, + graph_dataset="karate", + graph_directed=dirctd, + algo="nx.bfs_edges", + source=7) + + +# ============================================================================= +# tests/traversal/test_sssp.py +# ============================================================================= +test_sssp_results = {} + +SOURCES = [1] + +for ds in DATASETS_SMALL: + for source in SOURCES: + Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) + nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths + vertices = cudf.Series(nx_paths.keys()) + distances = cudf.Series(nx_paths.values()) + add_resultset({"vertex": vertices, "distance": distances}, + graph_dataset=ds.metadata["name"], + graph_directed=True, + algo="nx.single_source_dijkstra_path_length", + source=source) + + M = utils.read_csv_for_nx(ds.get_path(), read_weights_in_sp=True) + edge_attr = "weight" + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr=edge_attr, + create_using=nx.DiGraph(), + ) + + M["weight"] = M["weight"].astype(np.int32) + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr="weight", + create_using=nx.DiGraph(), + ) + nx_paths_datatypeconv = nx.single_source_dijkstra_path_length(Gnx, source) + test_sssp_results[ + "nx_paths,data_type_conversion,{}".format(ds) + ] = nx_paths_datatypeconv + vertices_datatypeconv = cudf.Series(nx_paths_datatypeconv.keys()) + distances_datatypeconv = cudf.Series(nx_paths_datatypeconv.values()) + add_resultset({"vertex": vertices_datatypeconv, "distance": distances_datatypeconv}, + graph_dataset=ds.metadata["name"], + graph_directed=True, + algo="nx.single_source_dijkstra_path_length", + test="data_type_conversion", + source=source) + +for dirctd in DIRECTED_GRAPH_OPTIONS: + for source in SOURCES: + Gnx = utils.generate_nx_graph_from_file( + karate.get_path(), directed=dirctd, edgevals=True + ) + if dirctd: + test_sssp_results[ + "nonnative_input,nx.DiGraph,{}".format(source) + ] = cugraph.sssp(Gnx, source) + else: + test_sssp_results[ + "nonnative_input,nx.Graph,{}".format(source) + ] = cugraph.sssp(Gnx, source) + add_resultset(cugraph.sssp(Gnx, source), + graph_dataset="karate", + graph_directed=dirctd, + algo="cu.sssp_nonnative", + source=source) + +G = nx.Graph() +G.add_edge(0, 1, other=10) +G.add_edge(1, 2, other=20) +df = cugraph.sssp(G, 0, edge_attr="other") +test_sssp_results["network_edge_attr"] = df +add_resultset(df, + algo="cu.sssp_nonnative", + test="network_edge_attr") + +# ============================================================================= +# tests/traversal/test_paths.py +# ============================================================================= +CONNECTED_GRAPH = """1,5,3 +1,4,1 +1,2,1 +1,6,2 +1,7,2 +4,5,1 +2,3,1 +7,6,2 +""" + +DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" + +paths = [("1", "1"), ("1", "5"), ("1", "3"), ("1", "6")] +invalid_paths = { + "connected": [("-1", "1"), ("0", "42")], + "disconnected": [("1", "10"), ("1", "8")], +} + +test_paths_results = {} + +# CONNECTED_GRAPH +with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: + graph_tf.writelines(DISCONNECTED_GRAPH) + graph_tf.seek(0) + Gnx_DIS = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") + +res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") +test_paths_results["1,notarget,nx"] = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") +vertices = cudf.Series(res1.keys()) +distances = cudf.Series(res1.values()) +add_resultset({"vertex": vertices, "distance": distances}, + algo="nx.shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight") + +res2 = cugraph.shortest_path_length(Gnx_DIS, "1") +test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length(Gnx_DIS, "1") +add_resultset(res2, + algo="cu.shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight") + +# Generating ALL results files +for temp in _resultsets: + res = _resultsets[temp].get_cudf_dataframe() + res.to_csv(results_dir / (str(temp) + ".csv")) + print(temp) \ No newline at end of file diff --git a/python/cugraph/cugraph/testing/resultset_pr.py b/python/cugraph/cugraph/testing/resultset_pr.py new file mode 100644 index 00000000000..6f76e13bf06 --- /dev/null +++ b/python/cugraph/cugraph/testing/resultset_pr.py @@ -0,0 +1,55 @@ +from pathlib import Path + +# from cugraph.experimental.datasets import karate +import cudf +# import networkx as nx +import os + +class Resultset: + def __init__(self, data_dictionary): + self._data_dictionary = data_dictionary + + def get_cudf_dataframe(self): + return cudf.DataFrame(self._data_dictionary) + +_resultsets = {} + +results_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) +results_dir = Path("testing/results") + +def add_resultset(result_data_dictionary, **kwargs): + rs = Resultset(result_data_dictionary) + hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) + _resultsets[hashable_dict_repr] = rs + +def get_resultset(**kwargs): + hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) + desired = results_dir / (str(hashable_dict_repr) + ".csv") + return cudf.read_csv(desired) + + +results_dir = Path("testing/results") + +# Example Code +################################################################################ +# Populate with results from running pagerank on karate over all combinations +# of the values for alpha and max_iter below. +"""pdf = karate.get_edgelist().to_pandas().rename(columns={"src": "source", + "dst": "target"}) +Gnx = nx.from_pandas_edgelist(pdf) + +alpha_values = [0.6, 0.75, 0.85] +max_iter_values = [50, 75, 100] + +for alpha in alpha_values: + for max_iter in max_iter_values: + print(f"pagerank: {alpha=}, {max_iter=}") + results = nx.pagerank(Gnx, alpha=alpha, max_iter=max_iter) + (vertices, pageranks) = zip(*results.items()) + add_resultset({"vertex": vertices, "pagerank": pageranks}, + graph_dataset="karate", + graph_directed=False, + algo="pagerank", + alpha=alpha, + max_iter=max_iter) +""" diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index ef69be35072..87c6e797f77 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -430,19 +430,17 @@ def compare_mst(mst_cugraph, mst_nx): ) +""" class ResultSet: - """ - A Resultset Object, which imports output data from networkX algs or cuGraph algs - with networkX inputs. This is to be used in the testing module, as to fully remove - nx as a dependency. - Parameters - ---------- - local_file_name : str - The string path for the pickled results file, stored locally somewhere. - cloud_file_name : str - The string path for the pickled results file, stored on the cloud. (s3) - """ - + # A Resultset Object, which imports output data from networkX algs or cuGraph algs + # with networkX inputs. This is to be used in the testing module, as to fully remove + # nx as a dependency. + # Parameters + # ---------- + # local_file_name : str + # The string path for the pickled results file, stored locally somewhere. + # cloud_file_name : str + # The string path for the pickled results file, stored on the cloud. (s3) # unsure about naming of 'cloud_result_file' def __init__(self, local_result_file=None, cloud_result_file=None): self._path = None @@ -457,32 +455,40 @@ def __init__(self, local_result_file=None, cloud_result_file=None): # self._path=Path("https://data.rapids.ai/cugraph/tsting/"+cloud_result_file) # not right syntax but the overall process would be similar to below: vv elif local_result_file is not None: - self._path = default_results_download_dir / local_result_file + # self._path = default_results_download_dir / local_result_file # breakpoint() + self._path = Path("testing") / local_result_file if self._path.exists() is False: # try to load results, if file doesn't exist raise pref. RuntimeError raise FileNotFoundError(local_result_file) else: - with open( - default_results_download_dir / local_result_file, "rb" - ) as file: + # with open( + # default_results_download_dir / local_result_file, "rb" + # ) as file: + # with open("testing/" + local_result_file, "rb") as file: + with open(self._path, "rb") as file: self.results = pickle.load(file) else: raise ValueError( "must specify either local_result_file or cloud_result_file" ) +""" -def load_all_results(force=False): - """ - Fetches all pickled results files from s3 bucket, stores them locally..somewhere - Parameters - force : Boolean (default=False) - Overwrite any existing copies of datafiles - """ - raise NotImplementedError("results files are not yet on cloud bucket") +""" +class ResultSet: + # A Resultset Object which imports output data from networkX algs or cuGraph algs + # with networkX inputs. This will eventually remove nx as a dependency. + def __init__(self, lib=None, alg=None, graph=None, params=None): + self._path = None + if lib is not None: + self._path = Path(Path("testing/nxresults") / lib / alg / graph / params).with_suffix(".csv") + if self._path.exists() is False: + raise FileNotFoundError(self._path) + else: + self.results = cudf.read_csv(self._path) -# Example of intended behavior: -# bfs_results = ResultSet("bfs_results.pkl") -# bfs_results["1,nonnative-nx"] + else: + raise ValueError("must specify result_file") +""" diff --git a/python/cugraph/cugraph/tests/traversal/BLUEPRINT.py b/python/cugraph/cugraph/tests/traversal/BLUEPRINT.py new file mode 100644 index 00000000000..cab1eaf82ac --- /dev/null +++ b/python/cugraph/cugraph/tests/traversal/BLUEPRINT.py @@ -0,0 +1,50 @@ +import pytest + +import cugraph +from python.cugraph.cugraph.testing.resultset_pr import get_resultset +from cudf.testing import assert_frame_equal + +karate_test_data = [ + [0.6, 50, get_resultset], + [0.6, 75, get_resultset], + [0.6, 100, get_resultset], + [0.6, -100, OverflowError], + [0.75, 50, get_resultset], + [0.75, 75, get_resultset], + [0.75, 100, get_resultset], + [0.85, 50, get_resultset], + [0.85, 75, get_resultset], + [0.85, 100, get_resultset], +] + +@pytest.fixture(params=[pytest.param(p) for p in karate_test_data]) +def test_data(request): + alpha, max_iter, expected_result = request.param + breakpoint() + if (type(expected_result) != type) and callable(expected_result): + expected_result = expected_result(graph_dataset="karate", + graph_directed=False, + algo="pagerank", + alpha=alpha, + max_iter=max_iter).get_cudf_dataframe() + return (alpha, max_iter, expected_result) + + +######################################## +def test_pagerank(test_data): + (alpha, max_iter, expected_result) = test_data + G = cugraph.experimental.datasets.karate.get_graph() + + if (type(expected_result) == type) and issubclass(expected_result, Exception): + with pytest.raises(expected_result): + cugraph.pagerank(G, alpha=alpha, max_iter=max_iter) + else: + pr = cugraph.pagerank(G, alpha=alpha, max_iter=max_iter) + pr = pr.sort_values("vertex", ignore_index=True) + expected_result = expected_result.sort_values("vertex", ignore_index=True) + expected_result["pagerank"] = expected_result["pagerank"].astype("float32") + assert_frame_equal(pr, + expected_result, + check_like=True, + check_dtype=False, + atol=1e-2) \ No newline at end of file diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs.py b/python/cugraph/cugraph/tests/traversal/test_bfs_current.py similarity index 93% rename from python/cugraph/cugraph/tests/traversal/test_bfs.py rename to python/cugraph/cugraph/tests/traversal/test_bfs_current.py index 5d5ea8ffcc2..44135b5d144 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs_current.py @@ -28,7 +28,7 @@ from pylibcugraph.testing.utils import gen_fixture_params_product import cugraph -from cugraph.testing import utils, ResultSet +from cugraph.testing import utils, resultset_pr from cugraph.experimental import datasets @@ -39,6 +39,8 @@ SUBSET_SEED_OPTIONS = [42] +DATASET_STARTS = {"dolphins": 16, "karate": 7, "karate-disjoint": 19, "netscience": 1237} + DEFAULT_EPSILON = 1e-6 DEPTH_LIMITS = [None, 1, 5, 18] @@ -56,8 +58,6 @@ } cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] -bfs_results = ResultSet(local_result_file="bfs_results.pkl") - # ============================================================================= # Pytest Setup / Teardown - called for each test function @@ -145,6 +145,7 @@ def compare_bfs(benchmark_callable, G, nx_values, start_vertex, depth_limit): """ Generate both cugraph and reference bfs traversal. """ + if isinstance(start_vertex, int): result = benchmark_callable(cugraph.bfs_edges, G, start_vertex) cugraph_df = convert_output_to_cudf(G, result) @@ -207,7 +208,6 @@ def _compare_bfs(cugraph_df, nx_distances, source): # We assume that the distances are given back as integers in BFS # max_val = np.iinfo(df['distance'].dtype).max # Unreached vertices have a distance of max_val - missing_vertex_error = 0 distance_mismatch_error = 0 invalid_predecessor_error = 0 @@ -261,15 +261,15 @@ def get_cu_graph_nx_results_and_params( """ Helper for fixtures returning Nx results and params. """ - # start_vertex = get_bfs_results("{},{},starts".format(seed, dataset_name)) - start_vertex = bfs_results.results["{},{},starts".format(seed, dataset_name)] + start_vertex = DATASET_STARTS[dataset_name] - # nx_values = get_bfs_results( - # "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) - # ) - nx_values = bfs_results.results[ - "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) - ] + nx_values = resultset_pr.get_resultset(algo='nx.single_source_shortest_path_length', + cutoff=depth_limit, + graph_dataset=dataset_name, + graph_directed=directed, + start_vertex=start_vertex) + nx_values = nx_values.drop(columns="Unnamed: 0") + nx_values = cudf.Series(nx_values.distance.values, index=nx_values.vertex).to_dict() return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) @@ -404,11 +404,11 @@ def test_bfs_nonnative_inputs_matrix( ): test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) +#@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) @pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) def test_bfs_nonnative_inputs_nx( - gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type + gpubenchmark, single_dataset_nxresults_startvertex_spc, ): ( _, @@ -419,9 +419,12 @@ def test_bfs_nonnative_inputs_nx( _, ) = single_dataset_nxresults_startvertex_spc - cugraph_df = bfs_results.results[ - "{},{},{}".format("karate", directed, "nonnative-nx") - ] + cugraph_df = resultset_pr.get_resultset(algo='nx.bfs_edges', + graph_dataset='karate', + graph_directed=directed, + source=start_vertex) + cugraph_df = cugraph_df.drop(columns="Unnamed: 0") + compare_func = _compare_bfs compare_func(cugraph_df, nx_values, start_vertex) diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_old.py b/python/cugraph/cugraph/tests/traversal/test_bfs_old.py index 7446b32ee5d..53e72d78d21 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs_old.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs_old.py @@ -12,10 +12,10 @@ # limitations under the License. import gc -import random + +# import random import pytest -import pandas as pd import cupy as cp import numpy as np from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix @@ -28,21 +28,9 @@ from pylibcugraph.testing.utils import gen_fixture_params_product import cugraph -from cugraph.testing import utils +from cugraph.testing import utils, ResultSet from cugraph.experimental import datasets -# Temporarily suppress warnings till networkX fixes deprecation warnings -# (Using or importing the ABCs from 'collections' instead of from -# 'collections.abc' is deprecated, and in 3.8 it will stop working) for -# python 3.7. Also, this import networkx needs to be relocated in the -# third-party group once this gets fixed. -import warnings - -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - import networkx as nx - import networkx.algorithms.centrality.betweenness as nxacb - # ============================================================================= # Parameters @@ -59,8 +47,6 @@ # connected_components calls. cuGraph_input_output_map = { cugraph.Graph: cudf.DataFrame, - nx.Graph: pd.DataFrame, - nx.DiGraph: pd.DataFrame, cp_coo_matrix: tuple, cp_csr_matrix: tuple, cp_csc_matrix: tuple, @@ -70,6 +56,14 @@ } cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] +bfs_results = ResultSet(local_result_file="bfs_results.pkl") + +bfs_results2 = {'42,dolphins,starts': 16, '42,netscience,starts': 1237, + '42,karate-disjoint,starts': 19, '42,karate,starts': 7} +# Dicts that need to be converted to cudf.df then to csv: +# '42,None,dolphins,True', '42,None,dolphins,False', '42,1,dolphins,True', '42,1,dolphins,False', '42,5,dolphins,True', '42,5,dolphins,False', '42,18,dolphins,True', '42,18,dolphins,False', '42,dolphins,starts', '42,None,netscience,True', '42,None,netscience,False', '42,1,netscience,True', '42,1,netscience,False', '42,5,netscience,True', '42,5,netscience,False', '42,18,netscience,True', '42,18,netscience,False', '42,netscience,starts', '42,None,karate-disjoint,True', '42,None,karate-disjoint,False', '42,1,karate-disjoint,True', '42,1,karate-disjoint,False', '42,5,karate-disjoint,True', '42,5,karate-disjoint,False', '42,18,karate-disjoint,True', '42,18,karate-disjoint,False', '42,karate-disjoint,starts', '42,None,karate,True', '42,None,karate,False', '42,1,karate,True', '42,1,karate,False', '42,5,karate,True', '42,5,karate,False', '42,18,karate,True', '42,18,karate,False', '42,karate,starts' +# Can be converted to csv easily: +# 'karate,True,nonnative-nx', 'karate,False,nonnative-nx' # ============================================================================= # Pytest Setup / Teardown - called for each test function @@ -94,8 +88,8 @@ def convert_output_to_cudf(input_G_or_matrix, cugraph_result): if expected_return_type is cudf.DataFrame: return cugraph_result - elif expected_return_type is pd.DataFrame: - return cudf.from_pandas(cugraph_result) + # elif expected_return_type is pd.DataFrame: + # return cudf.from_pandas(cugraph_result) # A CuPy/SciPy input means the return value will be a 2-tuple of: # distance: cupy.ndarray @@ -155,7 +149,7 @@ def compare_single_sp_counter(result, expected, epsilon=DEFAULT_EPSILON): def compare_bfs(benchmark_callable, G, nx_values, start_vertex, depth_limit): """ - Genereate both cugraph and reference bfs traversal. + Generate both cugraph and reference bfs traversal. """ if isinstance(start_vertex, int): result = benchmark_callable(cugraph.bfs_edges, G, start_vertex) @@ -256,34 +250,34 @@ def _compare_bfs(cugraph_df, nx_distances, source): assert invalid_predecessor_error == 0, "There are invalid predecessors" -def get_cu_graph_nx_graph_and_params(dataset, directed): +def get_cu_graph_and_params(dataset, directed): """ - Helper for fixtures returning a Nx graph obj and params. + Helper for fixtures returning a cuGraph obj and params. """ # create graph G = dataset.get_graph(create_using=cugraph.Graph(directed=directed)) dataset_path = dataset.get_path() - - return ( - G, - dataset_path, - directed, - utils.generate_nx_graph_from_file(dataset_path, directed), - ) + dataset_name = dataset.metadata["name"] + return (G, dataset_path, dataset_name, directed) -def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, Gnx): +def get_cu_graph_nx_results_and_params( + seed, depth_limit, G, dataset_path, dataset_name, directed +): """ Helper for fixtures returning Nx results and params. """ - random.seed(seed) - start_vertex = random.sample(list(Gnx.nodes()), 1)[0] + # start_vertex = get_bfs_results("{},{},starts".format(seed, dataset_name)) + start_vertex = bfs_results.results["{},{},starts".format(seed, dataset_name)] - nx_values = nx.single_source_shortest_path_length( - Gnx, start_vertex, cutoff=depth_limit - ) + # nx_values = get_bfs_results( + # "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) + # ) + nx_values = bfs_results.results[ + "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) + ] - return (G, dataset, directed, nx_values, start_vertex, depth_limit) + return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) # ============================================================================= @@ -312,6 +306,7 @@ def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd") ) + # The single param list variants are used when only 1 param combination is # needed (eg. testing non-native input types where tests for other combinations # was covered elsewhere). @@ -328,18 +323,18 @@ def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, # combination. These return the path to the dataset, a bool indicating if a # directed graph is being used, and the Nx graph object. @pytest.fixture(scope="module", params=graph_fixture_params) -def dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) +def dataset_nx_results(request): + return get_cu_graph_and_params(*request.param) @pytest.fixture(scope="module", params=small_graph_fixture_params) -def small_dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) +def small_dataset_nx_results(request): + return get_cu_graph_and_params(*request.param) @pytest.fixture(scope="module", params=single_small_graph_fixture_params) -def single_small_dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) +def single_small_dataset_nx_results(request): + return get_cu_graph_and_params(*request.param) # Fixtures that result in a test-per (dataset_nx_graph combinations X algo_test @@ -348,21 +343,21 @@ def single_small_dataset_nx_graph(request): # results, the starting vertex for BFS, and flag if shortes path counting was # used. @pytest.fixture(scope="module", params=algo_test_fixture_params) -def dataset_nxresults_startvertex_spc(dataset_nx_graph, request): - return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_graph) +def dataset_nxresults_startvertex_spc(dataset_nx_results, request): + return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_results) @pytest.fixture(scope="module", params=single_algo_test_fixture_params) -def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_graph, request): +def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_results, request): return get_cu_graph_nx_results_and_params( - *request.param, *single_small_dataset_nx_graph + *request.param, *single_small_dataset_nx_results ) -@pytest.fixture(scope="module") -def dataset_nxresults_allstartvertices_spc(small_dataset_nx_graph): +"""@pytest.fixture(scope="module") +def dataset_nxresults_allstartvertices_spc(small_dataset_nx_results): - dataset, directed, Gnx = small_dataset_nx_graph + dataset, directed, Gnx = small_dataset_nx_results use_spc = True start_vertices = [start_vertex for start_vertex in Gnx] @@ -375,7 +370,7 @@ def dataset_nxresults_allstartvertices_spc(small_dataset_nx_graph): nx_values = nx_sp_counter all_nx_values.append(nx_values) - return (dataset, directed, all_nx_values, start_vertices, use_spc) + return (dataset, directed, all_nx_values, start_vertices, use_spc)""" # ============================================================================= @@ -396,15 +391,9 @@ def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type depth_limit, ) = dataset_nxresults_startvertex_spc - # special case: ensure cugraph and Nx Graph types are DiGraphs if - # "directed" is set, since the graph type parameterization is currently - # independent of the directed parameter. Unfortunately this does not - # change the "id" in the pytest output. Ignore for nonnative inputs if directed: if isinstance(cugraph_input_type, cugraph.Graph): cugraph_input_type = cugraph.Graph(directed=True) - elif cugraph_input_type is nx.Graph: - cugraph_input_type = nx.DiGraph if not isinstance(cugraph_input_type, cugraph.Graph): G_or_matrix = utils.create_obj_from_csv(dataset, cugraph_input_type) @@ -415,28 +404,40 @@ def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type @pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_bfs_nonnative_inputs( +@pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) +def test_bfs_nonnative_inputs_matrix( gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type ): test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) @pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs_invalid_start( - gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type +@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) +def test_bfs_nonnative_inputs_nx( + gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type ): ( - G, - dataset, + _, + _, directed, nx_values, start_vertex, - depth_limit, - ) = dataset_nxresults_startvertex_spc + _, + ) = single_dataset_nxresults_startvertex_spc + + cugraph_df = bfs_results.results[ + "{},{},{}".format("karate", directed, "nonnative-nx") + ] + compare_func = _compare_bfs + compare_func(cugraph_df, nx_values, start_vertex) + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) +def test_bfs_invalid_start( + gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type +): + (G, _, _, _, start_vertex, depth_limit) = dataset_nxresults_startvertex_spc el = G.view_edge_list() diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py b/python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py new file mode 100644 index 00000000000..7446b32ee5d --- /dev/null +++ b/python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py @@ -0,0 +1,479 @@ +# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +import random + +import pytest +import pandas as pd +import cupy as cp +import numpy as np +from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix +from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix +from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix +from scipy.sparse import coo_matrix as sp_coo_matrix +from scipy.sparse import csr_matrix as sp_csr_matrix +from scipy.sparse import csc_matrix as sp_csc_matrix +import cudf +from pylibcugraph.testing.utils import gen_fixture_params_product + +import cugraph +from cugraph.testing import utils +from cugraph.experimental import datasets + +# Temporarily suppress warnings till networkX fixes deprecation warnings +# (Using or importing the ABCs from 'collections' instead of from +# 'collections.abc' is deprecated, and in 3.8 it will stop working) for +# python 3.7. Also, this import networkx needs to be relocated in the +# third-party group once this gets fixed. +import warnings + +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + import networkx as nx + import networkx.algorithms.centrality.betweenness as nxacb + + +# ============================================================================= +# Parameters +# ============================================================================= +DIRECTED_GRAPH_OPTIONS = [True, False] + +SUBSET_SEED_OPTIONS = [42] + +DEFAULT_EPSILON = 1e-6 + +DEPTH_LIMITS = [None, 1, 5, 18] + +# Map of cuGraph input types to the expected output type for cuGraph +# connected_components calls. +cuGraph_input_output_map = { + cugraph.Graph: cudf.DataFrame, + nx.Graph: pd.DataFrame, + nx.DiGraph: pd.DataFrame, + cp_coo_matrix: tuple, + cp_csr_matrix: tuple, + cp_csc_matrix: tuple, + sp_coo_matrix: tuple, + sp_csr_matrix: tuple, + sp_csc_matrix: tuple, +} +cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] + + +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= +def setup_function(): + gc.collect() + + +# ============================================================================= +# Helper functions +# ============================================================================= +def convert_output_to_cudf(input_G_or_matrix, cugraph_result): + """ + Convert cugraph_result to a cudf DataFrame. The conversion is based on the + type of input_G_or_matrix, since different input types result in different + cugraph_result types (see cugraph_input_output_map). + """ + input_type = type(input_G_or_matrix) + expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] + assert type(cugraph_result) is expected_return_type + + if expected_return_type is cudf.DataFrame: + return cugraph_result + + elif expected_return_type is pd.DataFrame: + return cudf.from_pandas(cugraph_result) + + # A CuPy/SciPy input means the return value will be a 2-tuple of: + # distance: cupy.ndarray + # ndarray of shortest distances between source and vertex. + # predecessor: cupy.ndarray + # ndarray of predecessors of a vertex on the path from source, which + # can be used to reconstruct the shortest paths. + # or a 3-tuple of the above 2 plus + # sp_counter: cupy.ndarray + # for the i'th position in the array, the number of shortest paths + # leading to the vertex at position i in the (input) vertex array. + elif expected_return_type is tuple: + if input_type in cupy_types: + assert type(cugraph_result[0]) is cp.ndarray + assert type(cugraph_result[1]) is cp.ndarray + if len(cugraph_result) == 3: + assert type(cugraph_result[2]) is cp.ndarray + else: + assert type(cugraph_result[0]) is np.ndarray + assert type(cugraph_result[1]) is np.ndarray + if len(cugraph_result) == 3: + assert type(cugraph_result[2]) is np.ndarray + + # Get unique verts from input since they are not incuded in output + if type(input_G_or_matrix) in [ + cp_csr_matrix, + cp_csc_matrix, + sp_csr_matrix, + sp_csc_matrix, + ]: + coo = input_G_or_matrix.tocoo(copy=False) + else: + coo = input_G_or_matrix + verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) + dists = [n.item() for n in cugraph_result[0]] + preds = [n.item() for n in cugraph_result[1]] + assert len(verts) == len(dists) == len(preds) + + d = {"vertex": verts, "distance": dists, "predecessor": preds} + + if len(cugraph_result) == 3: + counters = [n.item() for n in cugraph_result[2]] + assert len(counters) == len(verts) + d.update({"sp_counter": counters}) + + return cudf.DataFrame(d) + + else: + raise RuntimeError(f"unsupported return type: {expected_return_type}") + + +# NOTE: We need to use relative error, the values of the shortest path +# counters can reach extremely high values 1e+80 and above +def compare_single_sp_counter(result, expected, epsilon=DEFAULT_EPSILON): + return np.isclose(result, expected, rtol=epsilon) + + +def compare_bfs(benchmark_callable, G, nx_values, start_vertex, depth_limit): + """ + Genereate both cugraph and reference bfs traversal. + """ + if isinstance(start_vertex, int): + result = benchmark_callable(cugraph.bfs_edges, G, start_vertex) + cugraph_df = convert_output_to_cudf(G, result) + compare_func = _compare_bfs + + # NOTE: We need to take 2 different path for verification as the nx + # functions used as reference return dictionaries that might + # not contain all the vertices while the cugraph version return + # a cudf.DataFrame with all the vertices, also some verification + # become slow with the data transfer + compare_func(cugraph_df, nx_values, start_vertex) + + elif isinstance(start_vertex, list): # For other Verifications + all_nx_values = nx_values + all_cugraph_distances = [] + + def func_to_benchmark(): + for sv in start_vertex: + cugraph_df = cugraph.bfs_edges(G, sv, depth_limit=depth_limit) + all_cugraph_distances.append(cugraph_df) + + benchmark_callable(func_to_benchmark) + + compare_func = _compare_bfs + for (i, sv) in enumerate(start_vertex): + cugraph_df = convert_output_to_cudf(G, all_cugraph_distances[i]) + + compare_func(cugraph_df, all_nx_values[i], sv) + + else: # Unknown type given to seed + raise NotImplementedError("Invalid type for start_vertex") + + +def _compare_bfs(cugraph_df, nx_distances, source): + # This call should only contain 3 columns: + # 'vertex', 'distance', 'predecessor' + # It also confirms wether or not 'sp_counter' has been created by the call + # 'sp_counter' triggers atomic operations in BFS, thus we want to make + # sure that it was not the case + # NOTE: 'predecessor' is always returned while the C++ function allows to + # pass a nullptr + assert len(cugraph_df.columns) == 3, ( + "The result of the BFS has an invalid " "number of columns" + ) + cu_distances = { + vertex: dist + for vertex, dist in zip( + cugraph_df["vertex"].to_numpy(), cugraph_df["distance"].to_numpy() + ) + } + cu_predecessors = { + vertex: dist + for vertex, dist in zip( + cugraph_df["vertex"].to_numpy(), cugraph_df["predecessor"].to_numpy() + ) + } + + # FIXME: The following only verifies vertices that were reached + # by cugraph's BFS. + # We assume that the distances are given back as integers in BFS + # max_val = np.iinfo(df['distance'].dtype).max + # Unreached vertices have a distance of max_val + + missing_vertex_error = 0 + distance_mismatch_error = 0 + invalid_predecessor_error = 0 + for vertex in nx_distances: + if vertex in cu_distances: + result = cu_distances[vertex] + expected = nx_distances[vertex] + if result != expected: + print( + "[ERR] Mismatch on distances: " + "vid = {}, cugraph = {}, nx = {}".format(vertex, result, expected) + ) + distance_mismatch_error += 1 + if vertex not in cu_predecessors: + missing_vertex_error += 1 + else: + pred = cu_predecessors[vertex] + if vertex != source and pred not in nx_distances: + invalid_predecessor_error += 1 + else: + # The graph is unweighted thus, predecessors are 1 away + if vertex != source and ( + (nx_distances[pred] + 1 != cu_distances[vertex]) + ): + print( + "[ERR] Invalid on predecessors: " + "vid = {}, cugraph = {}".format(vertex, pred) + ) + invalid_predecessor_error += 1 + else: + missing_vertex_error += 1 + assert missing_vertex_error == 0, "There are missing vertices" + assert distance_mismatch_error == 0, "There are invalid distances" + assert invalid_predecessor_error == 0, "There are invalid predecessors" + + +def get_cu_graph_nx_graph_and_params(dataset, directed): + """ + Helper for fixtures returning a Nx graph obj and params. + """ + # create graph + G = dataset.get_graph(create_using=cugraph.Graph(directed=directed)) + dataset_path = dataset.get_path() + + return ( + G, + dataset_path, + directed, + utils.generate_nx_graph_from_file(dataset_path, directed), + ) + + +def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, Gnx): + """ + Helper for fixtures returning Nx results and params. + """ + random.seed(seed) + start_vertex = random.sample(list(Gnx.nodes()), 1)[0] + + nx_values = nx.single_source_shortest_path_length( + Gnx, start_vertex, cutoff=depth_limit + ) + + return (G, dataset, directed, nx_values, start_vertex, depth_limit) + + +# ============================================================================= +# Pytest Fixtures +# ============================================================================= +SEEDS = [pytest.param(s) for s in SUBSET_SEED_OPTIONS] +DIRECTED = [pytest.param(d) for d in DIRECTED_GRAPH_OPTIONS] +DATASETS = [pytest.param(d) for d in datasets.DATASETS] +DATASETS_SMALL = [pytest.param(d) for d in datasets.DATASETS_SMALL] +DEPTH_LIMIT = [pytest.param(d) for d in DEPTH_LIMITS] + +# Call gen_fixture_params_product() to caluculate the cartesian product of +# multiple lists of params. This is required since parameterized fixtures do +# not do this automatically (unlike multiply-parameterized tests). The 2nd +# item in the tuple is a label for the param value used when displaying the +# full test name. +algo_test_fixture_params = gen_fixture_params_product( + (SEEDS, "seed"), (DEPTH_LIMIT, "depth_limit") +) + +graph_fixture_params = gen_fixture_params_product( + (DATASETS, "ds"), (DIRECTED, "dirctd") +) + +small_graph_fixture_params = gen_fixture_params_product( + (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd") +) + +# The single param list variants are used when only 1 param combination is +# needed (eg. testing non-native input types where tests for other combinations +# was covered elsewhere). +single_algo_test_fixture_params = gen_fixture_params_product( + ([SEEDS[0]], "seed"), ([DEPTH_LIMIT[0]], "depth_limit") +) + +single_small_graph_fixture_params = gen_fixture_params_product( + ([DATASETS_SMALL[0]], "ds"), (DIRECTED, "dirctd") +) + + +# Fixtures that result in a test-per (dataset X directed/undirected) +# combination. These return the path to the dataset, a bool indicating if a +# directed graph is being used, and the Nx graph object. +@pytest.fixture(scope="module", params=graph_fixture_params) +def dataset_nx_graph(request): + return get_cu_graph_nx_graph_and_params(*request.param) + + +@pytest.fixture(scope="module", params=small_graph_fixture_params) +def small_dataset_nx_graph(request): + return get_cu_graph_nx_graph_and_params(*request.param) + + +@pytest.fixture(scope="module", params=single_small_graph_fixture_params) +def single_small_dataset_nx_graph(request): + return get_cu_graph_nx_graph_and_params(*request.param) + + +# Fixtures that result in a test-per (dataset_nx_graph combinations X algo_test +# param combinations) combination. These run Nx BFS on the Nx graph obj and +# return the path to the dataset, if a directed graph is being used, the Nx BFS +# results, the starting vertex for BFS, and flag if shortes path counting was +# used. +@pytest.fixture(scope="module", params=algo_test_fixture_params) +def dataset_nxresults_startvertex_spc(dataset_nx_graph, request): + return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_graph) + + +@pytest.fixture(scope="module", params=single_algo_test_fixture_params) +def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_graph, request): + return get_cu_graph_nx_results_and_params( + *request.param, *single_small_dataset_nx_graph + ) + + +@pytest.fixture(scope="module") +def dataset_nxresults_allstartvertices_spc(small_dataset_nx_graph): + + dataset, directed, Gnx = small_dataset_nx_graph + use_spc = True + + start_vertices = [start_vertex for start_vertex in Gnx] + + all_nx_values = [] + for start_vertex in start_vertices: + _, _, nx_sp_counter = nxacb._single_source_shortest_path_basic( + Gnx, start_vertex + ) + nx_values = nx_sp_counter + all_nx_values.append(nx_values) + + return (dataset, directed, all_nx_values, start_vertices, use_spc) + + +# ============================================================================= +# Tests +# ============================================================================= +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) +def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type): + """ + Test BFS traversal on random source with distance and predecessors + """ + ( + G, + dataset, + directed, + nx_values, + start_vertex, + depth_limit, + ) = dataset_nxresults_startvertex_spc + + # special case: ensure cugraph and Nx Graph types are DiGraphs if + # "directed" is set, since the graph type parameterization is currently + # independent of the directed parameter. Unfortunately this does not + # change the "id" in the pytest output. Ignore for nonnative inputs + if directed: + if isinstance(cugraph_input_type, cugraph.Graph): + cugraph_input_type = cugraph.Graph(directed=True) + elif cugraph_input_type is nx.Graph: + cugraph_input_type = nx.DiGraph + + if not isinstance(cugraph_input_type, cugraph.Graph): + G_or_matrix = utils.create_obj_from_csv(dataset, cugraph_input_type) + else: + G_or_matrix = G + + compare_bfs(gpubenchmark, G_or_matrix, nx_values, start_vertex, depth_limit) + + +@pytest.mark.sg +@pytest.mark.parametrize( + "cugraph_input_type", utils.NX_INPUT_TYPES + utils.MATRIX_INPUT_TYPES +) +def test_bfs_nonnative_inputs( + gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type +): + test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) +def test_bfs_invalid_start( + gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type +): + ( + G, + dataset, + directed, + nx_values, + start_vertex, + depth_limit, + ) = dataset_nxresults_startvertex_spc + + el = G.view_edge_list() + + newval = max(el.src.max(), el.dst.max()) + 1 + start_vertex = newval + + with pytest.raises(ValueError): + cugraph.bfs(G, start_vertex, depth_limit=depth_limit) + + +@pytest.mark.sg +def test_scipy_api_compat(): + graph_file = datasets.DATASETS[0] + dataset_path = graph_file.get_path() + + input_cugraph_graph = graph_file.get_graph(ignore_weights=True) + + input_coo_matrix = utils.create_obj_from_csv( + dataset_path, cp_coo_matrix, edgevals=True + ) + # Ensure scipy-only options are rejected for cugraph inputs + with pytest.raises(TypeError): + cugraph.bfs(input_cugraph_graph, start=0, directed=False) + with pytest.raises(TypeError): + cugraph.bfs(input_cugraph_graph) # required arg missing + + # Ensure cugraph-compatible options work as expected + cugraph.bfs(input_cugraph_graph, i_start=0) + cugraph.bfs(input_cugraph_graph, i_start=0) + # cannot have start and i_start + with pytest.raises(TypeError): + cugraph.bfs(input_cugraph_graph, start=0, i_start=0) + + # Ensure SciPy options for matrix inputs work as expected + cugraph.bfs(input_coo_matrix, i_start=0) + cugraph.bfs(input_coo_matrix, i_start=0, directed=True) + cugraph.bfs(input_coo_matrix, i_start=0, directed=False) + result = cugraph.bfs(input_coo_matrix, i_start=0) + assert type(result) is tuple + assert len(result) == 2 diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_current.py b/python/cugraph/cugraph/tests/traversal/test_paths_current.py new file mode 100644 index 00000000000..2b4304bf0f3 --- /dev/null +++ b/python/cugraph/cugraph/tests/traversal/test_paths_current.py @@ -0,0 +1,239 @@ +# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +from tempfile import NamedTemporaryFile +import math + +import cudf +from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix +import cupy + +from cugraph.testing import ResultSet, resultset_pr +import pytest + +import cugraph + + +CONNECTED_GRAPH = """1,5,3 +1,4,1 +1,2,1 +1,6,2 +1,7,2 +4,5,1 +2,3,1 +7,6,2 +""" + +DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" + + +paths_test_data = { + "nx.shortest_path_length_1_1": 0, + "cu.shortest_path_length_1_1": 0.0, + "nx.shortest_path_length_1_5": 2.0, + "cu.shortest_path_length_1_5": 2.0, + "nx.shortest_path_length_1_3": 2.0, + "cu.shortest_path_length_1_3": 2.0, + "nx.shortest_path_length_1_6": 2.0, + "cu.shortest_path_length_1_6": 2.0, + "cu.shortest_path_length_nx_-1_1": ValueError, + "cu.shortest_path_length_nx_1_10": ValueError, + "cu.shortest_path_length_nx_0_42": ValueError, + "cu.shortest_path_length_nx_1_8": 3.4028235e+38 +} + + +@pytest.fixture +def graphs(request): + with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: + graph_tf.writelines(request.param) + graph_tf.seek(0) + + cudf_df = cudf.read_csv( + graph_tf.name, + names=["src", "dst", "data"], + delimiter=",", + dtype=["int32", "int32", "float64"], + ) + cugraph_G = cugraph.Graph() + cugraph_G.from_cudf_edgelist( + cudf_df, source="src", destination="dst", edge_attr="data" + ) + + # construct cupy coo_matrix graph + i = [] + j = [] + weights = [] + for index in range(cudf_df.shape[0]): + vertex1 = cudf_df.iloc[index]["src"] + vertex2 = cudf_df.iloc[index]["dst"] + weight = cudf_df.iloc[index]["data"] + i += [vertex1, vertex2] + j += [vertex2, vertex1] + weights += [weight, weight] + i = cupy.array(i) + j = cupy.array(j) + weights = cupy.array(weights) + largest_vertex = max(cupy.amax(i), cupy.amax(j)) + cupy_df = cupy_coo_matrix( + (weights, (i, j)), shape=(largest_vertex + 1, largest_vertex + 1) + ) + + yield cugraph_G, cupy_df + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) +def test_connected_graph_shortest_path_length(graphs): + cugraph_G, cupy_df = graphs + + path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) + assert path_1_to_1_length == 0.0 + assert path_1_to_1_length == paths_test_data["nx.shortest_path_length_1_1"] + assert path_1_to_1_length == paths_test_data["cu.shortest_path_length_1_1"] + assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) + + path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) + assert path_1_to_5_length == 2.0 + assert path_1_to_5_length == paths_test_data["nx.shortest_path_length_1_5"] + assert path_1_to_5_length == paths_test_data["cu.shortest_path_length_1_5"] + assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) + + path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) + assert path_1_to_3_length == 2.0 + assert path_1_to_3_length == paths_test_data["nx.shortest_path_length_1_3"] + assert path_1_to_3_length == paths_test_data["cu.shortest_path_length_1_3"] + assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) + + path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) + assert path_1_to_6_length == 2.0 + assert path_1_to_6_length == paths_test_data["nx.shortest_path_length_1_6"] + assert path_1_to_6_length == paths_test_data["cu.shortest_path_length_1_6"] + assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_invalid_source(graphs): + cugraph_G, cupy_df = graphs + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cugraph_G, -1, 1) + + result = paths_test_data["cu.shortest_path_length_nx_-1_1"] + if callable(result): + with pytest.raises(ValueError): + raise result() + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cupy_df, -1, 1) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_invalid_target(graphs): + cugraph_G, cupy_df = graphs + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cugraph_G, 1, 10) + + result = paths_test_data["cu.shortest_path_length_nx_1_10"] + if callable(result): + with pytest.raises(ValueError): + raise result() + + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cupy_df, 1, 10) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_invalid_vertexes(graphs): + cugraph_G, cupy_df = graphs + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cugraph_G, 0, 42) + + result = paths_test_data["cu.shortest_path_length_nx_0_42"] + if callable(result): + with pytest.raises(ValueError): + raise result() + + with pytest.raises(ValueError): + cugraph.shortest_path_length(cupy_df, 0, 42) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_no_path(graphs): + cugraph_G, cupy_df = graphs + + # FIXME: In case there is no path between two vertices, the + # result can be either the max of float32 or float64 + max_float_32 = (2 - math.pow(2, -23)) * math.pow(2, 127) + + path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) + assert path_1_to_8 == sys.float_info.max + # Not sure why this assertion now fails + assert paths_test_data["cu.shortest_path_length_nx_1_8"] in [ + max_float_32, + path_1_to_8, + ] + assert path_1_to_8 == cugraph.shortest_path_length(cupy_df, 1, 8) + + +@pytest.mark.sg +@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) +def test_shortest_path_length_no_target(graphs): + cugraph_G, cupy_df = graphs + + cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) + nx_path_1_to_all = resultset_pr.get_resultset(algo='nx.shortest_path_length', + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight" + ) + nx_path_1_to_all = nx_path_1_to_all.drop(columns="Unnamed: 0") + nx_gpu_path_1_to_all = resultset_pr.get_resultset(algo='cu.shortest_path_length', + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight" + ) + nx_gpu_path_1_to_all = nx_gpu_path_1_to_all.drop(columns="Unnamed: 0") + + cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) + + + # Cast networkx graph on cugraph vertex column type from str to int. + # SSSP preserves vertex type, convert for comparison + nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") + assert cugraph_path_1_to_all == nx_gpu_path_1_to_all + assert cugraph_path_1_to_all == cupy_path_1_to_all + + # results for vertex 8 and 9 are not returned + assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 + for index in range(cugraph_path_1_to_all.shape[0]): + + vertex = cugraph_path_1_to_all["vertex"][index].item() + distance = cugraph_path_1_to_all["distance"][index].item() + + # verify cugraph against networkx + if vertex in {8, 9}: + # Networkx does not return distances for these vertexes. + assert distance == sys.float_info.max + else: + assert distance == nx_path_1_to_all.loc[nx_path_1_to_all.vertex == vertex].distance.iloc[0] diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_old.py b/python/cugraph/cugraph/tests/traversal/test_paths_old.py index 8938ae74553..1008a222ae1 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths_old.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths_old.py @@ -18,7 +18,8 @@ import cudf from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix import cupy -import networkx as nx + +from cugraph.testing import ResultSet, ResultSet2 import pytest import cugraph @@ -36,6 +37,37 @@ DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" +paths_results = ResultSet(local_result_file="paths_results.pkl") + +"""paths_results2 = {'1,1,connected,nx': 0, '1,1,connected,cu': 0.0, + '1,5,connected,nx': 2.0, '1,5,connected,cu': 2.0, + '1,3,connected,nx': 2.0, '1,3,connected,cu': 2.0, + '1,6,connected,nx': 2.0, '1,6,connected,cu': 2.0, + '-1,1,connected,invalid': 'ValueError', + '0,42,connected,invalid': 'ValueError', + '1,10,disconnected,invalid': 'ValueError', + '1,8,disconnected,invalid': 3.4028235e+38}""" +connected_test_data = [ + ["1", "1", "nx", 0], + ["1", "1", "cu", 0.0], + ["1", "5", "nx", 2.0], + ["1", "5", "cu", 2.0], + ["1", "3", "nx", 2.0], + ["1", "3", "cu", 2.0], + ["1", "6", "nx", 2.0], + ["1", "6", "cu", 2.0], + ["-1", "1", "invalid", ValueError], + ["0", "42", "invalid", ValueError] +] +disconnected_test_data = [ + ["1", "10", "invalid", ValueError], + ["1", "8", "invalid", 3.4028235e+38] +] + +# The above can be saved as a result within the same file, however dicts and dataframes can't +# We would create results files within +# '1,notarget,nx': {'1': 0, '4': 1.0, '2': 1.0, '6': 2.0, '7': 2.0, '5': 2.0, '3': 2.0} +# '1,notarget,cu': {'1': 0, '4': 1.0, '2': 1.0, '6': 2.0, '7': 2.0, '5': 2.0, '3': 2.0} @pytest.fixture def graphs(request): @@ -43,7 +75,6 @@ def graphs(request): graph_tf.writelines(request.param) graph_tf.seek(0) - nx_G = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") cudf_df = cudf.read_csv( graph_tf.name, names=["src", "dst", "data"], @@ -74,57 +105,48 @@ def graphs(request): (weights, (i, j)), shape=(largest_vertex + 1, largest_vertex + 1) ) - yield cugraph_G, nx_G, cupy_df + yield cugraph_G, cupy_df @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_connected_graph_shortest_path_length(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) assert path_1_to_1_length == 0.0 - assert path_1_to_1_length == nx.shortest_path_length( - nx_G, "1", target="1", weight="weight" - ) - assert path_1_to_1_length == cugraph.shortest_path_length(nx_G, "1", "1") + assert path_1_to_1_length == paths_results.results["1,1,connected,nx"] + assert path_1_to_1_length == paths_results.results["1,1,connected,cu"] assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) assert path_1_to_5_length == 2.0 - assert path_1_to_5_length == nx.shortest_path_length( - nx_G, "1", target="5", weight="weight" - ) - assert path_1_to_5_length == cugraph.shortest_path_length(nx_G, "1", "5") + assert path_1_to_5_length == paths_results.results["1,5,connected,nx"] + assert path_1_to_5_length == paths_results.results["1,5,connected,cu"] assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) assert path_1_to_3_length == 2.0 - assert path_1_to_3_length == nx.shortest_path_length( - nx_G, "1", target="3", weight="weight" - ) - assert path_1_to_3_length == cugraph.shortest_path_length(nx_G, "1", "3") + assert path_1_to_3_length == paths_results.results["1,3,connected,nx"] + assert path_1_to_3_length == paths_results.results["1,3,connected,cu"] assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) assert path_1_to_6_length == 2.0 - assert path_1_to_6_length == nx.shortest_path_length( - nx_G, "1", target="6", weight="weight" - ) - assert path_1_to_6_length == cugraph.shortest_path_length(nx_G, "1", "6") + assert path_1_to_6_length == paths_results.results["1,6,connected,nx"] + assert path_1_to_6_length == paths_results.results["1,6,connected,cu"] assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_source(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, -1, 1) - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "-1", "1") + assert "ValueError" == paths_results.results["-1,1,connected,invalid"] with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, -1, 1) @@ -133,13 +155,12 @@ def test_shortest_path_length_invalid_source(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_target(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 1, 10) - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "1", "10") + assert "ValueError" == paths_results.results["1,10,disconnected,invalid"] with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, 1, 10) @@ -148,13 +169,12 @@ def test_shortest_path_length_invalid_target(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_vertexes(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 0, 42) - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "0", "42") + assert "ValueError" == paths_results.results["0,42,connected,invalid"] with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, 0, 42) @@ -163,7 +183,7 @@ def test_shortest_path_length_invalid_vertexes(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_no_path(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs # FIXME: In case there is no path between two vertices, the # result can be either the max of float32 or float64 @@ -171,27 +191,41 @@ def test_shortest_path_length_no_path(graphs): path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) assert path_1_to_8 == sys.float_info.max - assert cugraph.shortest_path_length(nx_G, "1", "8") in [max_float_32, path_1_to_8] + assert paths_results.results["1,8,disconnected,invalid"] in [ + max_float_32, + path_1_to_8, + ] assert path_1_to_8 == cugraph.shortest_path_length(cupy_df, 1, 8) @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_no_target(graphs): - cugraph_G, nx_G, cupy_df = graphs + cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - nx_path_1_to_all = nx.shortest_path_length(nx_G, source="1", weight="weight") - nx_gpu_path_1_to_all = cugraph.shortest_path_length(nx_G, "1") + #nx_path_1_to_all = paths_results.results["1,notarget,nx"] + #nx_gpu_path_1_to_all = cudf.DataFrame.from_dict( + # paths_results.results["1,notarget,cu"] + #) + nx_path_1_to_all = ResultSet2( + lib="nx", alg="shortest_path_length", graph="DISCONNECTEDnx", param="1" + ).results + nx_path_1_to_all = nx_path_1_to_all.rename(columns={"Unnamed: 0": "vertex", "0": "distance"}) + nx_path_1_to_all = nx_path_1_to_all.reset_index("vertex").to_dict()["distance"] + + nx_gpu_path_1_to_all = ResultSet2( + lib="cugraph", alg="shortest_path_length", graph="DISCONNECTEDnx", param="1" + ).results cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) + #breakpoint() # Cast networkx graph on cugraph vertex column type from str to int. # SSSP preserves vertex type, convert for comparison nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") - assert cugraph_path_1_to_all == nx_gpu_path_1_to_all assert cugraph_path_1_to_all == cupy_path_1_to_all - + #breakpoint() # results for vertex 8 and 9 are not returned assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 @@ -199,7 +233,7 @@ def test_shortest_path_length_no_target(graphs): vertex = str(cugraph_path_1_to_all["vertex"][index].item()) distance = cugraph_path_1_to_all["distance"][index].item() - + breakpoint() # verify cugraph against networkx if vertex in {"8", "9"}: # Networkx does not return distances for these vertexes. diff --git a/python/cugraph/cugraph/tests/traversal/test_paths.py b/python/cugraph/cugraph/tests/traversal/test_paths_withnx.py similarity index 77% rename from python/cugraph/cugraph/tests/traversal/test_paths.py rename to python/cugraph/cugraph/tests/traversal/test_paths_withnx.py index 8b6330ac095..8938ae74553 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths_withnx.py @@ -18,8 +18,7 @@ import cudf from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix import cupy - -from cugraph.testing import ResultSet +import networkx as nx import pytest import cugraph @@ -37,8 +36,6 @@ DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" -paths_results = ResultSet(local_result_file="paths_results.pkl") - @pytest.fixture def graphs(request): @@ -46,6 +43,7 @@ def graphs(request): graph_tf.writelines(request.param) graph_tf.seek(0) + nx_G = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") cudf_df = cudf.read_csv( graph_tf.name, names=["src", "dst", "data"], @@ -76,48 +74,57 @@ def graphs(request): (weights, (i, j)), shape=(largest_vertex + 1, largest_vertex + 1) ) - yield cugraph_G, cupy_df + yield cugraph_G, nx_G, cupy_df @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_connected_graph_shortest_path_length(graphs): - cugraph_G, cupy_df = graphs + cugraph_G, nx_G, cupy_df = graphs path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) assert path_1_to_1_length == 0.0 - assert path_1_to_1_length == paths_results.results["1,1,connected,nx"] - assert path_1_to_1_length == paths_results.results["1,1,connected,cu"] + assert path_1_to_1_length == nx.shortest_path_length( + nx_G, "1", target="1", weight="weight" + ) + assert path_1_to_1_length == cugraph.shortest_path_length(nx_G, "1", "1") assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) assert path_1_to_5_length == 2.0 - assert path_1_to_5_length == paths_results.results["1,5,connected,nx"] - assert path_1_to_5_length == paths_results.results["1,5,connected,cu"] + assert path_1_to_5_length == nx.shortest_path_length( + nx_G, "1", target="5", weight="weight" + ) + assert path_1_to_5_length == cugraph.shortest_path_length(nx_G, "1", "5") assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) assert path_1_to_3_length == 2.0 - assert path_1_to_3_length == paths_results.results["1,3,connected,nx"] - assert path_1_to_3_length == paths_results.results["1,3,connected,cu"] + assert path_1_to_3_length == nx.shortest_path_length( + nx_G, "1", target="3", weight="weight" + ) + assert path_1_to_3_length == cugraph.shortest_path_length(nx_G, "1", "3") assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) assert path_1_to_6_length == 2.0 - assert path_1_to_6_length == paths_results.results["1,6,connected,nx"] - assert path_1_to_6_length == paths_results.results["1,6,connected,cu"] + assert path_1_to_6_length == nx.shortest_path_length( + nx_G, "1", target="6", weight="weight" + ) + assert path_1_to_6_length == cugraph.shortest_path_length(nx_G, "1", "6") assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_source(graphs): - cugraph_G, cupy_df = graphs + cugraph_G, nx_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, -1, 1) - assert "ValueError" == paths_results.results["-1,1,connected,invalid"] + with pytest.raises(ValueError): + cugraph.shortest_path_length(nx_G, "-1", "1") with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, -1, 1) @@ -126,12 +133,13 @@ def test_shortest_path_length_invalid_source(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_target(graphs): - cugraph_G, cupy_df = graphs + cugraph_G, nx_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 1, 10) - assert "ValueError" == paths_results.results["1,10,disconnected,invalid"] + with pytest.raises(ValueError): + cugraph.shortest_path_length(nx_G, "1", "10") with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, 1, 10) @@ -140,12 +148,13 @@ def test_shortest_path_length_invalid_target(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) def test_shortest_path_length_invalid_vertexes(graphs): - cugraph_G, cupy_df = graphs + cugraph_G, nx_G, cupy_df = graphs with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 0, 42) - assert "ValueError" == paths_results.results["0,42,connected,invalid"] + with pytest.raises(ValueError): + cugraph.shortest_path_length(nx_G, "0", "42") with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, 0, 42) @@ -154,7 +163,7 @@ def test_shortest_path_length_invalid_vertexes(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_no_path(graphs): - cugraph_G, cupy_df = graphs + cugraph_G, nx_G, cupy_df = graphs # FIXME: In case there is no path between two vertices, the # result can be either the max of float32 or float64 @@ -162,23 +171,18 @@ def test_shortest_path_length_no_path(graphs): path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) assert path_1_to_8 == sys.float_info.max - assert paths_results.results["1,8,disconnected,invalid"] in [ - max_float_32, - path_1_to_8, - ] + assert cugraph.shortest_path_length(nx_G, "1", "8") in [max_float_32, path_1_to_8] assert path_1_to_8 == cugraph.shortest_path_length(cupy_df, 1, 8) @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) def test_shortest_path_length_no_target(graphs): - cugraph_G, cupy_df = graphs + cugraph_G, nx_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - nx_path_1_to_all = paths_results.results["1,notarget,nx"] - nx_gpu_path_1_to_all = cudf.DataFrame.from_dict( - paths_results.results["1,notarget,cu"] - ) + nx_path_1_to_all = nx.shortest_path_length(nx_G, source="1", weight="weight") + nx_gpu_path_1_to_all = cugraph.shortest_path_length(nx_G, "1") cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) # Cast networkx graph on cugraph vertex column type from str to int. diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp.py b/python/cugraph/cugraph/tests/traversal/test_sssp_current.py similarity index 88% rename from python/cugraph/cugraph/tests/traversal/test_sssp.py rename to python/cugraph/cugraph/tests/traversal/test_sssp_current.py index 72db4999813..299515aefe6 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp_current.py @@ -29,7 +29,7 @@ from cugraph.experimental.datasets import DATASETS_UNDIRECTED import cugraph -from cugraph.testing import utils, ResultSet +from cugraph.testing import utils, resultset_pr from cugraph.experimental import datasets @@ -46,7 +46,7 @@ } cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] -sssp_results = ResultSet(local_result_file="sssp_results.pkl") +# sssp_results = ResultSet(local_result_file="sssp_results.pkl") # ============================================================================= @@ -132,13 +132,22 @@ def networkx_call(graph_file, source, edgevals=True): if edgevals is False: # FIXME: no test coverage if edgevals is False, this assertion is never reached assert False - nx_paths = sssp_results.results["{},{},ssspl".format(dataset_name, source)] + # nx_paths = sssp_results.results["{},{},ssspl".format(dataset_name, source)] + nx_paths = resultset_pr.get_resultset(algo="nx.single_source_shortest_path_length", + graph_dataset=dataset_name, + graph_directed=True, + source=source) else: # FIXME: The nx call below doesn't return accurate results as it seems to # not support 'weights'. It matches cuGraph result only if the weight column # is 1s. - nx_paths = sssp_results.results["{},{},ssdpl".format(dataset_name, source)] - + # nx_paths = sssp_results.results["{},{},ssdpl".format(dataset_name, source)] + nx_paths = resultset_pr.get_resultset(algo="nx.single_source_dijkstra_path_length", + graph_dataset=dataset_name, + graph_directed=True, + source=source) + nx_paths = nx_paths.drop(columns="Unnamed: 0") + nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() G = graph_file.get_graph( create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals ) @@ -205,7 +214,6 @@ def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): ) else: input_G_or_matrix = G - cu_paths, max_val = cugraph_call(gpubenchmark, input_G_or_matrix, source) # Calculating mismatch @@ -250,16 +258,20 @@ def test_sssp_nonnative_inputs_matrix( @pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) +@pytest.mark.parametrize("directed", [True, False]) def test_sssp_nonnative_inputs_nx( - gpubenchmark, single_dataset_source_nxresults, cugraph_input_type + gpubenchmark, single_dataset_source_nxresults, directed ): - (_, _, _, source, nx_paths) = single_dataset_source_nxresults - result = sssp_results.results[ - "nonnative_input,{},{}".format(cugraph_input_type, source) - ] - # ^^ should be a pd dataframe - result = cudf.from_pandas(result) + (_, _, graph_file, source, nx_paths) = single_dataset_source_nxresults + dataset_name = graph_file.metadata["name"] + # result = sssp_results.results[ + # "nonnative_input,{},{}".format(cugraph_input_type, source) + # ] + result = resultset_pr.get_resultset(algo="cu.sssp_nonnative", + graph_dataset=dataset_name, + graph_directed=directed, + source=source) + result = result.drop(columns="Unnamed: 0") if np.issubdtype(result["distance"].dtype, np.integer): max_val = np.iinfo(result["distance"].dtype).max else: @@ -357,9 +369,16 @@ def test_sssp_data_type_conversion(graph_file, source): dist_np = df["distance"].to_numpy() pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - nx_paths = sssp_results.results[ - "nx_paths,data_type_conversion,{}".format(dataset_name) - ] + # nx_paths = sssp_results.results[ + # "nx_paths,data_type_conversion,{}".format(dataset_name) + # ] + nx_paths = resultset_pr.get_resultset(algo="nx.single_source_dijkstra_path_length", + graph_dataset=dataset_name, + graph_directed=True, + source=source, + test="data_type_conversion") + nx_paths = nx_paths.drop(columns="Unnamed: 0") + nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() # Calculating mismatch err = 0 @@ -387,8 +406,10 @@ def test_sssp_data_type_conversion(graph_file, source): @pytest.mark.sg def test_sssp_networkx_edge_attr(): - df = sssp_results.results["network_edge_attr"] - df = cudf.DataFrame(df) + # df = sssp_results.results["network_edge_attr"] + df = resultset_pr.get_resultset(algo="cu.sssp_nonnative", + test="network_edge_attr") + df = df.drop(columns="Unnamed: 0") df = df.set_index("vertex") assert df.loc[0, "distance"] == 0 assert df.loc[1, "distance"] == 10 diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp_old.py b/python/cugraph/cugraph/tests/traversal/test_sssp_old.py index 1c99123f866..72db4999813 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp_old.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp_old.py @@ -12,7 +12,6 @@ # limitations under the License. import gc -import time import numpy as np import pytest @@ -30,30 +29,14 @@ from cugraph.experimental.datasets import DATASETS_UNDIRECTED import cugraph -from cugraph.testing import utils +from cugraph.testing import utils, ResultSet from cugraph.experimental import datasets -# Temporarily suppress warnings till networkX fixes deprecation warnings -# (Using or importing the ABCs from 'collections' instead of from -# 'collections.abc' is deprecated, and in 3.8 it will stop working) for -# python 3.7. Also, this import networkx needs to be relocated in the -# third-party group once this gets fixed. -import warnings - -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - import networkx as nx - -print("Networkx version : {} ".format(nx.__version__)) - - # Map of cuGraph input types to the expected output type for cuGraph # connected_components calls. cuGraph_input_output_map = { cugraph.Graph: cudf.DataFrame, - nx.Graph: pd.DataFrame, - nx.DiGraph: pd.DataFrame, cp_coo_matrix: tuple, cp_csr_matrix: tuple, cp_csc_matrix: tuple, @@ -63,6 +46,8 @@ } cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] +sssp_results = ResultSet(local_result_file="sssp_results.pkl") + # ============================================================================= # Pytest Setup / Teardown - called for each test function @@ -142,43 +127,30 @@ def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=Tru def networkx_call(graph_file, source, edgevals=True): dataset_path = graph_file.get_path() - M = utils.read_csv_for_nx(dataset_path, read_weights_in_sp=True) - # Directed NetworkX graph - edge_attr = "weight" if edgevals else None - - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr=edge_attr, - create_using=nx.DiGraph(), - ) - print("NX Solving... ") - t1 = time.time() + dataset_name = graph_file.metadata["name"] if edgevals is False: - nx_paths = nx.single_source_shortest_path_length(Gnx, source) + # FIXME: no test coverage if edgevals is False, this assertion is never reached + assert False + nx_paths = sssp_results.results["{},{},ssspl".format(dataset_name, source)] else: # FIXME: The nx call below doesn't return accurate results as it seems to # not support 'weights'. It matches cuGraph result only if the weight column # is 1s. - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + nx_paths = sssp_results.results["{},{},ssdpl".format(dataset_name, source)] G = graph_file.get_graph( create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals ) - t2 = time.time() - t1 - print("NX Time : " + str(t2)) - - return (G, dataset_path, source, nx_paths, Gnx) + return (G, dataset_path, graph_file, source, nx_paths) # ============================================================================= # Pytest fixtures # ============================================================================= -# Call gen_fixture_params_product() to caluculate the cartesian product of +# Call gen_fixture_params_product() to calculate the cartesian product of # multiple lists of params. This is required since parameterized fixtures do # not do this automatically (unlike multiply-parameterized tests). The 2nd # item in the tuple is a label for the param value used when displaying the @@ -225,7 +197,7 @@ def single_dataset_source_nxresults_weighted(request): @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): # Extract the params generated from the fixture - (G, dataset_path, source, nx_paths, Gnx) = dataset_source_nxresults + (G, dataset_path, _, source, nx_paths) = dataset_source_nxresults if not isinstance(cugraph_input_type, cugraph.Graph): input_G_or_matrix = utils.create_obj_from_csv( @@ -259,7 +231,7 @@ def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_input_type): - (G, _, source, nx_paths, Gnx) = dataset_source_nxresults + (G, _, _, source, _) = dataset_source_nxresults el = G.view_edge_list() newval = max(el.src.max(), el.dst.max()) + 1 @@ -270,22 +242,60 @@ def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_inpu @pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_sssp_nonnative_inputs( +@pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) +def test_sssp_nonnative_inputs_matrix( gpubenchmark, single_dataset_source_nxresults, cugraph_input_type ): test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) +def test_sssp_nonnative_inputs_nx( + gpubenchmark, single_dataset_source_nxresults, cugraph_input_type +): + (_, _, _, source, nx_paths) = single_dataset_source_nxresults + result = sssp_results.results[ + "nonnative_input,{},{}".format(cugraph_input_type, source) + ] + # ^^ should be a pd dataframe + result = cudf.from_pandas(result) + if np.issubdtype(result["distance"].dtype, np.integer): + max_val = np.iinfo(result["distance"].dtype).max + else: + max_val = np.finfo(result["distance"].dtype).max + verts = result["vertex"].to_numpy() + dists = result["distance"].to_numpy() + preds = result["predecessor"].to_numpy() + cu_paths = dict(zip(verts, zip(dists, preds))) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + 1 = current dist (since unweighted) + pred = cu_paths[vid][1] + if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) def test_sssp_edgevals( gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type ): # Extract the params generated from the fixture - (G, _, source, nx_paths, Gnx) = dataset_source_nxresults_weighted + (G, _, dataset, source, nx_paths) = dataset_source_nxresults_weighted input_G_or_matrix = G cu_paths, max_val = cugraph_call( @@ -298,19 +308,20 @@ def test_sssp_edgevals( # Validate vertices that are reachable # NOTE : If distance type is float64 then cu_paths[vid][0] # should be compared against np.finfo(np.float64).max) + distances = cugraph.sssp(G, source=vid) if cu_paths[vid][0] != max_val: if cu_paths[vid][0] != nx_paths[vid]: err = err + 1 # check pred dist + edge_weight = current dist if vid != source: pred = cu_paths[vid][1] - edge_weight = Gnx[pred][vid]["weight"] + if G.has_edge(pred, vid): + edge_weight = distances[distances["vertex"] == pred].iloc[0, 0] if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: err = err + 1 else: if vid in nx_paths.keys(): err = err + 1 - assert err == 0 @@ -331,7 +342,7 @@ def test_sssp_edgevals_nonnative_inputs( @pytest.mark.parametrize("source", SOURCES) def test_sssp_data_type_conversion(graph_file, source): dataset_path = graph_file.get_path() - M = utils.read_csv_for_nx(dataset_path) + dataset_name = graph_file.metadata["name"] cu_M = utils.read_csv_file(dataset_path) # cugraph call with int32 weights @@ -346,19 +357,9 @@ def test_sssp_data_type_conversion(graph_file, source): dist_np = df["distance"].to_numpy() pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - - # networkx call with int32 weights - M["weight"] = M["weight"].astype(np.int32) - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr="weight", - create_using=nx.DiGraph(), - ) - # assert nx weights is int - assert type(list(Gnx.edges(data=True))[0][2]["weight"]) is int - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + nx_paths = sssp_results.results[ + "nx_paths,data_type_conversion,{}".format(dataset_name) + ] # Calculating mismatch err = 0 @@ -366,13 +367,15 @@ def test_sssp_data_type_conversion(graph_file, source): # Validate vertices that are reachable # NOTE : If distance type is float64 then cu_paths[vid][0] # should be compared against np.finfo(np.float64).max) + distances = cugraph.sssp(G, source=vid) if cu_paths[vid][0] != max_val: if cu_paths[vid][0] != nx_paths[vid]: err = err + 1 # check pred dist + edge_weight = current dist if vid != source: pred = cu_paths[vid][1] - edge_weight = Gnx[pred][vid]["weight"] + if G.has_edge(pred, vid): + edge_weight = distances[distances["vertex"] == pred].iloc[0, 0] if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: err = err + 1 else: @@ -384,10 +387,8 @@ def test_sssp_data_type_conversion(graph_file, source): @pytest.mark.sg def test_sssp_networkx_edge_attr(): - G = nx.Graph() - G.add_edge(0, 1, other=10) - G.add_edge(1, 2, other=20) - df = cugraph.sssp(G, 0, edge_attr="other") + df = sssp_results.results["network_edge_attr"] + df = cudf.DataFrame(df) df = df.set_index("vertex") assert df.loc[0, "distance"] == 0 assert df.loc[1, "distance"] == 10 diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py b/python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py new file mode 100644 index 00000000000..1c99123f866 --- /dev/null +++ b/python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py @@ -0,0 +1,519 @@ +# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +import time + +import numpy as np +import pytest +import pandas as pd +import cupy as cp +import cupyx +from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix +from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix +from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix +from scipy.sparse import coo_matrix as sp_coo_matrix +from scipy.sparse import csr_matrix as sp_csr_matrix +from scipy.sparse import csc_matrix as sp_csc_matrix +import cudf +from pylibcugraph.testing.utils import gen_fixture_params_product +from cugraph.experimental.datasets import DATASETS_UNDIRECTED + +import cugraph +from cugraph.testing import utils +from cugraph.experimental import datasets + + +# Temporarily suppress warnings till networkX fixes deprecation warnings +# (Using or importing the ABCs from 'collections' instead of from +# 'collections.abc' is deprecated, and in 3.8 it will stop working) for +# python 3.7. Also, this import networkx needs to be relocated in the +# third-party group once this gets fixed. +import warnings + +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + import networkx as nx + +print("Networkx version : {} ".format(nx.__version__)) + + +# Map of cuGraph input types to the expected output type for cuGraph +# connected_components calls. +cuGraph_input_output_map = { + cugraph.Graph: cudf.DataFrame, + nx.Graph: pd.DataFrame, + nx.DiGraph: pd.DataFrame, + cp_coo_matrix: tuple, + cp_csr_matrix: tuple, + cp_csc_matrix: tuple, + sp_coo_matrix: tuple, + sp_csr_matrix: tuple, + sp_csc_matrix: tuple, +} +cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] + + +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= +def setup_function(): + gc.collect() + + +# ============================================================================= +# Helper functions +# ============================================================================= +def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=True): + """ + Call cugraph.sssp on input_G_or_matrix, then convert the result to a + standard format (dictionary of vertex IDs to (distance, predecessor) + tuples) for easy checking in the test code. + """ + result = gpu_benchmark_callable(cugraph.sssp, input_G_or_matrix, source) + + input_type = type(input_G_or_matrix) + expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] + assert type(result) is expected_return_type + + # Convert cudf and pandas: DF of 3 columns: (vertex, distance, predecessor) + if expected_return_type in [cudf.DataFrame, pd.DataFrame]: + if expected_return_type is pd.DataFrame: + result = cudf.from_pandas(result) + + if np.issubdtype(result["distance"].dtype, np.integer): + max_val = np.iinfo(result["distance"].dtype).max + else: + max_val = np.finfo(result["distance"].dtype).max + verts = result["vertex"].to_numpy() + dists = result["distance"].to_numpy() + preds = result["predecessor"].to_numpy() + + # A CuPy/SciPy input means the return value will be a 2-tuple of: + # distance: cupy.ndarray + # ndarray of shortest distances between source and vertex. + # predecessor: cupy.ndarray + # ndarray of predecessors of a vertex on the path from source, which + # can be used to reconstruct the shortest paths. + elif expected_return_type is tuple: + if input_type in cupy_types: + assert type(result[0]) is cp.ndarray + assert type(result[1]) is cp.ndarray + else: + assert type(result[0]) is np.ndarray + assert type(result[1]) is np.ndarray + + if np.issubdtype(result[0].dtype, np.integer): + max_val = np.iinfo(result[0].dtype).max + else: + max_val = np.finfo(result[0].dtype).max + + # Get unique verts from input since they are not incuded in output + if type(input_G_or_matrix) in [ + cp_csr_matrix, + cp_csc_matrix, + sp_csr_matrix, + sp_csc_matrix, + ]: + coo = input_G_or_matrix.tocoo(copy=False) + else: + coo = input_G_or_matrix + verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) + dists = [n.item() for n in result[0]] + preds = [n.item() for n in result[1]] + assert len(verts) == len(dists) == len(preds) + + else: + raise RuntimeError(f"unsupported return type: {expected_return_type}") + + result_dict = dict(zip(verts, zip(dists, preds))) + return result_dict, max_val + + +def networkx_call(graph_file, source, edgevals=True): + dataset_path = graph_file.get_path() + M = utils.read_csv_for_nx(dataset_path, read_weights_in_sp=True) + # Directed NetworkX graph + edge_attr = "weight" if edgevals else None + + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr=edge_attr, + create_using=nx.DiGraph(), + ) + print("NX Solving... ") + t1 = time.time() + + if edgevals is False: + nx_paths = nx.single_source_shortest_path_length(Gnx, source) + else: + # FIXME: The nx call below doesn't return accurate results as it seems to + # not support 'weights'. It matches cuGraph result only if the weight column + # is 1s. + nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + + G = graph_file.get_graph( + create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals + ) + + t2 = time.time() - t1 + print("NX Time : " + str(t2)) + + return (G, dataset_path, source, nx_paths, Gnx) + + +# ============================================================================= +# Pytest fixtures +# ============================================================================= + +# Call gen_fixture_params_product() to caluculate the cartesian product of +# multiple lists of params. This is required since parameterized fixtures do +# not do this automatically (unlike multiply-parameterized tests). The 2nd +# item in the tuple is a label for the param value used when displaying the +# full test name. +# FIXME: tests with datasets like 'netscience' which has a weight column different +# than than 1's fail because it looks like netwokX doesn't consider weights during +# the computation. +DATASETS = [pytest.param(d) for d in datasets.DATASETS_SMALL] +SOURCES = [pytest.param(1)] +fixture_params = gen_fixture_params_product((DATASETS, "ds"), (SOURCES, "src")) +fixture_params_single_dataset = gen_fixture_params_product( + ([DATASETS[0]], "ds"), (SOURCES, "src") +) + + +# These fixtures will call networkx BFS algos and save the result. The networkx +# call is only made only once per input param combination. +@pytest.fixture(scope="module", params=fixture_params) +def dataset_source_nxresults(request): + # request.param is a tuple of params from fixture_params. When expanded + # with *, will be passed to networkx_call() as args (graph_file, source) + return networkx_call(*(request.param)) + + +@pytest.fixture(scope="module", params=fixture_params_single_dataset) +def single_dataset_source_nxresults(request): + return networkx_call(*(request.param)) + + +@pytest.fixture(scope="module", params=fixture_params) +def dataset_source_nxresults_weighted(request): + return networkx_call(*(request.param), edgevals=True) + + +@pytest.fixture(scope="module", params=fixture_params_single_dataset) +def single_dataset_source_nxresults_weighted(request): + return networkx_call(*(request.param), edgevals=True) + + +# ============================================================================= +# Tests +# ============================================================================= +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) +def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): + # Extract the params generated from the fixture + (G, dataset_path, source, nx_paths, Gnx) = dataset_source_nxresults + + if not isinstance(cugraph_input_type, cugraph.Graph): + input_G_or_matrix = utils.create_obj_from_csv( + dataset_path, cugraph_input_type, edgevals=True + ) + else: + input_G_or_matrix = G + + cu_paths, max_val = cugraph_call(gpubenchmark, input_G_or_matrix, source) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + 1 = current dist (since unweighted) + pred = cu_paths[vid][1] + if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) +def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_input_type): + (G, _, source, nx_paths, Gnx) = dataset_source_nxresults + el = G.view_edge_list() + + newval = max(el.src.max(), el.dst.max()) + 1 + source = newval + + with pytest.raises(ValueError): + cugraph_call(gpubenchmark, G, source) + + +@pytest.mark.sg +@pytest.mark.parametrize( + "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES +) +def test_sssp_nonnative_inputs( + gpubenchmark, single_dataset_source_nxresults, cugraph_input_type +): + test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) + + +@pytest.mark.sg +@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) +def test_sssp_edgevals( + gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type +): + # Extract the params generated from the fixture + (G, _, source, nx_paths, Gnx) = dataset_source_nxresults_weighted + input_G_or_matrix = G + + cu_paths, max_val = cugraph_call( + gpubenchmark, input_G_or_matrix, source, edgevals=True + ) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + edge_weight = current dist + if vid != source: + pred = cu_paths[vid][1] + edge_weight = Gnx[pred][vid]["weight"] + if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + +@pytest.mark.sg +@pytest.mark.parametrize( + "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES +) +def test_sssp_edgevals_nonnative_inputs( + gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type +): + test_sssp_edgevals( + gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type + ) + + +@pytest.mark.sg +@pytest.mark.parametrize("graph_file", DATASETS) +@pytest.mark.parametrize("source", SOURCES) +def test_sssp_data_type_conversion(graph_file, source): + dataset_path = graph_file.get_path() + M = utils.read_csv_for_nx(dataset_path) + cu_M = utils.read_csv_file(dataset_path) + + # cugraph call with int32 weights + cu_M["2"] = cu_M["2"].astype(np.int32) + G = cugraph.Graph(directed=True) + G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") + # assert cugraph weights is int32 + assert G.edgelist.edgelist_df["weights"].dtype == np.int32 + df = cugraph.sssp(G, source) + max_val = np.finfo(df["distance"].dtype).max + verts_np = df["vertex"].to_numpy() + dist_np = df["distance"].to_numpy() + pred_np = df["predecessor"].to_numpy() + cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) + + # networkx call with int32 weights + M["weight"] = M["weight"].astype(np.int32) + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr="weight", + create_using=nx.DiGraph(), + ) + # assert nx weights is int + assert type(list(Gnx.edges(data=True))[0][2]["weight"]) is int + nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + + # Calculating mismatch + err = 0 + for vid in cu_paths: + # Validate vertices that are reachable + # NOTE : If distance type is float64 then cu_paths[vid][0] + # should be compared against np.finfo(np.float64).max) + if cu_paths[vid][0] != max_val: + if cu_paths[vid][0] != nx_paths[vid]: + err = err + 1 + # check pred dist + edge_weight = current dist + if vid != source: + pred = cu_paths[vid][1] + edge_weight = Gnx[pred][vid]["weight"] + if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: + err = err + 1 + else: + if vid in nx_paths.keys(): + err = err + 1 + + assert err == 0 + + +@pytest.mark.sg +def test_sssp_networkx_edge_attr(): + G = nx.Graph() + G.add_edge(0, 1, other=10) + G.add_edge(1, 2, other=20) + df = cugraph.sssp(G, 0, edge_attr="other") + df = df.set_index("vertex") + assert df.loc[0, "distance"] == 0 + assert df.loc[1, "distance"] == 10 + assert df.loc[2, "distance"] == 30 + + +@pytest.mark.sg +def test_scipy_api_compat(): + graph_file = datasets.DATASETS[0] + dataset_path = graph_file.get_path() + input_cugraph_graph = graph_file.get_graph() + input_coo_matrix = utils.create_obj_from_csv( + dataset_path, cp_coo_matrix, edgevals=True + ) + + # Ensure scipy-only options are rejected for cugraph inputs + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, directed=False) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, unweighted=False) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, overwrite=False) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, return_predecessors=False) + + # Ensure cugraph-compatible options work as expected + # cannot set both source and indices, but must set one + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph, source=0, indices=0) + with pytest.raises(TypeError): + cugraph.shortest_path(input_cugraph_graph) + with pytest.raises(ValueError): + cugraph.shortest_path(input_cugraph_graph, source=0, method="BF") + cugraph.shortest_path(input_cugraph_graph, indices=0) + with pytest.raises(ValueError): + cugraph.shortest_path(input_cugraph_graph, indices=[0, 1, 2]) + cugraph.shortest_path(input_cugraph_graph, source=0, method="auto") + + # Ensure SciPy options for matrix inputs work as expected + # cannot set both source and indices, but must set one + with pytest.raises(TypeError): + cugraph.shortest_path(input_coo_matrix, source=0, indices=0) + with pytest.raises(TypeError): + cugraph.shortest_path(input_coo_matrix) + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, method="BF") + cugraph.shortest_path(input_coo_matrix, source=0, method="auto") + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, directed=3) + cugraph.shortest_path(input_coo_matrix, source=0, directed=True) + cugraph.shortest_path(input_coo_matrix, source=0, directed=False) + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, return_predecessors=3) + (distances, preds) = cugraph.shortest_path( + input_coo_matrix, source=0, return_predecessors=True + ) + distances = cugraph.shortest_path( + input_coo_matrix, source=0, return_predecessors=False + ) + assert type(distances) != tuple + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, unweighted=False) + cugraph.shortest_path(input_coo_matrix, source=0, unweighted=True) + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, source=0, overwrite=True) + cugraph.shortest_path(input_coo_matrix, source=0, overwrite=False) + + with pytest.raises(ValueError): + cugraph.shortest_path(input_coo_matrix, indices=[0, 1, 2]) + cugraph.shortest_path(input_coo_matrix, indices=0) + + +@pytest.mark.sg +@pytest.mark.parametrize("graph_file", DATASETS_UNDIRECTED) +def test_sssp_csr_graph(graph_file): + df = graph_file.get_edgelist() + + M = cupyx.scipy.sparse.coo_matrix( + (df["wgt"].to_cupy(), (df["src"].to_cupy(), df["dst"].to_cupy())) + ) + M = M.tocsr() + + offsets = cudf.Series(M.indptr) + indices = cudf.Series(M.indices) + weights = cudf.Series(M.data) + G_csr = cugraph.Graph() + G_coo = graph_file.get_graph() + + source = G_coo.select_random_vertices(num_vertices=1)[0] + + print("source = ", source) + + G_csr.from_cudf_adjlist(offsets, indices, weights) + + result_csr = cugraph.sssp(G_csr, source) + result_coo = cugraph.sssp(G_coo, source) + + result_csr = result_csr.sort_values("vertex").reset_index(drop=True) + result_sssp = ( + result_coo.sort_values("vertex") + .reset_index(drop=True) + .rename(columns={"distance": "distance_coo", "predecessor": "predecessor_coo"}) + ) + result_sssp["distance_csr"] = result_csr["distance"] + result_sssp["predecessor_csr"] = result_csr["predecessor"] + + distance_diffs = result_sssp.query("distance_csr != distance_coo") + predecessor_diffs = result_sssp.query("predecessor_csr != predecessor_coo") + + assert len(distance_diffs) == 0 + assert len(predecessor_diffs) == 0 + + +@pytest.mark.sg +def test_sssp_unweighted_graph(): + karate = DATASETS_UNDIRECTED[0] + G = karate.get_graph(ignore_weights=True) + + error_msg = ( + "'SSSP' requires the input graph to be weighted." + "'BFS' should be used instead of 'SSSP' for unweighted graphs." + ) + + with pytest.raises(RuntimeError, match=error_msg): + cugraph.sssp(G, 1) From 0adf4437abac44c98ad58f0dd36a6db670c78cf3 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Thu, 20 Jul 2023 17:48:43 +0000 Subject: [PATCH 04/20] Renaming files, style check --- python/cugraph/cugraph/testing/__init__.py | 4 +- ...resultset_2308.py => resultset_current.py} | 160 +++++++++--------- .../{resultset.py => resultset_old.py} | 11 +- .../cugraph/cugraph/testing/resultset_pr.py | 55 ------ python/cugraph/cugraph/testing/utils.py | 13 +- .../{test_bfs_current.py => test_bfs_new.py} | 35 ++-- .../cugraph/tests/traversal/test_bfs_old.py | 13 +- ...est_paths_current.py => test_paths_new.py} | 43 +++-- .../cugraph/tests/traversal/test_paths_old.py | 21 +-- ...{test_sssp_current.py => test_sssp_new.py} | 47 ++--- 10 files changed, 183 insertions(+), 219 deletions(-) rename python/cugraph/cugraph/testing/{resultset_2308.py => resultset_current.py} (63%) rename python/cugraph/cugraph/testing/{resultset.py => resultset_old.py} (96%) delete mode 100644 python/cugraph/cugraph/testing/resultset_pr.py rename python/cugraph/cugraph/tests/traversal/{test_bfs_current.py => test_bfs_new.py} (94%) rename python/cugraph/cugraph/tests/traversal/{test_paths_current.py => test_paths_new.py} (87%) rename python/cugraph/cugraph/tests/traversal/{test_sssp_current.py => test_sssp_new.py} (93%) diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 9cbc542354f..13b5c8a5186 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -13,6 +13,4 @@ from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH -from cugraph.testing.resultset_pr import ( - get_resultset -) \ No newline at end of file +from cugraph.testing.resultset_current import get_resultset diff --git a/python/cugraph/cugraph/testing/resultset_2308.py b/python/cugraph/cugraph/testing/resultset_current.py similarity index 63% rename from python/cugraph/cugraph/testing/resultset_2308.py rename to python/cugraph/cugraph/testing/resultset_current.py index ffc2fad029d..e8086ce0fdc 100644 --- a/python/cugraph/cugraph/testing/resultset_2308.py +++ b/python/cugraph/cugraph/testing/resultset_current.py @@ -13,12 +13,8 @@ from tempfile import NamedTemporaryFile import random -import os from pathlib import Path -# import json -import pickle - import numpy as np import cudf @@ -35,40 +31,26 @@ results_dir = Path("testing/results") -class ResultSet: - def __init__(self, data_dictionary): - self._data_dictionary = data_dictionary - - def get_cudf_dataframe(self): - # THIS IS CALLED IN RESULTS GENERATION BEFORE WRITING ALL RESULTS TO FILES - # cu algs on nx input (dict) - # nx algs on nx input (dict, but requires renaming,tweaking) - return cudf.DataFrame(self._data_dictionary) - _resultsets = {} + def add_resultset(result_data_dictionary, **kwargs): - rs = ResultSet(result_data_dictionary) + rs = utils.ResultSet(result_data_dictionary) hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) _resultsets[hashable_dict_repr] = rs -def get_resultset(**kwargs): - # THIS IS CALLED IN TESTS - hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - return _resultsets.get(hashable_dict_repr) -def get_resultset_dev(**kwargs): +"""def get_resultset(**kwargs): hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - resultset_path = results_dir / (str(hashable_dict_repr) + ".csv") - return cudf.read_csv(resultset_path) + return _resultsets.get(hashable_dict_repr)""" + -""" def get_resultset(**kwargs): + # THIS IS CALLED IN TESTS hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - desired = results_dir / (str(hashable_dict_repr) + ".csv") - return cudf.read_csv(desired) -""" - + path = results_dir / (str(hashable_dict_repr) + ".csv") + # path = Path("https://data.rapids.ai/cugraph/results/" / path + return cudf.read_csv(path) # ============================================================================= @@ -101,17 +83,19 @@ def get_resultset(**kwargs): nx_values = nx.single_source_shortest_path_length( Gnx, start_vertex, cutoff=depth_limit ) - test_bfs_results[ + """test_bfs_results[ "{},{},{},{},{}".format(seed, depth_limit, ds, dirctd, start_vertex) - ] = nx_values + ] = nx_values""" vertices = cudf.Series(nx_values.keys()) distances = cudf.Series(nx_values.values()) - add_resultset({"vertex": vertices, "distance": distances}, - graph_dataset=ds.metadata["name"], - graph_directed=dirctd, - algo="nx.single_source_shortest_path_length", - start_vertex=start_vertex, - cutoff=depth_limit) + add_resultset( + {"vertex": vertices, "distance": distances}, + graph_dataset=ds.metadata["name"], + graph_directed=dirctd, + algo="nx.single_source_shortest_path_length", + start_vertex=start_vertex, + cutoff=depth_limit, + ) # prob don't need to store in resultset # test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex @@ -120,12 +104,14 @@ def get_resultset(**kwargs): Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) result = cugraph.bfs_edges(Gnx, source=7) cugraph_df = cudf.from_pandas(result) - test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df - add_resultset(cugraph_df, - graph_dataset="karate", - graph_directed=dirctd, - algo="nx.bfs_edges", - source=7) + # test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df + add_resultset( + cugraph_df, + graph_dataset="karate", + graph_directed=dirctd, + algo="nx.bfs_edges", + source=7, + ) # ============================================================================= @@ -139,14 +125,16 @@ def get_resultset(**kwargs): for source in SOURCES: Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) - test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths + # stest_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths vertices = cudf.Series(nx_paths.keys()) distances = cudf.Series(nx_paths.values()) - add_resultset({"vertex": vertices, "distance": distances}, - graph_dataset=ds.metadata["name"], - graph_directed=True, - algo="nx.single_source_dijkstra_path_length", - source=source) + add_resultset( + {"vertex": vertices, "distance": distances}, + graph_dataset=ds.metadata["name"], + graph_directed=True, + algo="nx.single_source_dijkstra_path_length", + source=source, + ) M = utils.read_csv_for_nx(ds.get_path(), read_weights_in_sp=True) edge_attr = "weight" @@ -167,45 +155,47 @@ def get_resultset(**kwargs): create_using=nx.DiGraph(), ) nx_paths_datatypeconv = nx.single_source_dijkstra_path_length(Gnx, source) - test_sssp_results[ + """test_sssp_results[ "nx_paths,data_type_conversion,{}".format(ds) - ] = nx_paths_datatypeconv + ] = nx_paths_datatypeconv""" vertices_datatypeconv = cudf.Series(nx_paths_datatypeconv.keys()) distances_datatypeconv = cudf.Series(nx_paths_datatypeconv.values()) - add_resultset({"vertex": vertices_datatypeconv, "distance": distances_datatypeconv}, - graph_dataset=ds.metadata["name"], - graph_directed=True, - algo="nx.single_source_dijkstra_path_length", - test="data_type_conversion", - source=source) + add_resultset( + {"vertex": vertices_datatypeconv, "distance": distances_datatypeconv}, + graph_dataset=ds.metadata["name"], + graph_directed=True, + algo="nx.single_source_dijkstra_path_length", + test="data_type_conversion", + source=source, + ) for dirctd in DIRECTED_GRAPH_OPTIONS: for source in SOURCES: Gnx = utils.generate_nx_graph_from_file( karate.get_path(), directed=dirctd, edgevals=True ) - if dirctd: + """if dirctd: test_sssp_results[ "nonnative_input,nx.DiGraph,{}".format(source) ] = cugraph.sssp(Gnx, source) else: test_sssp_results[ "nonnative_input,nx.Graph,{}".format(source) - ] = cugraph.sssp(Gnx, source) - add_resultset(cugraph.sssp(Gnx, source), - graph_dataset="karate", - graph_directed=dirctd, - algo="cu.sssp_nonnative", - source=source) + ] = cugraph.sssp(Gnx, source)""" + add_resultset( + cugraph.sssp(Gnx, source), + graph_dataset="karate", + graph_directed=dirctd, + algo="cu.sssp_nonnative", + source=source, + ) G = nx.Graph() G.add_edge(0, 1, other=10) G.add_edge(1, 2, other=20) df = cugraph.sssp(G, 0, edge_attr="other") -test_sssp_results["network_edge_attr"] = df -add_resultset(df, - algo="cu.sssp_nonnative", - test="network_edge_attr") +# test_sssp_results["network_edge_attr"] = df +add_resultset(df, algo="cu.sssp_nonnative", test="network_edge_attr") # ============================================================================= # tests/traversal/test_paths.py @@ -228,7 +218,7 @@ def get_resultset(**kwargs): "disconnected": [("1", "10"), ("1", "8")], } -test_paths_results = {} +# test_paths_results = {} # CONNECTED_GRAPH with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: @@ -237,27 +227,33 @@ def get_resultset(**kwargs): Gnx_DIS = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") -test_paths_results["1,notarget,nx"] = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") +"""test_paths_results["1,notarget,nx"] = nx.shortest_path_length( + Gnx_DIS, source="1", weight="weight" +)""" vertices = cudf.Series(res1.keys()) distances = cudf.Series(res1.values()) -add_resultset({"vertex": vertices, "distance": distances}, - algo="nx.shortest_path_length", - graph_dataset="DISCONNECTED", - graph_directed=True, - source="1", - weight="weight") +add_resultset( + {"vertex": vertices, "distance": distances}, + algo="nx.shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight", +) res2 = cugraph.shortest_path_length(Gnx_DIS, "1") -test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length(Gnx_DIS, "1") -add_resultset(res2, - algo="cu.shortest_path_length", - graph_dataset="DISCONNECTED", - graph_directed=True, - source="1", - weight="weight") +# test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length(Gnx_DIS, "1") +add_resultset( + res2, + algo="cu.shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight", +) # Generating ALL results files for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() res.to_csv(results_dir / (str(temp) + ".csv")) - print(temp) \ No newline at end of file + # print(temp) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset_old.py similarity index 96% rename from python/cugraph/cugraph/testing/resultset.py rename to python/cugraph/cugraph/testing/resultset_old.py index dcd2e795c76..677ee85f2a6 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset_old.py @@ -16,9 +16,6 @@ import os from pathlib import Path -# import json -import pickle - # import pandas as pd # import cupy as cp import numpy as np @@ -38,8 +35,8 @@ default_results_upload_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" alt_results_dir = Path("testing/nxresults") -# This script is intended to generate all results for each of the corresponding results files. -# Currently, its location is in testing, but that won't be the final location +# This script is intended to generate all results for all results files. +# Currently, its location is in testing, but that won't be the final location # ============================================================================= # Parameters # ============================================================================= @@ -209,11 +206,11 @@ res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") test_paths_results["1,notarget,nx"] = res1 # res1 = cudf.DataFrame.from_dict(res1, orient="index") -# res1.to_csv(alt_results_dir / "nx/shortest_path_length/DISCONNECTEDnx/1.csv", index=True) +# res1.to_csv(alt_results_dir / "nx/spl/DISCONNECTEDnx/1.csv", index=True) res2 = cugraph.shortest_path_length(Gnx_DIS, "1") test_paths_results["1,notarget,cu"] = res2 -# res2.to_csv(alt_results_dir / "cugraph/shortest_path_length/DISCONNECTEDnx/1.csv", index=False) +# res2.to_csv(alt_results_dir / "cugraph/spl/DISCONNECTEDnx/1.csv", index=False) # serial_bfs_results = pickle.dumps(test_bfs_results) diff --git a/python/cugraph/cugraph/testing/resultset_pr.py b/python/cugraph/cugraph/testing/resultset_pr.py deleted file mode 100644 index 6f76e13bf06..00000000000 --- a/python/cugraph/cugraph/testing/resultset_pr.py +++ /dev/null @@ -1,55 +0,0 @@ -from pathlib import Path - -# from cugraph.experimental.datasets import karate -import cudf -# import networkx as nx -import os - -class Resultset: - def __init__(self, data_dictionary): - self._data_dictionary = data_dictionary - - def get_cudf_dataframe(self): - return cudf.DataFrame(self._data_dictionary) - -_resultsets = {} - -results_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) -results_dir = Path("testing/results") - -def add_resultset(result_data_dictionary, **kwargs): - rs = Resultset(result_data_dictionary) - hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - _resultsets[hashable_dict_repr] = rs - -def get_resultset(**kwargs): - hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - desired = results_dir / (str(hashable_dict_repr) + ".csv") - return cudf.read_csv(desired) - - -results_dir = Path("testing/results") - -# Example Code -################################################################################ -# Populate with results from running pagerank on karate over all combinations -# of the values for alpha and max_iter below. -"""pdf = karate.get_edgelist().to_pandas().rename(columns={"src": "source", - "dst": "target"}) -Gnx = nx.from_pandas_edgelist(pdf) - -alpha_values = [0.6, 0.75, 0.85] -max_iter_values = [50, 75, 100] - -for alpha in alpha_values: - for max_iter in max_iter_values: - print(f"pagerank: {alpha=}, {max_iter=}") - results = nx.pagerank(Gnx, alpha=alpha, max_iter=max_iter) - (vertices, pageranks) = zip(*results.items()) - add_resultset({"vertex": vertices, "pagerank": pageranks}, - graph_dataset="karate", - graph_directed=False, - algo="pagerank", - alpha=alpha, - max_iter=max_iter) -""" diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index 87c6e797f77..5a7443cf3f1 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -12,7 +12,6 @@ # limitations under the License. import os -import pickle # Assume test environment has the following dependencies installed import pytest @@ -483,7 +482,8 @@ def __init__(self, lib=None, alg=None, graph=None, params=None): self._path = None if lib is not None: - self._path = Path(Path("testing/nxresults") / lib / alg / graph / params).with_suffix(".csv") + self._path = Path(Path("testing/nxresults") / lib / alg / graph / params) + .with_suffix(".csv") if self._path.exists() is False: raise FileNotFoundError(self._path) else: @@ -492,3 +492,12 @@ def __init__(self, lib=None, alg=None, graph=None, params=None): else: raise ValueError("must specify result_file") """ + + +class ResultSet: + def __init__(self, data_dictionary): + self._data_dictionary = data_dictionary + + def get_cudf_dataframe(self): + # THIS IS CALLED IN RESULTS GENERATION BEFORE WRITING ALL RESULTS TO FILES + return cudf.DataFrame(self._data_dictionary) diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_current.py b/python/cugraph/cugraph/tests/traversal/test_bfs_new.py similarity index 94% rename from python/cugraph/cugraph/tests/traversal/test_bfs_current.py rename to python/cugraph/cugraph/tests/traversal/test_bfs_new.py index 44135b5d144..028be0e5aa4 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs_current.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs_new.py @@ -28,7 +28,7 @@ from pylibcugraph.testing.utils import gen_fixture_params_product import cugraph -from cugraph.testing import utils, resultset_pr +from cugraph.testing import utils, get_resultset from cugraph.experimental import datasets @@ -39,7 +39,12 @@ SUBSET_SEED_OPTIONS = [42] -DATASET_STARTS = {"dolphins": 16, "karate": 7, "karate-disjoint": 19, "netscience": 1237} +DATASET_STARTS = { + "dolphins": 16, + "karate": 7, + "karate-disjoint": 19, + "netscience": 1237, +} DEFAULT_EPSILON = 1e-6 @@ -263,11 +268,13 @@ def get_cu_graph_nx_results_and_params( """ start_vertex = DATASET_STARTS[dataset_name] - nx_values = resultset_pr.get_resultset(algo='nx.single_source_shortest_path_length', - cutoff=depth_limit, - graph_dataset=dataset_name, - graph_directed=directed, - start_vertex=start_vertex) + nx_values = get_resultset( + algo="nx.single_source_shortest_path_length", + cutoff=depth_limit, + graph_dataset=dataset_name, + graph_directed=directed, + start_vertex=start_vertex, + ) nx_values = nx_values.drop(columns="Unnamed: 0") nx_values = cudf.Series(nx_values.distance.values, index=nx_values.vertex).to_dict() @@ -404,11 +411,11 @@ def test_bfs_nonnative_inputs_matrix( ): test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) -#@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) @pytest.mark.sg def test_bfs_nonnative_inputs_nx( - gpubenchmark, single_dataset_nxresults_startvertex_spc, + gpubenchmark, + single_dataset_nxresults_startvertex_spc, ): ( _, @@ -419,10 +426,12 @@ def test_bfs_nonnative_inputs_nx( _, ) = single_dataset_nxresults_startvertex_spc - cugraph_df = resultset_pr.get_resultset(algo='nx.bfs_edges', - graph_dataset='karate', - graph_directed=directed, - source=start_vertex) + cugraph_df = get_resultset( + algo="nx.bfs_edges", + graph_dataset="karate", + graph_directed=directed, + source=start_vertex, + ) cugraph_df = cugraph_df.drop(columns="Unnamed: 0") compare_func = _compare_bfs diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_old.py b/python/cugraph/cugraph/tests/traversal/test_bfs_old.py index 53e72d78d21..e4ff327fbc7 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs_old.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs_old.py @@ -58,12 +58,13 @@ bfs_results = ResultSet(local_result_file="bfs_results.pkl") -bfs_results2 = {'42,dolphins,starts': 16, '42,netscience,starts': 1237, - '42,karate-disjoint,starts': 19, '42,karate,starts': 7} -# Dicts that need to be converted to cudf.df then to csv: -# '42,None,dolphins,True', '42,None,dolphins,False', '42,1,dolphins,True', '42,1,dolphins,False', '42,5,dolphins,True', '42,5,dolphins,False', '42,18,dolphins,True', '42,18,dolphins,False', '42,dolphins,starts', '42,None,netscience,True', '42,None,netscience,False', '42,1,netscience,True', '42,1,netscience,False', '42,5,netscience,True', '42,5,netscience,False', '42,18,netscience,True', '42,18,netscience,False', '42,netscience,starts', '42,None,karate-disjoint,True', '42,None,karate-disjoint,False', '42,1,karate-disjoint,True', '42,1,karate-disjoint,False', '42,5,karate-disjoint,True', '42,5,karate-disjoint,False', '42,18,karate-disjoint,True', '42,18,karate-disjoint,False', '42,karate-disjoint,starts', '42,None,karate,True', '42,None,karate,False', '42,1,karate,True', '42,1,karate,False', '42,5,karate,True', '42,5,karate,False', '42,18,karate,True', '42,18,karate,False', '42,karate,starts' -# Can be converted to csv easily: -# 'karate,True,nonnative-nx', 'karate,False,nonnative-nx' +bfs_results2 = { + "42,dolphins,starts": 16, + "42,netscience,starts": 1237, + "42,karate-disjoint,starts": 19, + "42,karate,starts": 7, +} + # ============================================================================= # Pytest Setup / Teardown - called for each test function diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_current.py b/python/cugraph/cugraph/tests/traversal/test_paths_new.py similarity index 87% rename from python/cugraph/cugraph/tests/traversal/test_paths_current.py rename to python/cugraph/cugraph/tests/traversal/test_paths_new.py index 2b4304bf0f3..94289a8e26c 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths_current.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths_new.py @@ -19,7 +19,7 @@ from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix import cupy -from cugraph.testing import ResultSet, resultset_pr +from cugraph.testing import get_resultset import pytest import cugraph @@ -50,7 +50,9 @@ "cu.shortest_path_length_nx_-1_1": ValueError, "cu.shortest_path_length_nx_1_10": ValueError, "cu.shortest_path_length_nx_0_42": ValueError, - "cu.shortest_path_length_nx_1_8": 3.4028235e+38 + "cu.shortest_path_length_nx_1_8": 3.4028235e38, + # "nx.shortest_path_length_1_all": get_resultset, + # "cu.shortest_path_length_1_all": get_resultset, } @@ -153,7 +155,6 @@ def test_shortest_path_length_invalid_target(graphs): with pytest.raises(ValueError): raise result() - with pytest.raises(ValueError): cugraph.shortest_path_length(cupy_df, 1, 10) @@ -200,30 +201,31 @@ def test_shortest_path_length_no_target(graphs): cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - nx_path_1_to_all = resultset_pr.get_resultset(algo='nx.shortest_path_length', - graph_dataset="DISCONNECTED", - graph_directed=True, - source="1", - weight="weight" - ) + nx_path_1_to_all = get_resultset( + algo="nx.shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight", + ) nx_path_1_to_all = nx_path_1_to_all.drop(columns="Unnamed: 0") - nx_gpu_path_1_to_all = resultset_pr.get_resultset(algo='cu.shortest_path_length', - graph_dataset="DISCONNECTED", - graph_directed=True, - source="1", - weight="weight" - ) + nx_gpu_path_1_to_all = get_resultset( + algo="cu.shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed=True, + source="1", + weight="weight", + ) nx_gpu_path_1_to_all = nx_gpu_path_1_to_all.drop(columns="Unnamed: 0") cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) - # Cast networkx graph on cugraph vertex column type from str to int. # SSSP preserves vertex type, convert for comparison nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") assert cugraph_path_1_to_all == nx_gpu_path_1_to_all assert cugraph_path_1_to_all == cupy_path_1_to_all - + # results for vertex 8 and 9 are not returned assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 for index in range(cugraph_path_1_to_all.shape[0]): @@ -236,4 +238,9 @@ def test_shortest_path_length_no_target(graphs): # Networkx does not return distances for these vertexes. assert distance == sys.float_info.max else: - assert distance == nx_path_1_to_all.loc[nx_path_1_to_all.vertex == vertex].distance.iloc[0] + assert ( + distance + == nx_path_1_to_all.loc[ + nx_path_1_to_all.vertex == vertex + ].distance.iloc[0] + ) diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_old.py b/python/cugraph/cugraph/tests/traversal/test_paths_old.py index 1008a222ae1..877fcf48674 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths_old.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths_old.py @@ -57,17 +57,13 @@ ["1", "6", "nx", 2.0], ["1", "6", "cu", 2.0], ["-1", "1", "invalid", ValueError], - ["0", "42", "invalid", ValueError] + ["0", "42", "invalid", ValueError], ] disconnected_test_data = [ ["1", "10", "invalid", ValueError], - ["1", "8", "invalid", 3.4028235e+38] + ["1", "8", "invalid", 3.4028235e38], ] -# The above can be saved as a result within the same file, however dicts and dataframes can't -# We would create results files within -# '1,notarget,nx': {'1': 0, '4': 1.0, '2': 1.0, '6': 2.0, '7': 2.0, '5': 2.0, '3': 2.0} -# '1,notarget,cu': {'1': 0, '4': 1.0, '2': 1.0, '6': 2.0, '7': 2.0, '5': 2.0, '3': 2.0} @pytest.fixture def graphs(request): @@ -204,28 +200,28 @@ def test_shortest_path_length_no_target(graphs): cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - #nx_path_1_to_all = paths_results.results["1,notarget,nx"] - #nx_gpu_path_1_to_all = cudf.DataFrame.from_dict( + # nx_path_1_to_all = paths_results.results["1,notarget,nx"] + # nx_gpu_path_1_to_all = cudf.DataFrame.from_dict( # paths_results.results["1,notarget,cu"] - #) + # ) nx_path_1_to_all = ResultSet2( lib="nx", alg="shortest_path_length", graph="DISCONNECTEDnx", param="1" ).results - nx_path_1_to_all = nx_path_1_to_all.rename(columns={"Unnamed: 0": "vertex", "0": "distance"}) + nx_path_1_to_all = nx_path_1_to_all.rename( + columns={"Unnamed: 0": "vertex", "0": "distance"} + ) nx_path_1_to_all = nx_path_1_to_all.reset_index("vertex").to_dict()["distance"] nx_gpu_path_1_to_all = ResultSet2( lib="cugraph", alg="shortest_path_length", graph="DISCONNECTEDnx", param="1" ).results cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) - #breakpoint() # Cast networkx graph on cugraph vertex column type from str to int. # SSSP preserves vertex type, convert for comparison nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") assert cugraph_path_1_to_all == nx_gpu_path_1_to_all assert cugraph_path_1_to_all == cupy_path_1_to_all - #breakpoint() # results for vertex 8 and 9 are not returned assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 @@ -233,7 +229,6 @@ def test_shortest_path_length_no_target(graphs): vertex = str(cugraph_path_1_to_all["vertex"][index].item()) distance = cugraph_path_1_to_all["distance"][index].item() - breakpoint() # verify cugraph against networkx if vertex in {"8", "9"}: # Networkx does not return distances for these vertexes. diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp_current.py b/python/cugraph/cugraph/tests/traversal/test_sssp_new.py similarity index 93% rename from python/cugraph/cugraph/tests/traversal/test_sssp_current.py rename to python/cugraph/cugraph/tests/traversal/test_sssp_new.py index 299515aefe6..53bd93b4f11 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp_current.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp_new.py @@ -29,7 +29,7 @@ from cugraph.experimental.datasets import DATASETS_UNDIRECTED import cugraph -from cugraph.testing import utils, resultset_pr +from cugraph.testing import utils, get_resultset from cugraph.experimental import datasets @@ -133,19 +133,23 @@ def networkx_call(graph_file, source, edgevals=True): # FIXME: no test coverage if edgevals is False, this assertion is never reached assert False # nx_paths = sssp_results.results["{},{},ssspl".format(dataset_name, source)] - nx_paths = resultset_pr.get_resultset(algo="nx.single_source_shortest_path_length", - graph_dataset=dataset_name, - graph_directed=True, - source=source) + nx_paths = get_resultset( + algo="nx.single_source_shortest_path_length", + graph_dataset=dataset_name, + graph_directed=True, + source=source, + ) else: # FIXME: The nx call below doesn't return accurate results as it seems to # not support 'weights'. It matches cuGraph result only if the weight column # is 1s. # nx_paths = sssp_results.results["{},{},ssdpl".format(dataset_name, source)] - nx_paths = resultset_pr.get_resultset(algo="nx.single_source_dijkstra_path_length", - graph_dataset=dataset_name, - graph_directed=True, - source=source) + nx_paths = get_resultset( + algo="nx.single_source_dijkstra_path_length", + graph_dataset=dataset_name, + graph_directed=True, + source=source, + ) nx_paths = nx_paths.drop(columns="Unnamed: 0") nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() G = graph_file.get_graph( @@ -267,10 +271,12 @@ def test_sssp_nonnative_inputs_nx( # result = sssp_results.results[ # "nonnative_input,{},{}".format(cugraph_input_type, source) # ] - result = resultset_pr.get_resultset(algo="cu.sssp_nonnative", - graph_dataset=dataset_name, - graph_directed=directed, - source=source) + result = get_resultset( + algo="cu.sssp_nonnative", + graph_dataset=dataset_name, + graph_directed=directed, + source=source, + ) result = result.drop(columns="Unnamed: 0") if np.issubdtype(result["distance"].dtype, np.integer): max_val = np.iinfo(result["distance"].dtype).max @@ -372,11 +378,13 @@ def test_sssp_data_type_conversion(graph_file, source): # nx_paths = sssp_results.results[ # "nx_paths,data_type_conversion,{}".format(dataset_name) # ] - nx_paths = resultset_pr.get_resultset(algo="nx.single_source_dijkstra_path_length", - graph_dataset=dataset_name, - graph_directed=True, - source=source, - test="data_type_conversion") + nx_paths = get_resultset( + algo="nx.single_source_dijkstra_path_length", + graph_dataset=dataset_name, + graph_directed=True, + source=source, + test="data_type_conversion", + ) nx_paths = nx_paths.drop(columns="Unnamed: 0") nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() @@ -407,8 +415,7 @@ def test_sssp_data_type_conversion(graph_file, source): @pytest.mark.sg def test_sssp_networkx_edge_attr(): # df = sssp_results.results["network_edge_attr"] - df = resultset_pr.get_resultset(algo="cu.sssp_nonnative", - test="network_edge_attr") + df = get_resultset(algo="cu.sssp_nonnative", test="network_edge_attr") df = df.drop(columns="Unnamed: 0") df = df.set_index("vertex") assert df.loc[0, "distance"] == 0 From d679d5615723a4f9a3ba2860efc1d1022436c9d3 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Mon, 24 Jul 2023 22:15:25 +0000 Subject: [PATCH 05/20] Removed temp results files, addresses mapping changes --- python/cugraph/cugraph/testing/__init__.py | 2 +- ...('source', '1'), ('weight', 'weight')).csv | 10 - ...raph_directed', False), ('source', 1)).csv | 35 --- ...graph_directed', True), ('source', 1)).csv | 35 --- ...tive'), ('test', 'network_edge_attr')).csv | 4 - ...raph_directed', False), ('source', 7)).csv | 35 --- ...graph_directed', True), ('source', 7)).csv | 35 --- ...('source', '1'), ('weight', 'weight')).csv | 8 - ...graph_directed', True), ('source', 1)).csv | 63 ----- ... 1), ('test', 'data_type_conversion')).csv | 63 ----- ...graph_directed', True), ('source', 1)).csv | 35 --- ... 1), ('test', 'data_type_conversion')).csv | 35 --- ...graph_directed', True), ('source', 1)).csv | 106 -------- ... 1), ('test', 'data_type_conversion')).csv | 106 -------- ...rected', False), ('start_vertex', 16)).csv | 8 - ...irected', True), ('start_vertex', 16)).csv | 8 - ...irected', False), ('start_vertex', 7)).csv | 6 - ...directed', True), ('start_vertex', 7)).csv | 6 - ...rected', False), ('start_vertex', 19)).csv | 5 - ...irected', True), ('start_vertex', 19)).csv | 5 - ...cted', False), ('start_vertex', 1237)).csv | 3 - ...ected', True), ('start_vertex', 1237)).csv | 3 - ...rected', False), ('start_vertex', 16)).csv | 63 ----- ...irected', True), ('start_vertex', 16)).csv | 63 ----- ...irected', False), ('start_vertex', 7)).csv | 35 --- ...directed', True), ('start_vertex', 7)).csv | 35 --- ...rected', False), ('start_vertex', 19)).csv | 35 --- ...irected', True), ('start_vertex', 19)).csv | 35 --- ...cted', False), ('start_vertex', 1237)).csv | 3 - ...ected', True), ('start_vertex', 1237)).csv | 3 - ...rected', False), ('start_vertex', 16)).csv | 60 ----- ...irected', True), ('start_vertex', 16)).csv | 60 ----- ...irected', False), ('start_vertex', 7)).csv | 35 --- ...directed', True), ('start_vertex', 7)).csv | 35 --- ...rected', False), ('start_vertex', 19)).csv | 35 --- ...irected', True), ('start_vertex', 19)).csv | 35 --- ...cted', False), ('start_vertex', 1237)).csv | 3 - ...ected', True), ('start_vertex', 1237)).csv | 3 - ...rected', False), ('start_vertex', 16)).csv | 63 ----- ...irected', True), ('start_vertex', 16)).csv | 63 ----- ...irected', False), ('start_vertex', 7)).csv | 35 --- ...directed', True), ('start_vertex', 7)).csv | 35 --- ...rected', False), ('start_vertex', 19)).csv | 35 --- ...irected', True), ('start_vertex', 19)).csv | 35 --- ...cted', False), ('start_vertex', 1237)).csv | 3 - ...ected', True), ('start_vertex', 1237)).csv | 3 - .../{resultset_current.py => resultset.py} | 89 ++++--- .../cugraph/cugraph/testing/resultset_old.py | 251 ------------------ .../cugraph/tests/traversal/BLUEPRINT.py | 50 ---- .../{test_bfs_new.py => test_bfs.py} | 24 +- .../{test_paths_new.py => test_paths.py} | 42 ++- .../{test_sssp_new.py => test_sssp.py} | 56 ++-- 52 files changed, 96 insertions(+), 1842 deletions(-) delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv delete mode 100644 python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv rename python/cugraph/cugraph/testing/{resultset_current.py => resultset.py} (79%) delete mode 100644 python/cugraph/cugraph/testing/resultset_old.py delete mode 100644 python/cugraph/cugraph/tests/traversal/BLUEPRINT.py rename python/cugraph/cugraph/tests/traversal/{test_bfs_new.py => test_bfs.py} (97%) rename python/cugraph/cugraph/tests/traversal/{test_paths_new.py => test_paths.py} (85%) rename python/cugraph/cugraph/tests/traversal/{test_sssp_new.py => test_sssp.py} (93%) diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 13b5c8a5186..52490ba1424 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -13,4 +13,4 @@ from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH -from cugraph.testing.resultset_current import get_resultset +from cugraph.testing.resultset import get_resultset diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv deleted file mode 100644 index 6872ef337f8..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'cu.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv +++ /dev/null @@ -1,10 +0,0 @@ -,vertex,distance -0,2,1.0 -1,4,1.0 -2,6,2.0 -3,7,2.0 -4,5,2.0 -5,3,2.0 -6,1,0.0 -7,9,3.402823466e+38 -8,8,3.402823466e+38 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv deleted file mode 100644 index d09b494fe6d..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 1)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,distance,vertex,predecessor -0,2.0,33,13 -1,1.0,0,1 -2,2.0,32,2 -3,1.0,2,1 -4,0.0,1,-1 -5,1.0,3,1 -6,2.0,31,0 -7,2.0,8,0 -8,1.0,13,1 -9,3.0,23,33 -10,2.0,5,0 -11,2.0,6,0 -12,1.0,7,1 -13,2.0,27,2 -14,3.0,29,33 -15,1.0,30,1 -16,2.0,4,0 -17,2.0,10,0 -18,1.0,19,1 -19,3.0,24,31 -20,3.0,25,31 -21,2.0,28,2 -22,2.0,9,2 -23,2.0,12,0 -24,3.0,14,33 -25,3.0,15,33 -26,3.0,16,5 -27,1.0,17,1 -28,3.0,18,33 -29,3.0,20,33 -30,1.0,21,1 -31,3.0,22,33 -32,3.0,26,33 -33,2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv deleted file mode 100644 index d09b494fe6d..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,distance,vertex,predecessor -0,2.0,33,13 -1,1.0,0,1 -2,2.0,32,2 -3,1.0,2,1 -4,0.0,1,-1 -5,1.0,3,1 -6,2.0,31,0 -7,2.0,8,0 -8,1.0,13,1 -9,3.0,23,33 -10,2.0,5,0 -11,2.0,6,0 -12,1.0,7,1 -13,2.0,27,2 -14,3.0,29,33 -15,1.0,30,1 -16,2.0,4,0 -17,2.0,10,0 -18,1.0,19,1 -19,3.0,24,31 -20,3.0,25,31 -21,2.0,28,2 -22,2.0,9,2 -23,2.0,12,0 -24,3.0,14,33 -25,3.0,15,33 -26,3.0,16,5 -27,1.0,17,1 -28,3.0,18,33 -29,3.0,20,33 -30,1.0,21,1 -31,3.0,22,33 -32,3.0,26,33 -33,2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv deleted file mode 100644 index 4918d7cf3b7..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'cu.sssp_nonnative'), ('test', 'network_edge_attr')).csv +++ /dev/null @@ -1,4 +0,0 @@ -,distance,vertex,predecessor -0,10.0,1,0 -1,0.0,0,-1 -2,30.0,2,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv deleted file mode 100644 index 44531380162..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', False), ('source', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance,predecessor -0,33,3,32 -1,0,1,7 -2,32,2,2 -3,2,1,7 -4,1,1,7 -5,3,1,7 -6,31,2,0 -7,8,2,0 -8,13,2,0 -9,23,3,32 -10,5,2,0 -11,6,2,0 -12,7,0,-1 -13,27,2,2 -14,29,3,32 -15,30,2,1 -16,4,2,0 -17,10,2,0 -18,19,2,0 -19,24,3,31 -20,25,3,31 -21,28,2,2 -22,9,2,2 -23,12,2,0 -24,14,3,32 -25,15,3,32 -26,16,3,5 -27,17,2,0 -28,18,3,32 -29,20,3,32 -30,21,2,0 -31,22,3,32 -32,26,4,33 -33,11,2,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv deleted file mode 100644 index 44531380162..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance,predecessor -0,33,3,32 -1,0,1,7 -2,32,2,2 -3,2,1,7 -4,1,1,7 -5,3,1,7 -6,31,2,0 -7,8,2,0 -8,13,2,0 -9,23,3,32 -10,5,2,0 -11,6,2,0 -12,7,0,-1 -13,27,2,2 -14,29,3,32 -15,30,2,1 -16,4,2,0 -17,10,2,0 -18,19,2,0 -19,24,3,31 -20,25,3,31 -21,28,2,2 -22,9,2,2 -23,12,2,0 -24,14,3,32 -25,15,3,32 -26,16,3,5 -27,17,2,0 -28,18,3,32 -29,20,3,32 -30,21,2,0 -31,22,3,32 -32,26,4,33 -33,11,2,0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv deleted file mode 100644 index 15d88268d5d..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', True), ('source', '1'), ('weight', 'weight')).csv +++ /dev/null @@ -1,8 +0,0 @@ -,vertex,distance -0,1,0.0 -1,4,1.0 -2,2,1.0 -3,6,2.0 -4,7,2.0 -5,5,2.0 -6,3,2.0 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv deleted file mode 100644 index a4adf34daa2..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1)).csv +++ /dev/null @@ -1,63 +0,0 @@ -,vertex,distance -0,1,0 -1,17,1 -2,19,1 -3,26,1 -4,27,1 -5,28,1 -6,36,1 -7,41,1 -8,54,1 -9,6,2 -10,9,2 -11,13,2 -12,22,2 -13,25,2 -14,31,2 -15,57,2 -16,7,2 -17,30,2 -18,8,2 -19,20,2 -20,47,2 -21,23,2 -22,37,2 -23,39,2 -24,40,2 -25,59,2 -26,56,3 -27,5,3 -28,32,3 -29,48,3 -30,42,3 -31,3,3 -32,45,3 -33,16,3 -34,18,3 -35,38,3 -36,44,3 -37,50,3 -38,0,3 -39,10,3 -40,51,3 -41,14,3 -42,21,3 -43,33,3 -44,34,3 -45,43,3 -46,61,3 -47,15,3 -48,52,3 -49,60,4 -50,2,4 -51,24,4 -52,29,4 -53,58,4 -54,4,4 -55,11,4 -56,55,4 -57,12,4 -58,49,4 -59,46,4 -60,53,4 -61,35,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv deleted file mode 100644 index a4adf34daa2..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv +++ /dev/null @@ -1,63 +0,0 @@ -,vertex,distance -0,1,0 -1,17,1 -2,19,1 -3,26,1 -4,27,1 -5,28,1 -6,36,1 -7,41,1 -8,54,1 -9,6,2 -10,9,2 -11,13,2 -12,22,2 -13,25,2 -14,31,2 -15,57,2 -16,7,2 -17,30,2 -18,8,2 -19,20,2 -20,47,2 -21,23,2 -22,37,2 -23,39,2 -24,40,2 -25,59,2 -26,56,3 -27,5,3 -28,32,3 -29,48,3 -30,42,3 -31,3,3 -32,45,3 -33,16,3 -34,18,3 -35,38,3 -36,44,3 -37,50,3 -38,0,3 -39,10,3 -40,51,3 -41,14,3 -42,21,3 -43,33,3 -44,34,3 -45,43,3 -46,61,3 -47,15,3 -48,52,3 -49,60,4 -50,2,4 -51,24,4 -52,29,4 -53,58,4 -54,4,4 -55,11,4 -56,55,4 -57,12,4 -58,49,4 -59,46,4 -60,53,4 -61,35,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv deleted file mode 100644 index d3ce8fd103c..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,1,0 -1,0,1 -2,2,1 -3,3,1 -4,7,1 -5,13,1 -6,17,1 -7,19,1 -8,21,1 -9,30,1 -10,4,2 -11,5,2 -12,6,2 -13,8,2 -14,10,2 -15,11,2 -16,12,2 -17,31,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,33,2 -23,16,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv deleted file mode 100644 index d3ce8fd103c..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,1,0 -1,0,1 -2,2,1 -3,3,1 -4,7,1 -5,13,1 -6,17,1 -7,19,1 -8,21,1 -9,30,1 -10,4,2 -11,5,2 -12,6,2 -13,8,2 -14,10,2 -15,11,2 -16,12,2 -17,31,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,33,2 -23,16,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv deleted file mode 100644 index f2771559775..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1)).csv +++ /dev/null @@ -1,106 +0,0 @@ -,vertex,distance -0,1,0 -1,0,1 -2,3,1 -3,5,1 -4,6,1 -5,2,2 -6,4,2 -7,8,2 -8,9,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,14,2 -14,15,2 -15,16,2 -16,17,2 -17,18,2 -18,19,2 -19,20,2 -20,21,2 -21,22,2 -22,23,2 -23,24,2 -24,25,2 -25,26,2 -26,27,2 -27,7,2 -28,29,2 -29,28,3 -30,30,3 -31,31,3 -32,32,3 -33,33,3 -34,35,3 -35,37,3 -36,40,3 -37,41,3 -38,42,3 -39,43,3 -40,44,3 -41,45,3 -42,46,3 -43,47,3 -44,48,3 -45,49,3 -46,50,3 -47,51,3 -48,52,3 -49,38,3 -50,39,3 -51,55,3 -52,56,3 -53,36,3 -54,54,3 -55,57,3 -56,58,3 -57,77,3 -58,53,3 -59,71,3 -60,85,3 -61,66,4 -62,72,4 -63,67,4 -64,70,4 -65,73,4 -66,74,4 -67,75,4 -68,76,4 -69,79,4 -70,80,4 -71,82,4 -72,83,4 -73,84,4 -74,86,4 -75,93,4 -76,99,4 -77,78,4 -78,91,4 -79,34,4 -80,102,4 -81,64,4 -82,65,4 -83,69,4 -84,68,4 -85,81,4 -86,88,5 -87,89,5 -88,90,5 -89,96,5 -90,97,5 -91,100,5 -92,87,5 -93,92,5 -94,103,5 -95,104,5 -96,94,5 -97,95,5 -98,98,5 -99,60,5 -100,62,5 -101,101,5 -102,61,5 -103,59,5 -104,63,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv deleted file mode 100644 index f2771559775..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', True), ('source', 1), ('test', 'data_type_conversion')).csv +++ /dev/null @@ -1,106 +0,0 @@ -,vertex,distance -0,1,0 -1,0,1 -2,3,1 -3,5,1 -4,6,1 -5,2,2 -6,4,2 -7,8,2 -8,9,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,14,2 -14,15,2 -15,16,2 -16,17,2 -17,18,2 -18,19,2 -19,20,2 -20,21,2 -21,22,2 -22,23,2 -23,24,2 -24,25,2 -25,26,2 -26,27,2 -27,7,2 -28,29,2 -29,28,3 -30,30,3 -31,31,3 -32,32,3 -33,33,3 -34,35,3 -35,37,3 -36,40,3 -37,41,3 -38,42,3 -39,43,3 -40,44,3 -41,45,3 -42,46,3 -43,47,3 -44,48,3 -45,49,3 -46,50,3 -47,51,3 -48,52,3 -49,38,3 -50,39,3 -51,55,3 -52,56,3 -53,36,3 -54,54,3 -55,57,3 -56,58,3 -57,77,3 -58,53,3 -59,71,3 -60,85,3 -61,66,4 -62,72,4 -63,67,4 -64,70,4 -65,73,4 -66,74,4 -67,75,4 -68,76,4 -69,79,4 -70,80,4 -71,82,4 -72,83,4 -73,84,4 -74,86,4 -75,93,4 -76,99,4 -77,78,4 -78,91,4 -79,34,4 -80,102,4 -81,64,4 -82,65,4 -83,69,4 -84,68,4 -85,81,4 -86,88,5 -87,89,5 -88,90,5 -89,96,5 -90,97,5 -91,100,5 -92,87,5 -93,92,5 -94,103,5 -95,104,5 -96,94,5 -97,95,5 -98,98,5 -99,60,5 -100,62,5 -101,101,5 -102,61,5 -103,59,5 -104,63,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv deleted file mode 100644 index a5146501cd9..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv +++ /dev/null @@ -1,8 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv deleted file mode 100644 index a5146501cd9..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv +++ /dev/null @@ -1,8 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv deleted file mode 100644 index f0105fbeebb..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv +++ /dev/null @@ -1,6 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv deleted file mode 100644 index f0105fbeebb..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv +++ /dev/null @@ -1,6 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv deleted file mode 100644 index cc0d15c1b90..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv +++ /dev/null @@ -1,5 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv deleted file mode 100644 index cc0d15c1b90..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv +++ /dev/null @@ -1,5 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 1), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv deleted file mode 100644 index 1395a419102..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv +++ /dev/null @@ -1,63 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 -7,0,2 -8,3,2 -9,24,2 -10,34,2 -11,40,2 -12,43,2 -13,52,2 -14,8,2 -15,18,2 -16,28,2 -17,36,2 -18,44,2 -19,47,2 -20,12,2 -21,21,2 -22,45,2 -23,61,2 -24,58,2 -25,42,2 -26,51,2 -27,10,3 -28,15,3 -29,59,3 -30,29,3 -31,49,3 -32,7,3 -33,46,3 -34,53,3 -35,1,3 -36,30,3 -37,23,3 -38,39,3 -39,2,3 -40,4,3 -41,11,3 -42,55,3 -43,35,4 -44,19,4 -45,27,4 -46,54,4 -47,17,4 -48,26,4 -49,41,4 -50,57,4 -51,25,5 -52,6,5 -53,13,5 -54,9,5 -55,22,5 -56,31,5 -57,5,5 -58,48,5 -59,56,6 -60,32,6 -61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv deleted file mode 100644 index 1395a419102..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv +++ /dev/null @@ -1,63 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 -7,0,2 -8,3,2 -9,24,2 -10,34,2 -11,40,2 -12,43,2 -13,52,2 -14,8,2 -15,18,2 -16,28,2 -17,36,2 -18,44,2 -19,47,2 -20,12,2 -21,21,2 -22,45,2 -23,61,2 -24,58,2 -25,42,2 -26,51,2 -27,10,3 -28,15,3 -29,59,3 -30,29,3 -31,49,3 -32,7,3 -33,46,3 -34,53,3 -35,1,3 -36,30,3 -37,23,3 -38,39,3 -39,2,3 -40,4,3 -41,11,3 -42,55,3 -43,35,4 -44,19,4 -45,27,4 -46,54,4 -47,17,4 -48,26,4 -49,41,4 -50,57,4 -51,25,5 -52,6,5 -53,13,5 -54,9,5 -55,22,5 -56,31,5 -57,5,5 -58,48,5 -59,56,6 -60,32,6 -61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv deleted file mode 100644 index 2240fd7b022..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 -5,4,2 -6,5,2 -7,6,2 -8,8,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,17,2 -14,19,2 -15,21,2 -16,31,2 -17,30,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,16,3 -23,33,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv deleted file mode 100644 index 2240fd7b022..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 -5,4,2 -6,5,2 -7,6,2 -8,8,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,17,2 -14,19,2 -15,21,2 -16,31,2 -17,30,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,16,3 -23,33,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv deleted file mode 100644 index a46f001b4ea..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 -4,2,2 -5,3,2 -6,4,2 -7,5,2 -8,6,2 -9,7,2 -10,8,2 -11,10,2 -12,11,2 -13,12,2 -14,13,2 -15,17,2 -16,21,2 -17,31,2 -18,30,2 -19,9,2 -20,14,2 -21,15,2 -22,18,2 -23,20,2 -24,22,2 -25,23,2 -26,26,2 -27,27,2 -28,28,2 -29,29,2 -30,32,2 -31,16,3 -32,24,3 -33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv deleted file mode 100644 index a46f001b4ea..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 -4,2,2 -5,3,2 -6,4,2 -7,5,2 -8,6,2 -9,7,2 -10,8,2 -11,10,2 -12,11,2 -13,12,2 -14,13,2 -15,17,2 -16,21,2 -17,31,2 -18,30,2 -19,9,2 -20,14,2 -21,15,2 -22,18,2 -23,20,2 -24,22,2 -25,23,2 -26,26,2 -27,27,2 -28,28,2 -29,29,2 -30,32,2 -31,16,3 -32,24,3 -33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 18), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv deleted file mode 100644 index 733866596fb..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv +++ /dev/null @@ -1,60 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 -7,0,2 -8,3,2 -9,24,2 -10,34,2 -11,40,2 -12,43,2 -13,52,2 -14,8,2 -15,18,2 -16,28,2 -17,36,2 -18,44,2 -19,47,2 -20,12,2 -21,21,2 -22,45,2 -23,61,2 -24,58,2 -25,42,2 -26,51,2 -27,10,3 -28,15,3 -29,59,3 -30,29,3 -31,49,3 -32,7,3 -33,46,3 -34,53,3 -35,1,3 -36,30,3 -37,23,3 -38,39,3 -39,2,3 -40,4,3 -41,11,3 -42,55,3 -43,35,4 -44,19,4 -45,27,4 -46,54,4 -47,17,4 -48,26,4 -49,41,4 -50,57,4 -51,25,5 -52,6,5 -53,13,5 -54,9,5 -55,22,5 -56,31,5 -57,5,5 -58,48,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv deleted file mode 100644 index 733866596fb..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv +++ /dev/null @@ -1,60 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 -7,0,2 -8,3,2 -9,24,2 -10,34,2 -11,40,2 -12,43,2 -13,52,2 -14,8,2 -15,18,2 -16,28,2 -17,36,2 -18,44,2 -19,47,2 -20,12,2 -21,21,2 -22,45,2 -23,61,2 -24,58,2 -25,42,2 -26,51,2 -27,10,3 -28,15,3 -29,59,3 -30,29,3 -31,49,3 -32,7,3 -33,46,3 -34,53,3 -35,1,3 -36,30,3 -37,23,3 -38,39,3 -39,2,3 -40,4,3 -41,11,3 -42,55,3 -43,35,4 -44,19,4 -45,27,4 -46,54,4 -47,17,4 -48,26,4 -49,41,4 -50,57,4 -51,25,5 -52,6,5 -53,13,5 -54,9,5 -55,22,5 -56,31,5 -57,5,5 -58,48,5 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv deleted file mode 100644 index 2240fd7b022..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 -5,4,2 -6,5,2 -7,6,2 -8,8,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,17,2 -14,19,2 -15,21,2 -16,31,2 -17,30,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,16,3 -23,33,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv deleted file mode 100644 index 2240fd7b022..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 -5,4,2 -6,5,2 -7,6,2 -8,8,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,17,2 -14,19,2 -15,21,2 -16,31,2 -17,30,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,16,3 -23,33,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv deleted file mode 100644 index a46f001b4ea..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 -4,2,2 -5,3,2 -6,4,2 -7,5,2 -8,6,2 -9,7,2 -10,8,2 -11,10,2 -12,11,2 -13,12,2 -14,13,2 -15,17,2 -16,21,2 -17,31,2 -18,30,2 -19,9,2 -20,14,2 -21,15,2 -22,18,2 -23,20,2 -24,22,2 -25,23,2 -26,26,2 -27,27,2 -28,28,2 -29,29,2 -30,32,2 -31,16,3 -32,24,3 -33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv deleted file mode 100644 index a46f001b4ea..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 -4,2,2 -5,3,2 -6,4,2 -7,5,2 -8,6,2 -9,7,2 -10,8,2 -11,10,2 -12,11,2 -13,12,2 -14,13,2 -15,17,2 -16,21,2 -17,31,2 -18,30,2 -19,9,2 -20,14,2 -21,15,2 -22,18,2 -23,20,2 -24,22,2 -25,23,2 -26,26,2 -27,27,2 -28,28,2 -29,29,2 -30,32,2 -31,16,3 -32,24,3 -33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', 5), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv deleted file mode 100644 index 1395a419102..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', False), ('start_vertex', 16)).csv +++ /dev/null @@ -1,63 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 -7,0,2 -8,3,2 -9,24,2 -10,34,2 -11,40,2 -12,43,2 -13,52,2 -14,8,2 -15,18,2 -16,28,2 -17,36,2 -18,44,2 -19,47,2 -20,12,2 -21,21,2 -22,45,2 -23,61,2 -24,58,2 -25,42,2 -26,51,2 -27,10,3 -28,15,3 -29,59,3 -30,29,3 -31,49,3 -32,7,3 -33,46,3 -34,53,3 -35,1,3 -36,30,3 -37,23,3 -38,39,3 -39,2,3 -40,4,3 -41,11,3 -42,55,3 -43,35,4 -44,19,4 -45,27,4 -46,54,4 -47,17,4 -48,26,4 -49,41,4 -50,57,4 -51,25,5 -52,6,5 -53,13,5 -54,9,5 -55,22,5 -56,31,5 -57,5,5 -58,48,5 -59,56,6 -60,32,6 -61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv deleted file mode 100644 index 1395a419102..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'dolphins'), ('graph_directed', True), ('start_vertex', 16)).csv +++ /dev/null @@ -1,63 +0,0 @@ -,vertex,distance -0,16,0 -1,14,1 -2,20,1 -3,33,1 -4,37,1 -5,38,1 -6,50,1 -7,0,2 -8,3,2 -9,24,2 -10,34,2 -11,40,2 -12,43,2 -13,52,2 -14,8,2 -15,18,2 -16,28,2 -17,36,2 -18,44,2 -19,47,2 -20,12,2 -21,21,2 -22,45,2 -23,61,2 -24,58,2 -25,42,2 -26,51,2 -27,10,3 -28,15,3 -29,59,3 -30,29,3 -31,49,3 -32,7,3 -33,46,3 -34,53,3 -35,1,3 -36,30,3 -37,23,3 -38,39,3 -39,2,3 -40,4,3 -41,11,3 -42,55,3 -43,35,4 -44,19,4 -45,27,4 -46,54,4 -47,17,4 -48,26,4 -49,41,4 -50,57,4 -51,25,5 -52,6,5 -53,13,5 -54,9,5 -55,22,5 -56,31,5 -57,5,5 -58,48,5 -59,56,6 -60,32,6 -61,60,7 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv deleted file mode 100644 index 2240fd7b022..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', False), ('start_vertex', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 -5,4,2 -6,5,2 -7,6,2 -8,8,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,17,2 -14,19,2 -15,21,2 -16,31,2 -17,30,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,16,3 -23,33,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv deleted file mode 100644 index 2240fd7b022..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate'), ('graph_directed', True), ('start_vertex', 7)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,7,0 -1,0,1 -2,1,1 -3,2,1 -4,3,1 -5,4,2 -6,5,2 -7,6,2 -8,8,2 -9,10,2 -10,11,2 -11,12,2 -12,13,2 -13,17,2 -14,19,2 -15,21,2 -16,31,2 -17,30,2 -18,9,2 -19,27,2 -20,28,2 -21,32,2 -22,16,3 -23,33,3 -24,24,3 -25,25,3 -26,23,3 -27,14,3 -28,15,3 -29,18,3 -30,20,3 -31,22,3 -32,29,3 -33,26,4 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv deleted file mode 100644 index a46f001b4ea..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', False), ('start_vertex', 19)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 -4,2,2 -5,3,2 -6,4,2 -7,5,2 -8,6,2 -9,7,2 -10,8,2 -11,10,2 -12,11,2 -13,12,2 -14,13,2 -15,17,2 -16,21,2 -17,31,2 -18,30,2 -19,9,2 -20,14,2 -21,15,2 -22,18,2 -23,20,2 -24,22,2 -25,23,2 -26,26,2 -27,27,2 -28,28,2 -29,29,2 -30,32,2 -31,16,3 -32,24,3 -33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv deleted file mode 100644 index a46f001b4ea..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'karate-disjoint'), ('graph_directed', True), ('start_vertex', 19)).csv +++ /dev/null @@ -1,35 +0,0 @@ -,vertex,distance -0,19,0 -1,0,1 -2,1,1 -3,33,1 -4,2,2 -5,3,2 -6,4,2 -7,5,2 -8,6,2 -9,7,2 -10,8,2 -11,10,2 -12,11,2 -13,12,2 -14,13,2 -15,17,2 -16,21,2 -17,31,2 -18,30,2 -19,9,2 -20,14,2 -21,15,2 -22,18,2 -23,20,2 -24,22,2 -25,23,2 -26,26,2 -27,27,2 -28,28,2 -29,29,2 -30,32,2 -31,16,3 -32,24,3 -33,25,3 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', False), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv b/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv deleted file mode 100644 index b35d461bbe6..00000000000 --- a/python/cugraph/cugraph/testing/results/(('algo', 'nx.single_source_shortest_path_length'), ('cutoff', None), ('graph_dataset', 'netscience'), ('graph_directed', True), ('start_vertex', 1237)).csv +++ /dev/null @@ -1,3 +0,0 @@ -,vertex,distance -0,1237,0 -1,1238,1 diff --git a/python/cugraph/cugraph/testing/resultset_current.py b/python/cugraph/cugraph/testing/resultset.py similarity index 79% rename from python/cugraph/cugraph/testing/resultset_current.py rename to python/cugraph/cugraph/testing/resultset.py index e8086ce0fdc..0bc06bb38d7 100644 --- a/python/cugraph/cugraph/testing/resultset_current.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -15,6 +15,7 @@ import random from pathlib import Path +# import cupy as cp import numpy as np import cudf @@ -40,15 +41,16 @@ def add_resultset(result_data_dictionary, **kwargs): _resultsets[hashable_dict_repr] = rs -"""def get_resultset(**kwargs): - hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - return _resultsets.get(hashable_dict_repr)""" - - -def get_resultset(**kwargs): +def get_resultset(category, **kwargs): # THIS IS CALLED IN TESTS hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - path = results_dir / (str(hashable_dict_repr) + ".csv") + mappings_path = results_dir / (category + "_mappings.csv") + mappings = cudf.read_csv(mappings_path) + results_filename = mappings[ + mappings["hashable_dict_repr"] == str(hashable_dict_repr) + ]["filename"].iloc[0] + # The assumption is that results_filename already includes the algorithm category + path = results_dir / results_filename # path = Path("https://data.rapids.ai/cugraph/results/" / path return cudf.read_csv(path) @@ -91,12 +93,11 @@ def get_resultset(**kwargs): add_resultset( {"vertex": vertices, "distance": distances}, graph_dataset=ds.metadata["name"], - graph_directed=dirctd, - algo="nx.single_source_shortest_path_length", - start_vertex=start_vertex, - cutoff=depth_limit, + graph_directed=str(dirctd), + algo="single_source_shortest_path_length", + start_vertex=str(start_vertex), + cutoff=str(depth_limit), ) - # prob don't need to store in resultset # test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex # these are pandas dataframes @@ -108,9 +109,9 @@ def get_resultset(**kwargs): add_resultset( cugraph_df, graph_dataset="karate", - graph_directed=dirctd, - algo="nx.bfs_edges", - source=7, + graph_directed=str(dirctd), + algo="bfs_edges", + source="7", ) @@ -131,9 +132,9 @@ def get_resultset(**kwargs): add_resultset( {"vertex": vertices, "distance": distances}, graph_dataset=ds.metadata["name"], - graph_directed=True, - algo="nx.single_source_dijkstra_path_length", - source=source, + graph_directed="True", + algo="single_source_dijkstra_path_length", + source=str(source), ) M = utils.read_csv_for_nx(ds.get_path(), read_weights_in_sp=True) @@ -163,10 +164,10 @@ def get_resultset(**kwargs): add_resultset( {"vertex": vertices_datatypeconv, "distance": distances_datatypeconv}, graph_dataset=ds.metadata["name"], - graph_directed=True, - algo="nx.single_source_dijkstra_path_length", + graph_directed="True", + algo="single_source_dijkstra_path_length", test="data_type_conversion", - source=source, + source=str(source), ) for dirctd in DIRECTED_GRAPH_OPTIONS: @@ -185,9 +186,9 @@ def get_resultset(**kwargs): add_resultset( cugraph.sssp(Gnx, source), graph_dataset="karate", - graph_directed=dirctd, - algo="cu.sssp_nonnative", - source=source, + graph_directed=str(dirctd), + algo="sssp_nonnative", + source=str(source), ) G = nx.Graph() @@ -195,7 +196,7 @@ def get_resultset(**kwargs): G.add_edge(1, 2, other=20) df = cugraph.sssp(G, 0, edge_attr="other") # test_sssp_results["network_edge_attr"] = df -add_resultset(df, algo="cu.sssp_nonnative", test="network_edge_attr") +add_resultset(df, algo="sssp_nonnative", test="network_edge_attr") # ============================================================================= # tests/traversal/test_paths.py @@ -218,8 +219,6 @@ def get_resultset(**kwargs): "disconnected": [("1", "10"), ("1", "8")], } -# test_paths_results = {} - # CONNECTED_GRAPH with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: graph_tf.writelines(DISCONNECTED_GRAPH) @@ -227,33 +226,35 @@ def get_resultset(**kwargs): Gnx_DIS = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") -"""test_paths_results["1,notarget,nx"] = nx.shortest_path_length( - Gnx_DIS, source="1", weight="weight" -)""" vertices = cudf.Series(res1.keys()) distances = cudf.Series(res1.values()) add_resultset( {"vertex": vertices, "distance": distances}, - algo="nx.shortest_path_length", + algo="shortest_path_length", graph_dataset="DISCONNECTED", - graph_directed=True, + graph_directed="True", source="1", weight="weight", ) -res2 = cugraph.shortest_path_length(Gnx_DIS, "1") -# test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length(Gnx_DIS, "1") -add_resultset( - res2, - algo="cu.shortest_path_length", - graph_dataset="DISCONNECTED", - graph_directed=True, - source="1", - weight="weight", -) +traversal_mappings = cudf.DataFrame(columns=["hashable_dict_repr", "filename"]) + + +random.seed(24) # Generating ALL results files for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() - res.to_csv(results_dir / (str(temp) + ".csv")) - # print(temp) + # Currently, only traversal results files are generated + temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" + temp_mapping = cudf.DataFrame( + [[str(temp), temp_filename]], columns=["hashable_dict_repr", "filename"] + ) + traversal_mappings = cudf.concat( + [traversal_mappings, temp_mapping], axis=0, ignore_index=True + ) + print(temp_filename) + # print("traversal_" + temp_filename) + res.to_csv(results_dir / temp_filename, index=False) + +traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False) diff --git a/python/cugraph/cugraph/testing/resultset_old.py b/python/cugraph/cugraph/testing/resultset_old.py deleted file mode 100644 index 677ee85f2a6..00000000000 --- a/python/cugraph/cugraph/testing/resultset_old.py +++ /dev/null @@ -1,251 +0,0 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. -# 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 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from tempfile import NamedTemporaryFile -import random -import os -from pathlib import Path - -# import pandas as pd -# import cupy as cp -import numpy as np - -import cudf -import networkx as nx -import cugraph -from cugraph.experimental.datasets import ( - dolphins, - netscience, - karate_disjoint, - karate, - polbooks, -) -from cugraph.testing import utils - -default_results_upload_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" -alt_results_dir = Path("testing/nxresults") - -# This script is intended to generate all results for all results files. -# Currently, its location is in testing, but that won't be the final location -# ============================================================================= -# Parameters -# ============================================================================= -# This will be refactored once the datasets variables are fixed/changed -SEEDS = [42] - -DIRECTED_GRAPH_OPTIONS = [True, False] - -DEPTH_LIMITS = [None, 1, 5, 18] - -DATASETS = [dolphins, netscience, karate_disjoint] - -DATASETS_SMALL = [karate, dolphins, polbooks] - - -# ============================================================================= -# tests/traversal/test_bfs.py -# ============================================================================= -test_bfs_results = {} - - -for ds in DATASETS + [karate]: - for seed in SEEDS: - for depth_limit in DEPTH_LIMITS: - for dirctd in DIRECTED_GRAPH_OPTIONS: - # this does the work of get_cu_graph_nx_results_and_params - Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=dirctd) - - random.seed(seed) - start_vertex = random.sample(list(Gnx.nodes()), 1)[0] - nx_values = nx.single_source_shortest_path_length( - Gnx, start_vertex, cutoff=depth_limit - ) - - test_bfs_results[ - "{},{},{},{}".format(seed, depth_limit, ds, dirctd) - ] = nx_values - test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex - -for dirctd in DIRECTED_GRAPH_OPTIONS: - Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) - result = cugraph.bfs_edges(Gnx, source=7) - cugraph_df = cudf.from_pandas(result) - test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df - - -# ============================================================================= -# tests/traversal/test_sssp.py -# ============================================================================= -test_sssp_results = {} - -SOURCES = [1] - -for ds in DATASETS_SMALL: - for source in SOURCES: - Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) - test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths - - M = utils.read_csv_for_nx(ds.get_path(), read_weights_in_sp=True) - edge_attr = "weight" - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr=edge_attr, - create_using=nx.DiGraph(), - ) - - M["weight"] = M["weight"].astype(np.int32) - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr="weight", - create_using=nx.DiGraph(), - ) - test_sssp_results[ - "nx_paths,data_type_conversion,{}".format(ds) - ] = nx.single_source_dijkstra_path_length(Gnx, source) - -for dirctd in DIRECTED_GRAPH_OPTIONS: - for source in SOURCES: - Gnx = utils.generate_nx_graph_from_file( - karate.get_path(), directed=dirctd, edgevals=True - ) - if dirctd: - test_sssp_results[ - "nonnative_input,nx.DiGraph,{}".format(source) - ] = cugraph.sssp(Gnx, source) - else: - test_sssp_results[ - "nonnative_input,nx.Graph,{}".format(source) - ] = cugraph.sssp(Gnx, source) - - -G = nx.Graph() -G.add_edge(0, 1, other=10) -G.add_edge(1, 2, other=20) -df = cugraph.sssp(G, 0, edge_attr="other") -test_sssp_results["network_edge_attr"] = df - - -# ============================================================================= -# tests/traversal/test_paths.py -# ============================================================================= -CONNECTED_GRAPH = """1,5,3 -1,4,1 -1,2,1 -1,6,2 -1,7,2 -4,5,1 -2,3,1 -7,6,2 -""" - -DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" - -paths = [("1", "1"), ("1", "5"), ("1", "3"), ("1", "6")] -invalid_paths = { - "connected": [("-1", "1"), ("0", "42")], - "disconnected": [("1", "10"), ("1", "8")], -} - -test_paths_results = {} - -# CONNECTED_GRAPH -with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: - graph_tf.writelines(CONNECTED_GRAPH) - graph_tf.seek(0) - Gnx = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") - - graph_tf.writelines(DISCONNECTED_GRAPH) - graph_tf.seek(0) - Gnx_DIS = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") - -for path in paths: - nx_path_length = nx.shortest_path_length( - Gnx, path[0], target=path[1], weight="weight" - ) - cu_path_length = cugraph.shortest_path_length(Gnx, path[0], target=path[1]) - test_paths_results[ - "{},{},{},nx".format(path[0], path[1], "connected") - ] = nx_path_length - test_paths_results[ - "{},{},{},cu".format(path[0], path[1], "connected") - ] = cu_path_length - -# INVALID -for graph in ["connected", "disconnected"]: - if graph == "connected": - G = Gnx - else: - G = Gnx_DIS - paths = invalid_paths[graph] - for path in paths: - try: - test_paths_results[ - "{},{},{},invalid".format(path[0], path[1], graph) - ] = cugraph.shortest_path_length(G, path[0], path[1]) - except ValueError: - test_paths_results[ - "{},{},{},invalid".format(path[0], path[1], graph) - ] = "ValueError" - -# test_shortest_path_length_no_target -res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") -test_paths_results["1,notarget,nx"] = res1 -# res1 = cudf.DataFrame.from_dict(res1, orient="index") -# res1.to_csv(alt_results_dir / "nx/spl/DISCONNECTEDnx/1.csv", index=True) - -res2 = cugraph.shortest_path_length(Gnx_DIS, "1") -test_paths_results["1,notarget,cu"] = res2 -# res2.to_csv(alt_results_dir / "cugraph/spl/DISCONNECTEDnx/1.csv", index=False) - - -# serial_bfs_results = pickle.dumps(test_bfs_results) -# serial_sssp_results = pickle.dumps(test_sssp_results) -# serial_paths_results = pickle.dumps(test_paths_results) - -# One way of generating pkl files (NOW OUTDATED) -# pickle.dump(test_bfs_results, open("testing/bfs_results.pkl", "wb")) -# pickle.dump(test_sssp_results, open("testing/sssp_results.pkl", "wb")) -# pickle.dump(test_paths_results, open("testing/paths_results.pkl", "wb")) - -# Another way of generating pkl files (NOW OUTDATED) -"""pickle.dump( - test_bfs_results, open(default_results_upload_dir / "bfs_results.pkl", "wb") -) -pickle.dump( - test_sssp_results, open(default_results_upload_dir / "sssp_results.pkl", "wb") -) -pickle.dump( - test_paths_results, open(default_results_upload_dir / "paths_results.pkl", "wb") -)""" - -# Example of how ResultSet is used in each individual testing script -# my_bfs_results = ResultSet(local_result_file="bfs_results.pkl") -# my_sssp_results = ResultSet(local_result_file="sssp_results.pkl") -# my_paths_results = ResultSet(local_result_file="paths_results.pkl") - -# GETTERS (these are now unused and ready to be gone) -"""def get_bfs_results(test_params): - return test_bfs_results[test_params] - - -def get_sssp_results(test_params): - return test_sssp_results[test_params] - - -def get_paths_results(test_params): - return test_paths_results[test_params]""" diff --git a/python/cugraph/cugraph/tests/traversal/BLUEPRINT.py b/python/cugraph/cugraph/tests/traversal/BLUEPRINT.py deleted file mode 100644 index cab1eaf82ac..00000000000 --- a/python/cugraph/cugraph/tests/traversal/BLUEPRINT.py +++ /dev/null @@ -1,50 +0,0 @@ -import pytest - -import cugraph -from python.cugraph.cugraph.testing.resultset_pr import get_resultset -from cudf.testing import assert_frame_equal - -karate_test_data = [ - [0.6, 50, get_resultset], - [0.6, 75, get_resultset], - [0.6, 100, get_resultset], - [0.6, -100, OverflowError], - [0.75, 50, get_resultset], - [0.75, 75, get_resultset], - [0.75, 100, get_resultset], - [0.85, 50, get_resultset], - [0.85, 75, get_resultset], - [0.85, 100, get_resultset], -] - -@pytest.fixture(params=[pytest.param(p) for p in karate_test_data]) -def test_data(request): - alpha, max_iter, expected_result = request.param - breakpoint() - if (type(expected_result) != type) and callable(expected_result): - expected_result = expected_result(graph_dataset="karate", - graph_directed=False, - algo="pagerank", - alpha=alpha, - max_iter=max_iter).get_cudf_dataframe() - return (alpha, max_iter, expected_result) - - -######################################## -def test_pagerank(test_data): - (alpha, max_iter, expected_result) = test_data - G = cugraph.experimental.datasets.karate.get_graph() - - if (type(expected_result) == type) and issubclass(expected_result, Exception): - with pytest.raises(expected_result): - cugraph.pagerank(G, alpha=alpha, max_iter=max_iter) - else: - pr = cugraph.pagerank(G, alpha=alpha, max_iter=max_iter) - pr = pr.sort_values("vertex", ignore_index=True) - expected_result = expected_result.sort_values("vertex", ignore_index=True) - expected_result["pagerank"] = expected_result["pagerank"].astype("float32") - assert_frame_equal(pr, - expected_result, - check_like=True, - check_dtype=False, - atol=1e-2) \ No newline at end of file diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_new.py b/python/cugraph/cugraph/tests/traversal/test_bfs.py similarity index 97% rename from python/cugraph/cugraph/tests/traversal/test_bfs_new.py rename to python/cugraph/cugraph/tests/traversal/test_bfs.py index 028be0e5aa4..27e1a52da92 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs_new.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs.py @@ -267,15 +267,14 @@ def get_cu_graph_nx_results_and_params( Helper for fixtures returning Nx results and params. """ start_vertex = DATASET_STARTS[dataset_name] - nx_values = get_resultset( - algo="nx.single_source_shortest_path_length", - cutoff=depth_limit, + category="traversal", + algo="single_source_shortest_path_length", + cutoff=str(depth_limit), graph_dataset=dataset_name, - graph_directed=directed, - start_vertex=start_vertex, + graph_directed=str(directed), + start_vertex=str(start_vertex), ) - nx_values = nx_values.drop(columns="Unnamed: 0") nx_values = cudf.Series(nx_values.distance.values, index=nx_values.vertex).to_dict() return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) @@ -414,7 +413,6 @@ def test_bfs_nonnative_inputs_matrix( @pytest.mark.sg def test_bfs_nonnative_inputs_nx( - gpubenchmark, single_dataset_nxresults_startvertex_spc, ): ( @@ -427,12 +425,12 @@ def test_bfs_nonnative_inputs_nx( ) = single_dataset_nxresults_startvertex_spc cugraph_df = get_resultset( - algo="nx.bfs_edges", + category="traversal", + algo="bfs_edges", graph_dataset="karate", - graph_directed=directed, - source=start_vertex, + graph_directed=str(directed), + source=str(start_vertex), ) - cugraph_df = cugraph_df.drop(columns="Unnamed: 0") compare_func = _compare_bfs compare_func(cugraph_df, nx_values, start_vertex) @@ -440,9 +438,7 @@ def test_bfs_nonnative_inputs_nx( @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs_invalid_start( - gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type -): +def test_bfs_invalid_start(dataset_nxresults_startvertex_spc, cugraph_input_type): (G, _, _, _, start_vertex, depth_limit) = dataset_nxresults_startvertex_spc el = G.view_edge_list() diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_new.py b/python/cugraph/cugraph/tests/traversal/test_paths.py similarity index 85% rename from python/cugraph/cugraph/tests/traversal/test_paths_new.py rename to python/cugraph/cugraph/tests/traversal/test_paths.py index 94289a8e26c..d5cfa02b0d4 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths_new.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths.py @@ -15,6 +15,7 @@ from tempfile import NamedTemporaryFile import math +import numpy as np import cudf from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix import cupy @@ -40,19 +41,17 @@ paths_test_data = { "nx.shortest_path_length_1_1": 0, - "cu.shortest_path_length_1_1": 0.0, + # "cu.shortest_path_length_1_1": 0.0, "nx.shortest_path_length_1_5": 2.0, - "cu.shortest_path_length_1_5": 2.0, + # "cu.shortest_path_length_1_5": 2.0, "nx.shortest_path_length_1_3": 2.0, - "cu.shortest_path_length_1_3": 2.0, + # "cu.shortest_path_length_1_3": 2.0, "nx.shortest_path_length_1_6": 2.0, - "cu.shortest_path_length_1_6": 2.0, + # "cu.shortest_path_length_1_6": 2.0, "cu.shortest_path_length_nx_-1_1": ValueError, "cu.shortest_path_length_nx_1_10": ValueError, "cu.shortest_path_length_nx_0_42": ValueError, "cu.shortest_path_length_nx_1_8": 3.4028235e38, - # "nx.shortest_path_length_1_all": get_resultset, - # "cu.shortest_path_length_1_all": get_resultset, } @@ -103,25 +102,25 @@ def test_connected_graph_shortest_path_length(graphs): path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) assert path_1_to_1_length == 0.0 assert path_1_to_1_length == paths_test_data["nx.shortest_path_length_1_1"] - assert path_1_to_1_length == paths_test_data["cu.shortest_path_length_1_1"] + # assert path_1_to_1_length == paths_test_data["cu.shortest_path_length_1_1"] assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) assert path_1_to_5_length == 2.0 assert path_1_to_5_length == paths_test_data["nx.shortest_path_length_1_5"] - assert path_1_to_5_length == paths_test_data["cu.shortest_path_length_1_5"] + # assert path_1_to_5_length == paths_test_data["cu.shortest_path_length_1_5"] assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) assert path_1_to_3_length == 2.0 assert path_1_to_3_length == paths_test_data["nx.shortest_path_length_1_3"] - assert path_1_to_3_length == paths_test_data["cu.shortest_path_length_1_3"] + # assert path_1_to_3_length == paths_test_data["cu.shortest_path_length_1_3"] assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) assert path_1_to_6_length == 2.0 assert path_1_to_6_length == paths_test_data["nx.shortest_path_length_1_6"] - assert path_1_to_6_length == paths_test_data["cu.shortest_path_length_1_6"] + # assert path_1_to_6_length == paths_test_data["cu.shortest_path_length_1_6"] assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) @@ -187,8 +186,10 @@ def test_shortest_path_length_no_path(graphs): path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) assert path_1_to_8 == sys.float_info.max - # Not sure why this assertion now fails - assert paths_test_data["cu.shortest_path_length_nx_1_8"] in [ + + nx_path_1_to_8 = paths_test_data["cu.shortest_path_length_nx_1_8"] + nx_path_1_to_8 = np.float32(nx_path_1_to_8) + assert nx_path_1_to_8 in [ max_float_32, path_1_to_8, ] @@ -202,28 +203,17 @@ def test_shortest_path_length_no_target(graphs): cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) nx_path_1_to_all = get_resultset( - algo="nx.shortest_path_length", - graph_dataset="DISCONNECTED", - graph_directed=True, - source="1", - weight="weight", - ) - nx_path_1_to_all = nx_path_1_to_all.drop(columns="Unnamed: 0") - nx_gpu_path_1_to_all = get_resultset( - algo="cu.shortest_path_length", + category="traversal", + algo="shortest_path_length", graph_dataset="DISCONNECTED", - graph_directed=True, + graph_directed=str(True), source="1", weight="weight", ) - nx_gpu_path_1_to_all = nx_gpu_path_1_to_all.drop(columns="Unnamed: 0") - cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) # Cast networkx graph on cugraph vertex column type from str to int. # SSSP preserves vertex type, convert for comparison - nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") - assert cugraph_path_1_to_all == nx_gpu_path_1_to_all assert cugraph_path_1_to_all == cupy_path_1_to_all # results for vertex 8 and 9 are not returned diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp_new.py b/python/cugraph/cugraph/tests/traversal/test_sssp.py similarity index 93% rename from python/cugraph/cugraph/tests/traversal/test_sssp_new.py rename to python/cugraph/cugraph/tests/traversal/test_sssp.py index 53bd93b4f11..674b792ef74 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp_new.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp.py @@ -46,8 +46,6 @@ } cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] -# sssp_results = ResultSet(local_result_file="sssp_results.pkl") - # ============================================================================= # Pytest Setup / Teardown - called for each test function @@ -132,26 +130,27 @@ def networkx_call(graph_file, source, edgevals=True): if edgevals is False: # FIXME: no test coverage if edgevals is False, this assertion is never reached assert False - # nx_paths = sssp_results.results["{},{},ssspl".format(dataset_name, source)] nx_paths = get_resultset( - algo="nx.single_source_shortest_path_length", + category="traversal", + algo="single_source_shortest_path_length", graph_dataset=dataset_name, - graph_directed=True, - source=source, + graph_directed=str(True), + source=str(source), ) else: # FIXME: The nx call below doesn't return accurate results as it seems to # not support 'weights'. It matches cuGraph result only if the weight column # is 1s. - # nx_paths = sssp_results.results["{},{},ssdpl".format(dataset_name, source)] nx_paths = get_resultset( - algo="nx.single_source_dijkstra_path_length", + category="traversal", + algo="single_source_dijkstra_path_length", graph_dataset=dataset_name, - graph_directed=True, - source=source, + graph_directed=str(True), + source=str(source), ) - nx_paths = nx_paths.drop(columns="Unnamed: 0") + # nx_paths = nx_paths.drop(columns="Unnamed: 0") nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() + G = graph_file.get_graph( create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals ) @@ -261,23 +260,19 @@ def test_sssp_nonnative_inputs_matrix( test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) +# MARK @pytest.mark.sg @pytest.mark.parametrize("directed", [True, False]) -def test_sssp_nonnative_inputs_nx( - gpubenchmark, single_dataset_source_nxresults, directed -): +def test_sssp_nonnative_inputs_nx(single_dataset_source_nxresults, directed): (_, _, graph_file, source, nx_paths) = single_dataset_source_nxresults dataset_name = graph_file.metadata["name"] - # result = sssp_results.results[ - # "nonnative_input,{},{}".format(cugraph_input_type, source) - # ] result = get_resultset( - algo="cu.sssp_nonnative", + category="traversal", + algo="sssp_nonnative", graph_dataset=dataset_name, - graph_directed=directed, - source=source, + graph_directed=str(directed), + source=str(source), ) - result = result.drop(columns="Unnamed: 0") if np.issubdtype(result["distance"].dtype, np.integer): max_val = np.iinfo(result["distance"].dtype).max else: @@ -313,7 +308,7 @@ def test_sssp_edgevals( gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type ): # Extract the params generated from the fixture - (G, _, dataset, source, nx_paths) = dataset_source_nxresults_weighted + (G, _, _, source, nx_paths) = dataset_source_nxresults_weighted input_G_or_matrix = G cu_paths, max_val = cugraph_call( @@ -375,17 +370,14 @@ def test_sssp_data_type_conversion(graph_file, source): dist_np = df["distance"].to_numpy() pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - # nx_paths = sssp_results.results[ - # "nx_paths,data_type_conversion,{}".format(dataset_name) - # ] nx_paths = get_resultset( - algo="nx.single_source_dijkstra_path_length", + category="traversal", + algo="single_source_dijkstra_path_length", graph_dataset=dataset_name, - graph_directed=True, - source=source, + graph_directed=str(True), + source=str(source), test="data_type_conversion", ) - nx_paths = nx_paths.drop(columns="Unnamed: 0") nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() # Calculating mismatch @@ -414,9 +406,9 @@ def test_sssp_data_type_conversion(graph_file, source): @pytest.mark.sg def test_sssp_networkx_edge_attr(): - # df = sssp_results.results["network_edge_attr"] - df = get_resultset(algo="cu.sssp_nonnative", test="network_edge_attr") - df = df.drop(columns="Unnamed: 0") + df = get_resultset( + category="traversal", algo="sssp_nonnative", test="network_edge_attr" + ) df = df.set_index("vertex") assert df.loc[0, "distance"] == 0 assert df.loc[1, "distance"] == 10 From 9885c8596f8ecde2ab14f19f2bfbc0da462aa6b3 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Mon, 24 Jul 2023 23:03:14 +0000 Subject: [PATCH 06/20] Removed old traversal tests and kept only resultset data --- .../cugraph/tests/traversal/test_bfs_old.py | 481 ---------------- .../tests/traversal/test_bfs_withnx.py | 479 ---------------- .../cugraph/tests/traversal/test_paths_old.py | 237 -------- .../tests/traversal/test_paths_withnx.py | 208 ------- .../cugraph/tests/traversal/test_sssp_old.py | 520 ------------------ .../tests/traversal/test_sssp_withnx.py | 519 ----------------- 6 files changed, 2444 deletions(-) delete mode 100644 python/cugraph/cugraph/tests/traversal/test_bfs_old.py delete mode 100644 python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py delete mode 100644 python/cugraph/cugraph/tests/traversal/test_paths_old.py delete mode 100644 python/cugraph/cugraph/tests/traversal/test_paths_withnx.py delete mode 100644 python/cugraph/cugraph/tests/traversal/test_sssp_old.py delete mode 100644 python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_old.py b/python/cugraph/cugraph/tests/traversal/test_bfs_old.py deleted file mode 100644 index e4ff327fbc7..00000000000 --- a/python/cugraph/cugraph/tests/traversal/test_bfs_old.py +++ /dev/null @@ -1,481 +0,0 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. -# 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 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import gc - -# import random - -import pytest -import cupy as cp -import numpy as np -from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix -from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix -from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix -from scipy.sparse import coo_matrix as sp_coo_matrix -from scipy.sparse import csr_matrix as sp_csr_matrix -from scipy.sparse import csc_matrix as sp_csc_matrix -import cudf -from pylibcugraph.testing.utils import gen_fixture_params_product - -import cugraph -from cugraph.testing import utils, ResultSet -from cugraph.experimental import datasets - - -# ============================================================================= -# Parameters -# ============================================================================= -DIRECTED_GRAPH_OPTIONS = [True, False] - -SUBSET_SEED_OPTIONS = [42] - -DEFAULT_EPSILON = 1e-6 - -DEPTH_LIMITS = [None, 1, 5, 18] - -# Map of cuGraph input types to the expected output type for cuGraph -# connected_components calls. -cuGraph_input_output_map = { - cugraph.Graph: cudf.DataFrame, - cp_coo_matrix: tuple, - cp_csr_matrix: tuple, - cp_csc_matrix: tuple, - sp_coo_matrix: tuple, - sp_csr_matrix: tuple, - sp_csc_matrix: tuple, -} -cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] - -bfs_results = ResultSet(local_result_file="bfs_results.pkl") - -bfs_results2 = { - "42,dolphins,starts": 16, - "42,netscience,starts": 1237, - "42,karate-disjoint,starts": 19, - "42,karate,starts": 7, -} - - -# ============================================================================= -# Pytest Setup / Teardown - called for each test function -# ============================================================================= -def setup_function(): - gc.collect() - - -# ============================================================================= -# Helper functions -# ============================================================================= -def convert_output_to_cudf(input_G_or_matrix, cugraph_result): - """ - Convert cugraph_result to a cudf DataFrame. The conversion is based on the - type of input_G_or_matrix, since different input types result in different - cugraph_result types (see cugraph_input_output_map). - """ - input_type = type(input_G_or_matrix) - expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] - assert type(cugraph_result) is expected_return_type - - if expected_return_type is cudf.DataFrame: - return cugraph_result - - # elif expected_return_type is pd.DataFrame: - # return cudf.from_pandas(cugraph_result) - - # A CuPy/SciPy input means the return value will be a 2-tuple of: - # distance: cupy.ndarray - # ndarray of shortest distances between source and vertex. - # predecessor: cupy.ndarray - # ndarray of predecessors of a vertex on the path from source, which - # can be used to reconstruct the shortest paths. - # or a 3-tuple of the above 2 plus - # sp_counter: cupy.ndarray - # for the i'th position in the array, the number of shortest paths - # leading to the vertex at position i in the (input) vertex array. - elif expected_return_type is tuple: - if input_type in cupy_types: - assert type(cugraph_result[0]) is cp.ndarray - assert type(cugraph_result[1]) is cp.ndarray - if len(cugraph_result) == 3: - assert type(cugraph_result[2]) is cp.ndarray - else: - assert type(cugraph_result[0]) is np.ndarray - assert type(cugraph_result[1]) is np.ndarray - if len(cugraph_result) == 3: - assert type(cugraph_result[2]) is np.ndarray - - # Get unique verts from input since they are not incuded in output - if type(input_G_or_matrix) in [ - cp_csr_matrix, - cp_csc_matrix, - sp_csr_matrix, - sp_csc_matrix, - ]: - coo = input_G_or_matrix.tocoo(copy=False) - else: - coo = input_G_or_matrix - verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) - dists = [n.item() for n in cugraph_result[0]] - preds = [n.item() for n in cugraph_result[1]] - assert len(verts) == len(dists) == len(preds) - - d = {"vertex": verts, "distance": dists, "predecessor": preds} - - if len(cugraph_result) == 3: - counters = [n.item() for n in cugraph_result[2]] - assert len(counters) == len(verts) - d.update({"sp_counter": counters}) - - return cudf.DataFrame(d) - - else: - raise RuntimeError(f"unsupported return type: {expected_return_type}") - - -# NOTE: We need to use relative error, the values of the shortest path -# counters can reach extremely high values 1e+80 and above -def compare_single_sp_counter(result, expected, epsilon=DEFAULT_EPSILON): - return np.isclose(result, expected, rtol=epsilon) - - -def compare_bfs(benchmark_callable, G, nx_values, start_vertex, depth_limit): - """ - Generate both cugraph and reference bfs traversal. - """ - if isinstance(start_vertex, int): - result = benchmark_callable(cugraph.bfs_edges, G, start_vertex) - cugraph_df = convert_output_to_cudf(G, result) - compare_func = _compare_bfs - - # NOTE: We need to take 2 different path for verification as the nx - # functions used as reference return dictionaries that might - # not contain all the vertices while the cugraph version return - # a cudf.DataFrame with all the vertices, also some verification - # become slow with the data transfer - compare_func(cugraph_df, nx_values, start_vertex) - - elif isinstance(start_vertex, list): # For other Verifications - all_nx_values = nx_values - all_cugraph_distances = [] - - def func_to_benchmark(): - for sv in start_vertex: - cugraph_df = cugraph.bfs_edges(G, sv, depth_limit=depth_limit) - all_cugraph_distances.append(cugraph_df) - - benchmark_callable(func_to_benchmark) - - compare_func = _compare_bfs - for (i, sv) in enumerate(start_vertex): - cugraph_df = convert_output_to_cudf(G, all_cugraph_distances[i]) - - compare_func(cugraph_df, all_nx_values[i], sv) - - else: # Unknown type given to seed - raise NotImplementedError("Invalid type for start_vertex") - - -def _compare_bfs(cugraph_df, nx_distances, source): - # This call should only contain 3 columns: - # 'vertex', 'distance', 'predecessor' - # It also confirms wether or not 'sp_counter' has been created by the call - # 'sp_counter' triggers atomic operations in BFS, thus we want to make - # sure that it was not the case - # NOTE: 'predecessor' is always returned while the C++ function allows to - # pass a nullptr - assert len(cugraph_df.columns) == 3, ( - "The result of the BFS has an invalid " "number of columns" - ) - cu_distances = { - vertex: dist - for vertex, dist in zip( - cugraph_df["vertex"].to_numpy(), cugraph_df["distance"].to_numpy() - ) - } - cu_predecessors = { - vertex: dist - for vertex, dist in zip( - cugraph_df["vertex"].to_numpy(), cugraph_df["predecessor"].to_numpy() - ) - } - - # FIXME: The following only verifies vertices that were reached - # by cugraph's BFS. - # We assume that the distances are given back as integers in BFS - # max_val = np.iinfo(df['distance'].dtype).max - # Unreached vertices have a distance of max_val - - missing_vertex_error = 0 - distance_mismatch_error = 0 - invalid_predecessor_error = 0 - for vertex in nx_distances: - if vertex in cu_distances: - result = cu_distances[vertex] - expected = nx_distances[vertex] - if result != expected: - print( - "[ERR] Mismatch on distances: " - "vid = {}, cugraph = {}, nx = {}".format(vertex, result, expected) - ) - distance_mismatch_error += 1 - if vertex not in cu_predecessors: - missing_vertex_error += 1 - else: - pred = cu_predecessors[vertex] - if vertex != source and pred not in nx_distances: - invalid_predecessor_error += 1 - else: - # The graph is unweighted thus, predecessors are 1 away - if vertex != source and ( - (nx_distances[pred] + 1 != cu_distances[vertex]) - ): - print( - "[ERR] Invalid on predecessors: " - "vid = {}, cugraph = {}".format(vertex, pred) - ) - invalid_predecessor_error += 1 - else: - missing_vertex_error += 1 - assert missing_vertex_error == 0, "There are missing vertices" - assert distance_mismatch_error == 0, "There are invalid distances" - assert invalid_predecessor_error == 0, "There are invalid predecessors" - - -def get_cu_graph_and_params(dataset, directed): - """ - Helper for fixtures returning a cuGraph obj and params. - """ - # create graph - G = dataset.get_graph(create_using=cugraph.Graph(directed=directed)) - dataset_path = dataset.get_path() - dataset_name = dataset.metadata["name"] - return (G, dataset_path, dataset_name, directed) - - -def get_cu_graph_nx_results_and_params( - seed, depth_limit, G, dataset_path, dataset_name, directed -): - """ - Helper for fixtures returning Nx results and params. - """ - # start_vertex = get_bfs_results("{},{},starts".format(seed, dataset_name)) - start_vertex = bfs_results.results["{},{},starts".format(seed, dataset_name)] - - # nx_values = get_bfs_results( - # "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) - # ) - nx_values = bfs_results.results[ - "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) - ] - - return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) - - -# ============================================================================= -# Pytest Fixtures -# ============================================================================= -SEEDS = [pytest.param(s) for s in SUBSET_SEED_OPTIONS] -DIRECTED = [pytest.param(d) for d in DIRECTED_GRAPH_OPTIONS] -DATASETS = [pytest.param(d) for d in datasets.DATASETS] -DATASETS_SMALL = [pytest.param(d) for d in datasets.DATASETS_SMALL] -DEPTH_LIMIT = [pytest.param(d) for d in DEPTH_LIMITS] - -# Call gen_fixture_params_product() to caluculate the cartesian product of -# multiple lists of params. This is required since parameterized fixtures do -# not do this automatically (unlike multiply-parameterized tests). The 2nd -# item in the tuple is a label for the param value used when displaying the -# full test name. -algo_test_fixture_params = gen_fixture_params_product( - (SEEDS, "seed"), (DEPTH_LIMIT, "depth_limit") -) - -graph_fixture_params = gen_fixture_params_product( - (DATASETS, "ds"), (DIRECTED, "dirctd") -) - -small_graph_fixture_params = gen_fixture_params_product( - (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd") -) - - -# The single param list variants are used when only 1 param combination is -# needed (eg. testing non-native input types where tests for other combinations -# was covered elsewhere). -single_algo_test_fixture_params = gen_fixture_params_product( - ([SEEDS[0]], "seed"), ([DEPTH_LIMIT[0]], "depth_limit") -) - -single_small_graph_fixture_params = gen_fixture_params_product( - ([DATASETS_SMALL[0]], "ds"), (DIRECTED, "dirctd") -) - - -# Fixtures that result in a test-per (dataset X directed/undirected) -# combination. These return the path to the dataset, a bool indicating if a -# directed graph is being used, and the Nx graph object. -@pytest.fixture(scope="module", params=graph_fixture_params) -def dataset_nx_results(request): - return get_cu_graph_and_params(*request.param) - - -@pytest.fixture(scope="module", params=small_graph_fixture_params) -def small_dataset_nx_results(request): - return get_cu_graph_and_params(*request.param) - - -@pytest.fixture(scope="module", params=single_small_graph_fixture_params) -def single_small_dataset_nx_results(request): - return get_cu_graph_and_params(*request.param) - - -# Fixtures that result in a test-per (dataset_nx_graph combinations X algo_test -# param combinations) combination. These run Nx BFS on the Nx graph obj and -# return the path to the dataset, if a directed graph is being used, the Nx BFS -# results, the starting vertex for BFS, and flag if shortes path counting was -# used. -@pytest.fixture(scope="module", params=algo_test_fixture_params) -def dataset_nxresults_startvertex_spc(dataset_nx_results, request): - return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_results) - - -@pytest.fixture(scope="module", params=single_algo_test_fixture_params) -def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_results, request): - return get_cu_graph_nx_results_and_params( - *request.param, *single_small_dataset_nx_results - ) - - -"""@pytest.fixture(scope="module") -def dataset_nxresults_allstartvertices_spc(small_dataset_nx_results): - - dataset, directed, Gnx = small_dataset_nx_results - use_spc = True - - start_vertices = [start_vertex for start_vertex in Gnx] - - all_nx_values = [] - for start_vertex in start_vertices: - _, _, nx_sp_counter = nxacb._single_source_shortest_path_basic( - Gnx, start_vertex - ) - nx_values = nx_sp_counter - all_nx_values.append(nx_values) - - return (dataset, directed, all_nx_values, start_vertices, use_spc)""" - - -# ============================================================================= -# Tests -# ============================================================================= -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type): - """ - Test BFS traversal on random source with distance and predecessors - """ - ( - G, - dataset, - directed, - nx_values, - start_vertex, - depth_limit, - ) = dataset_nxresults_startvertex_spc - - if directed: - if isinstance(cugraph_input_type, cugraph.Graph): - cugraph_input_type = cugraph.Graph(directed=True) - - if not isinstance(cugraph_input_type, cugraph.Graph): - G_or_matrix = utils.create_obj_from_csv(dataset, cugraph_input_type) - else: - G_or_matrix = G - - compare_bfs(gpubenchmark, G_or_matrix, nx_values, start_vertex, depth_limit) - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) -def test_bfs_nonnative_inputs_matrix( - gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type -): - test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) -def test_bfs_nonnative_inputs_nx( - gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type -): - ( - _, - _, - directed, - nx_values, - start_vertex, - _, - ) = single_dataset_nxresults_startvertex_spc - - cugraph_df = bfs_results.results[ - "{},{},{}".format("karate", directed, "nonnative-nx") - ] - compare_func = _compare_bfs - compare_func(cugraph_df, nx_values, start_vertex) - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs_invalid_start( - gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type -): - (G, _, _, _, start_vertex, depth_limit) = dataset_nxresults_startvertex_spc - - el = G.view_edge_list() - - newval = max(el.src.max(), el.dst.max()) + 1 - start_vertex = newval - - with pytest.raises(ValueError): - cugraph.bfs(G, start_vertex, depth_limit=depth_limit) - - -@pytest.mark.sg -def test_scipy_api_compat(): - graph_file = datasets.DATASETS[0] - dataset_path = graph_file.get_path() - - input_cugraph_graph = graph_file.get_graph(ignore_weights=True) - - input_coo_matrix = utils.create_obj_from_csv( - dataset_path, cp_coo_matrix, edgevals=True - ) - # Ensure scipy-only options are rejected for cugraph inputs - with pytest.raises(TypeError): - cugraph.bfs(input_cugraph_graph, start=0, directed=False) - with pytest.raises(TypeError): - cugraph.bfs(input_cugraph_graph) # required arg missing - - # Ensure cugraph-compatible options work as expected - cugraph.bfs(input_cugraph_graph, i_start=0) - cugraph.bfs(input_cugraph_graph, i_start=0) - # cannot have start and i_start - with pytest.raises(TypeError): - cugraph.bfs(input_cugraph_graph, start=0, i_start=0) - - # Ensure SciPy options for matrix inputs work as expected - cugraph.bfs(input_coo_matrix, i_start=0) - cugraph.bfs(input_coo_matrix, i_start=0, directed=True) - cugraph.bfs(input_coo_matrix, i_start=0, directed=False) - result = cugraph.bfs(input_coo_matrix, i_start=0) - assert type(result) is tuple - assert len(result) == 2 diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py b/python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py deleted file mode 100644 index 7446b32ee5d..00000000000 --- a/python/cugraph/cugraph/tests/traversal/test_bfs_withnx.py +++ /dev/null @@ -1,479 +0,0 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. -# 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 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import gc -import random - -import pytest -import pandas as pd -import cupy as cp -import numpy as np -from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix -from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix -from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix -from scipy.sparse import coo_matrix as sp_coo_matrix -from scipy.sparse import csr_matrix as sp_csr_matrix -from scipy.sparse import csc_matrix as sp_csc_matrix -import cudf -from pylibcugraph.testing.utils import gen_fixture_params_product - -import cugraph -from cugraph.testing import utils -from cugraph.experimental import datasets - -# Temporarily suppress warnings till networkX fixes deprecation warnings -# (Using or importing the ABCs from 'collections' instead of from -# 'collections.abc' is deprecated, and in 3.8 it will stop working) for -# python 3.7. Also, this import networkx needs to be relocated in the -# third-party group once this gets fixed. -import warnings - -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - import networkx as nx - import networkx.algorithms.centrality.betweenness as nxacb - - -# ============================================================================= -# Parameters -# ============================================================================= -DIRECTED_GRAPH_OPTIONS = [True, False] - -SUBSET_SEED_OPTIONS = [42] - -DEFAULT_EPSILON = 1e-6 - -DEPTH_LIMITS = [None, 1, 5, 18] - -# Map of cuGraph input types to the expected output type for cuGraph -# connected_components calls. -cuGraph_input_output_map = { - cugraph.Graph: cudf.DataFrame, - nx.Graph: pd.DataFrame, - nx.DiGraph: pd.DataFrame, - cp_coo_matrix: tuple, - cp_csr_matrix: tuple, - cp_csc_matrix: tuple, - sp_coo_matrix: tuple, - sp_csr_matrix: tuple, - sp_csc_matrix: tuple, -} -cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] - - -# ============================================================================= -# Pytest Setup / Teardown - called for each test function -# ============================================================================= -def setup_function(): - gc.collect() - - -# ============================================================================= -# Helper functions -# ============================================================================= -def convert_output_to_cudf(input_G_or_matrix, cugraph_result): - """ - Convert cugraph_result to a cudf DataFrame. The conversion is based on the - type of input_G_or_matrix, since different input types result in different - cugraph_result types (see cugraph_input_output_map). - """ - input_type = type(input_G_or_matrix) - expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] - assert type(cugraph_result) is expected_return_type - - if expected_return_type is cudf.DataFrame: - return cugraph_result - - elif expected_return_type is pd.DataFrame: - return cudf.from_pandas(cugraph_result) - - # A CuPy/SciPy input means the return value will be a 2-tuple of: - # distance: cupy.ndarray - # ndarray of shortest distances between source and vertex. - # predecessor: cupy.ndarray - # ndarray of predecessors of a vertex on the path from source, which - # can be used to reconstruct the shortest paths. - # or a 3-tuple of the above 2 plus - # sp_counter: cupy.ndarray - # for the i'th position in the array, the number of shortest paths - # leading to the vertex at position i in the (input) vertex array. - elif expected_return_type is tuple: - if input_type in cupy_types: - assert type(cugraph_result[0]) is cp.ndarray - assert type(cugraph_result[1]) is cp.ndarray - if len(cugraph_result) == 3: - assert type(cugraph_result[2]) is cp.ndarray - else: - assert type(cugraph_result[0]) is np.ndarray - assert type(cugraph_result[1]) is np.ndarray - if len(cugraph_result) == 3: - assert type(cugraph_result[2]) is np.ndarray - - # Get unique verts from input since they are not incuded in output - if type(input_G_or_matrix) in [ - cp_csr_matrix, - cp_csc_matrix, - sp_csr_matrix, - sp_csc_matrix, - ]: - coo = input_G_or_matrix.tocoo(copy=False) - else: - coo = input_G_or_matrix - verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) - dists = [n.item() for n in cugraph_result[0]] - preds = [n.item() for n in cugraph_result[1]] - assert len(verts) == len(dists) == len(preds) - - d = {"vertex": verts, "distance": dists, "predecessor": preds} - - if len(cugraph_result) == 3: - counters = [n.item() for n in cugraph_result[2]] - assert len(counters) == len(verts) - d.update({"sp_counter": counters}) - - return cudf.DataFrame(d) - - else: - raise RuntimeError(f"unsupported return type: {expected_return_type}") - - -# NOTE: We need to use relative error, the values of the shortest path -# counters can reach extremely high values 1e+80 and above -def compare_single_sp_counter(result, expected, epsilon=DEFAULT_EPSILON): - return np.isclose(result, expected, rtol=epsilon) - - -def compare_bfs(benchmark_callable, G, nx_values, start_vertex, depth_limit): - """ - Genereate both cugraph and reference bfs traversal. - """ - if isinstance(start_vertex, int): - result = benchmark_callable(cugraph.bfs_edges, G, start_vertex) - cugraph_df = convert_output_to_cudf(G, result) - compare_func = _compare_bfs - - # NOTE: We need to take 2 different path for verification as the nx - # functions used as reference return dictionaries that might - # not contain all the vertices while the cugraph version return - # a cudf.DataFrame with all the vertices, also some verification - # become slow with the data transfer - compare_func(cugraph_df, nx_values, start_vertex) - - elif isinstance(start_vertex, list): # For other Verifications - all_nx_values = nx_values - all_cugraph_distances = [] - - def func_to_benchmark(): - for sv in start_vertex: - cugraph_df = cugraph.bfs_edges(G, sv, depth_limit=depth_limit) - all_cugraph_distances.append(cugraph_df) - - benchmark_callable(func_to_benchmark) - - compare_func = _compare_bfs - for (i, sv) in enumerate(start_vertex): - cugraph_df = convert_output_to_cudf(G, all_cugraph_distances[i]) - - compare_func(cugraph_df, all_nx_values[i], sv) - - else: # Unknown type given to seed - raise NotImplementedError("Invalid type for start_vertex") - - -def _compare_bfs(cugraph_df, nx_distances, source): - # This call should only contain 3 columns: - # 'vertex', 'distance', 'predecessor' - # It also confirms wether or not 'sp_counter' has been created by the call - # 'sp_counter' triggers atomic operations in BFS, thus we want to make - # sure that it was not the case - # NOTE: 'predecessor' is always returned while the C++ function allows to - # pass a nullptr - assert len(cugraph_df.columns) == 3, ( - "The result of the BFS has an invalid " "number of columns" - ) - cu_distances = { - vertex: dist - for vertex, dist in zip( - cugraph_df["vertex"].to_numpy(), cugraph_df["distance"].to_numpy() - ) - } - cu_predecessors = { - vertex: dist - for vertex, dist in zip( - cugraph_df["vertex"].to_numpy(), cugraph_df["predecessor"].to_numpy() - ) - } - - # FIXME: The following only verifies vertices that were reached - # by cugraph's BFS. - # We assume that the distances are given back as integers in BFS - # max_val = np.iinfo(df['distance'].dtype).max - # Unreached vertices have a distance of max_val - - missing_vertex_error = 0 - distance_mismatch_error = 0 - invalid_predecessor_error = 0 - for vertex in nx_distances: - if vertex in cu_distances: - result = cu_distances[vertex] - expected = nx_distances[vertex] - if result != expected: - print( - "[ERR] Mismatch on distances: " - "vid = {}, cugraph = {}, nx = {}".format(vertex, result, expected) - ) - distance_mismatch_error += 1 - if vertex not in cu_predecessors: - missing_vertex_error += 1 - else: - pred = cu_predecessors[vertex] - if vertex != source and pred not in nx_distances: - invalid_predecessor_error += 1 - else: - # The graph is unweighted thus, predecessors are 1 away - if vertex != source and ( - (nx_distances[pred] + 1 != cu_distances[vertex]) - ): - print( - "[ERR] Invalid on predecessors: " - "vid = {}, cugraph = {}".format(vertex, pred) - ) - invalid_predecessor_error += 1 - else: - missing_vertex_error += 1 - assert missing_vertex_error == 0, "There are missing vertices" - assert distance_mismatch_error == 0, "There are invalid distances" - assert invalid_predecessor_error == 0, "There are invalid predecessors" - - -def get_cu_graph_nx_graph_and_params(dataset, directed): - """ - Helper for fixtures returning a Nx graph obj and params. - """ - # create graph - G = dataset.get_graph(create_using=cugraph.Graph(directed=directed)) - dataset_path = dataset.get_path() - - return ( - G, - dataset_path, - directed, - utils.generate_nx_graph_from_file(dataset_path, directed), - ) - - -def get_cu_graph_nx_results_and_params(seed, depth_limit, G, dataset, directed, Gnx): - """ - Helper for fixtures returning Nx results and params. - """ - random.seed(seed) - start_vertex = random.sample(list(Gnx.nodes()), 1)[0] - - nx_values = nx.single_source_shortest_path_length( - Gnx, start_vertex, cutoff=depth_limit - ) - - return (G, dataset, directed, nx_values, start_vertex, depth_limit) - - -# ============================================================================= -# Pytest Fixtures -# ============================================================================= -SEEDS = [pytest.param(s) for s in SUBSET_SEED_OPTIONS] -DIRECTED = [pytest.param(d) for d in DIRECTED_GRAPH_OPTIONS] -DATASETS = [pytest.param(d) for d in datasets.DATASETS] -DATASETS_SMALL = [pytest.param(d) for d in datasets.DATASETS_SMALL] -DEPTH_LIMIT = [pytest.param(d) for d in DEPTH_LIMITS] - -# Call gen_fixture_params_product() to caluculate the cartesian product of -# multiple lists of params. This is required since parameterized fixtures do -# not do this automatically (unlike multiply-parameterized tests). The 2nd -# item in the tuple is a label for the param value used when displaying the -# full test name. -algo_test_fixture_params = gen_fixture_params_product( - (SEEDS, "seed"), (DEPTH_LIMIT, "depth_limit") -) - -graph_fixture_params = gen_fixture_params_product( - (DATASETS, "ds"), (DIRECTED, "dirctd") -) - -small_graph_fixture_params = gen_fixture_params_product( - (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd") -) - -# The single param list variants are used when only 1 param combination is -# needed (eg. testing non-native input types where tests for other combinations -# was covered elsewhere). -single_algo_test_fixture_params = gen_fixture_params_product( - ([SEEDS[0]], "seed"), ([DEPTH_LIMIT[0]], "depth_limit") -) - -single_small_graph_fixture_params = gen_fixture_params_product( - ([DATASETS_SMALL[0]], "ds"), (DIRECTED, "dirctd") -) - - -# Fixtures that result in a test-per (dataset X directed/undirected) -# combination. These return the path to the dataset, a bool indicating if a -# directed graph is being used, and the Nx graph object. -@pytest.fixture(scope="module", params=graph_fixture_params) -def dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) - - -@pytest.fixture(scope="module", params=small_graph_fixture_params) -def small_dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) - - -@pytest.fixture(scope="module", params=single_small_graph_fixture_params) -def single_small_dataset_nx_graph(request): - return get_cu_graph_nx_graph_and_params(*request.param) - - -# Fixtures that result in a test-per (dataset_nx_graph combinations X algo_test -# param combinations) combination. These run Nx BFS on the Nx graph obj and -# return the path to the dataset, if a directed graph is being used, the Nx BFS -# results, the starting vertex for BFS, and flag if shortes path counting was -# used. -@pytest.fixture(scope="module", params=algo_test_fixture_params) -def dataset_nxresults_startvertex_spc(dataset_nx_graph, request): - return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_graph) - - -@pytest.fixture(scope="module", params=single_algo_test_fixture_params) -def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_graph, request): - return get_cu_graph_nx_results_and_params( - *request.param, *single_small_dataset_nx_graph - ) - - -@pytest.fixture(scope="module") -def dataset_nxresults_allstartvertices_spc(small_dataset_nx_graph): - - dataset, directed, Gnx = small_dataset_nx_graph - use_spc = True - - start_vertices = [start_vertex for start_vertex in Gnx] - - all_nx_values = [] - for start_vertex in start_vertices: - _, _, nx_sp_counter = nxacb._single_source_shortest_path_basic( - Gnx, start_vertex - ) - nx_values = nx_sp_counter - all_nx_values.append(nx_values) - - return (dataset, directed, all_nx_values, start_vertices, use_spc) - - -# ============================================================================= -# Tests -# ============================================================================= -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type): - """ - Test BFS traversal on random source with distance and predecessors - """ - ( - G, - dataset, - directed, - nx_values, - start_vertex, - depth_limit, - ) = dataset_nxresults_startvertex_spc - - # special case: ensure cugraph and Nx Graph types are DiGraphs if - # "directed" is set, since the graph type parameterization is currently - # independent of the directed parameter. Unfortunately this does not - # change the "id" in the pytest output. Ignore for nonnative inputs - if directed: - if isinstance(cugraph_input_type, cugraph.Graph): - cugraph_input_type = cugraph.Graph(directed=True) - elif cugraph_input_type is nx.Graph: - cugraph_input_type = nx.DiGraph - - if not isinstance(cugraph_input_type, cugraph.Graph): - G_or_matrix = utils.create_obj_from_csv(dataset, cugraph_input_type) - else: - G_or_matrix = G - - compare_bfs(gpubenchmark, G_or_matrix, nx_values, start_vertex, depth_limit) - - -@pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_bfs_nonnative_inputs( - gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type -): - test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs_invalid_start( - gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type -): - ( - G, - dataset, - directed, - nx_values, - start_vertex, - depth_limit, - ) = dataset_nxresults_startvertex_spc - - el = G.view_edge_list() - - newval = max(el.src.max(), el.dst.max()) + 1 - start_vertex = newval - - with pytest.raises(ValueError): - cugraph.bfs(G, start_vertex, depth_limit=depth_limit) - - -@pytest.mark.sg -def test_scipy_api_compat(): - graph_file = datasets.DATASETS[0] - dataset_path = graph_file.get_path() - - input_cugraph_graph = graph_file.get_graph(ignore_weights=True) - - input_coo_matrix = utils.create_obj_from_csv( - dataset_path, cp_coo_matrix, edgevals=True - ) - # Ensure scipy-only options are rejected for cugraph inputs - with pytest.raises(TypeError): - cugraph.bfs(input_cugraph_graph, start=0, directed=False) - with pytest.raises(TypeError): - cugraph.bfs(input_cugraph_graph) # required arg missing - - # Ensure cugraph-compatible options work as expected - cugraph.bfs(input_cugraph_graph, i_start=0) - cugraph.bfs(input_cugraph_graph, i_start=0) - # cannot have start and i_start - with pytest.raises(TypeError): - cugraph.bfs(input_cugraph_graph, start=0, i_start=0) - - # Ensure SciPy options for matrix inputs work as expected - cugraph.bfs(input_coo_matrix, i_start=0) - cugraph.bfs(input_coo_matrix, i_start=0, directed=True) - cugraph.bfs(input_coo_matrix, i_start=0, directed=False) - result = cugraph.bfs(input_coo_matrix, i_start=0) - assert type(result) is tuple - assert len(result) == 2 diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_old.py b/python/cugraph/cugraph/tests/traversal/test_paths_old.py deleted file mode 100644 index 877fcf48674..00000000000 --- a/python/cugraph/cugraph/tests/traversal/test_paths_old.py +++ /dev/null @@ -1,237 +0,0 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. -# 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 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import sys -from tempfile import NamedTemporaryFile -import math - -import cudf -from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix -import cupy - -from cugraph.testing import ResultSet, ResultSet2 -import pytest - -import cugraph - - -CONNECTED_GRAPH = """1,5,3 -1,4,1 -1,2,1 -1,6,2 -1,7,2 -4,5,1 -2,3,1 -7,6,2 -""" - -DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" - -paths_results = ResultSet(local_result_file="paths_results.pkl") - -"""paths_results2 = {'1,1,connected,nx': 0, '1,1,connected,cu': 0.0, - '1,5,connected,nx': 2.0, '1,5,connected,cu': 2.0, - '1,3,connected,nx': 2.0, '1,3,connected,cu': 2.0, - '1,6,connected,nx': 2.0, '1,6,connected,cu': 2.0, - '-1,1,connected,invalid': 'ValueError', - '0,42,connected,invalid': 'ValueError', - '1,10,disconnected,invalid': 'ValueError', - '1,8,disconnected,invalid': 3.4028235e+38}""" -connected_test_data = [ - ["1", "1", "nx", 0], - ["1", "1", "cu", 0.0], - ["1", "5", "nx", 2.0], - ["1", "5", "cu", 2.0], - ["1", "3", "nx", 2.0], - ["1", "3", "cu", 2.0], - ["1", "6", "nx", 2.0], - ["1", "6", "cu", 2.0], - ["-1", "1", "invalid", ValueError], - ["0", "42", "invalid", ValueError], -] -disconnected_test_data = [ - ["1", "10", "invalid", ValueError], - ["1", "8", "invalid", 3.4028235e38], -] - - -@pytest.fixture -def graphs(request): - with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: - graph_tf.writelines(request.param) - graph_tf.seek(0) - - cudf_df = cudf.read_csv( - graph_tf.name, - names=["src", "dst", "data"], - delimiter=",", - dtype=["int32", "int32", "float64"], - ) - cugraph_G = cugraph.Graph() - cugraph_G.from_cudf_edgelist( - cudf_df, source="src", destination="dst", edge_attr="data" - ) - - # construct cupy coo_matrix graph - i = [] - j = [] - weights = [] - for index in range(cudf_df.shape[0]): - vertex1 = cudf_df.iloc[index]["src"] - vertex2 = cudf_df.iloc[index]["dst"] - weight = cudf_df.iloc[index]["data"] - i += [vertex1, vertex2] - j += [vertex2, vertex1] - weights += [weight, weight] - i = cupy.array(i) - j = cupy.array(j) - weights = cupy.array(weights) - largest_vertex = max(cupy.amax(i), cupy.amax(j)) - cupy_df = cupy_coo_matrix( - (weights, (i, j)), shape=(largest_vertex + 1, largest_vertex + 1) - ) - - yield cugraph_G, cupy_df - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) -def test_connected_graph_shortest_path_length(graphs): - cugraph_G, cupy_df = graphs - - path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) - assert path_1_to_1_length == 0.0 - assert path_1_to_1_length == paths_results.results["1,1,connected,nx"] - assert path_1_to_1_length == paths_results.results["1,1,connected,cu"] - assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) - - path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) - assert path_1_to_5_length == 2.0 - assert path_1_to_5_length == paths_results.results["1,5,connected,nx"] - assert path_1_to_5_length == paths_results.results["1,5,connected,cu"] - assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) - - path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) - assert path_1_to_3_length == 2.0 - assert path_1_to_3_length == paths_results.results["1,3,connected,nx"] - assert path_1_to_3_length == paths_results.results["1,3,connected,cu"] - assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) - - path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) - assert path_1_to_6_length == 2.0 - assert path_1_to_6_length == paths_results.results["1,6,connected,nx"] - assert path_1_to_6_length == paths_results.results["1,6,connected,cu"] - assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_invalid_source(graphs): - cugraph_G, cupy_df = graphs - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cugraph_G, -1, 1) - - assert "ValueError" == paths_results.results["-1,1,connected,invalid"] - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cupy_df, -1, 1) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_invalid_target(graphs): - cugraph_G, cupy_df = graphs - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cugraph_G, 1, 10) - - assert "ValueError" == paths_results.results["1,10,disconnected,invalid"] - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cupy_df, 1, 10) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_invalid_vertexes(graphs): - cugraph_G, cupy_df = graphs - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cugraph_G, 0, 42) - - assert "ValueError" == paths_results.results["0,42,connected,invalid"] - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cupy_df, 0, 42) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_no_path(graphs): - cugraph_G, cupy_df = graphs - - # FIXME: In case there is no path between two vertices, the - # result can be either the max of float32 or float64 - max_float_32 = (2 - math.pow(2, -23)) * math.pow(2, 127) - - path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) - assert path_1_to_8 == sys.float_info.max - assert paths_results.results["1,8,disconnected,invalid"] in [ - max_float_32, - path_1_to_8, - ] - assert path_1_to_8 == cugraph.shortest_path_length(cupy_df, 1, 8) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_no_target(graphs): - cugraph_G, cupy_df = graphs - - cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - # nx_path_1_to_all = paths_results.results["1,notarget,nx"] - # nx_gpu_path_1_to_all = cudf.DataFrame.from_dict( - # paths_results.results["1,notarget,cu"] - # ) - nx_path_1_to_all = ResultSet2( - lib="nx", alg="shortest_path_length", graph="DISCONNECTEDnx", param="1" - ).results - nx_path_1_to_all = nx_path_1_to_all.rename( - columns={"Unnamed: 0": "vertex", "0": "distance"} - ) - nx_path_1_to_all = nx_path_1_to_all.reset_index("vertex").to_dict()["distance"] - - nx_gpu_path_1_to_all = ResultSet2( - lib="cugraph", alg="shortest_path_length", graph="DISCONNECTEDnx", param="1" - ).results - cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) - - # Cast networkx graph on cugraph vertex column type from str to int. - # SSSP preserves vertex type, convert for comparison - nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") - assert cugraph_path_1_to_all == nx_gpu_path_1_to_all - assert cugraph_path_1_to_all == cupy_path_1_to_all - # results for vertex 8 and 9 are not returned - assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 - - for index in range(cugraph_path_1_to_all.shape[0]): - - vertex = str(cugraph_path_1_to_all["vertex"][index].item()) - distance = cugraph_path_1_to_all["distance"][index].item() - # verify cugraph against networkx - if vertex in {"8", "9"}: - # Networkx does not return distances for these vertexes. - assert distance == sys.float_info.max - else: - assert distance == nx_path_1_to_all[vertex] diff --git a/python/cugraph/cugraph/tests/traversal/test_paths_withnx.py b/python/cugraph/cugraph/tests/traversal/test_paths_withnx.py deleted file mode 100644 index 8938ae74553..00000000000 --- a/python/cugraph/cugraph/tests/traversal/test_paths_withnx.py +++ /dev/null @@ -1,208 +0,0 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. -# 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 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import sys -from tempfile import NamedTemporaryFile -import math - -import cudf -from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix -import cupy -import networkx as nx -import pytest - -import cugraph - - -CONNECTED_GRAPH = """1,5,3 -1,4,1 -1,2,1 -1,6,2 -1,7,2 -4,5,1 -2,3,1 -7,6,2 -""" - -DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" - - -@pytest.fixture -def graphs(request): - with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: - graph_tf.writelines(request.param) - graph_tf.seek(0) - - nx_G = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") - cudf_df = cudf.read_csv( - graph_tf.name, - names=["src", "dst", "data"], - delimiter=",", - dtype=["int32", "int32", "float64"], - ) - cugraph_G = cugraph.Graph() - cugraph_G.from_cudf_edgelist( - cudf_df, source="src", destination="dst", edge_attr="data" - ) - - # construct cupy coo_matrix graph - i = [] - j = [] - weights = [] - for index in range(cudf_df.shape[0]): - vertex1 = cudf_df.iloc[index]["src"] - vertex2 = cudf_df.iloc[index]["dst"] - weight = cudf_df.iloc[index]["data"] - i += [vertex1, vertex2] - j += [vertex2, vertex1] - weights += [weight, weight] - i = cupy.array(i) - j = cupy.array(j) - weights = cupy.array(weights) - largest_vertex = max(cupy.amax(i), cupy.amax(j)) - cupy_df = cupy_coo_matrix( - (weights, (i, j)), shape=(largest_vertex + 1, largest_vertex + 1) - ) - - yield cugraph_G, nx_G, cupy_df - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) -def test_connected_graph_shortest_path_length(graphs): - cugraph_G, nx_G, cupy_df = graphs - - path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) - assert path_1_to_1_length == 0.0 - assert path_1_to_1_length == nx.shortest_path_length( - nx_G, "1", target="1", weight="weight" - ) - assert path_1_to_1_length == cugraph.shortest_path_length(nx_G, "1", "1") - assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) - - path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) - assert path_1_to_5_length == 2.0 - assert path_1_to_5_length == nx.shortest_path_length( - nx_G, "1", target="5", weight="weight" - ) - assert path_1_to_5_length == cugraph.shortest_path_length(nx_G, "1", "5") - assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) - - path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) - assert path_1_to_3_length == 2.0 - assert path_1_to_3_length == nx.shortest_path_length( - nx_G, "1", target="3", weight="weight" - ) - assert path_1_to_3_length == cugraph.shortest_path_length(nx_G, "1", "3") - assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) - - path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) - assert path_1_to_6_length == 2.0 - assert path_1_to_6_length == nx.shortest_path_length( - nx_G, "1", target="6", weight="weight" - ) - assert path_1_to_6_length == cugraph.shortest_path_length(nx_G, "1", "6") - assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_invalid_source(graphs): - cugraph_G, nx_G, cupy_df = graphs - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cugraph_G, -1, 1) - - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "-1", "1") - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cupy_df, -1, 1) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_invalid_target(graphs): - cugraph_G, nx_G, cupy_df = graphs - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cugraph_G, 1, 10) - - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "1", "10") - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cupy_df, 1, 10) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [CONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_invalid_vertexes(graphs): - cugraph_G, nx_G, cupy_df = graphs - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cugraph_G, 0, 42) - - with pytest.raises(ValueError): - cugraph.shortest_path_length(nx_G, "0", "42") - - with pytest.raises(ValueError): - cugraph.shortest_path_length(cupy_df, 0, 42) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_no_path(graphs): - cugraph_G, nx_G, cupy_df = graphs - - # FIXME: In case there is no path between two vertices, the - # result can be either the max of float32 or float64 - max_float_32 = (2 - math.pow(2, -23)) * math.pow(2, 127) - - path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) - assert path_1_to_8 == sys.float_info.max - assert cugraph.shortest_path_length(nx_G, "1", "8") in [max_float_32, path_1_to_8] - assert path_1_to_8 == cugraph.shortest_path_length(cupy_df, 1, 8) - - -@pytest.mark.sg -@pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_no_target(graphs): - cugraph_G, nx_G, cupy_df = graphs - - cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - nx_path_1_to_all = nx.shortest_path_length(nx_G, source="1", weight="weight") - nx_gpu_path_1_to_all = cugraph.shortest_path_length(nx_G, "1") - cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) - - # Cast networkx graph on cugraph vertex column type from str to int. - # SSSP preserves vertex type, convert for comparison - nx_gpu_path_1_to_all["vertex"] = nx_gpu_path_1_to_all["vertex"].astype("int32") - - assert cugraph_path_1_to_all == nx_gpu_path_1_to_all - assert cugraph_path_1_to_all == cupy_path_1_to_all - - # results for vertex 8 and 9 are not returned - assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 - - for index in range(cugraph_path_1_to_all.shape[0]): - - vertex = str(cugraph_path_1_to_all["vertex"][index].item()) - distance = cugraph_path_1_to_all["distance"][index].item() - - # verify cugraph against networkx - if vertex in {"8", "9"}: - # Networkx does not return distances for these vertexes. - assert distance == sys.float_info.max - else: - assert distance == nx_path_1_to_all[vertex] diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp_old.py b/python/cugraph/cugraph/tests/traversal/test_sssp_old.py deleted file mode 100644 index 72db4999813..00000000000 --- a/python/cugraph/cugraph/tests/traversal/test_sssp_old.py +++ /dev/null @@ -1,520 +0,0 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. -# 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 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import gc - -import numpy as np -import pytest -import pandas as pd -import cupy as cp -import cupyx -from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix -from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix -from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix -from scipy.sparse import coo_matrix as sp_coo_matrix -from scipy.sparse import csr_matrix as sp_csr_matrix -from scipy.sparse import csc_matrix as sp_csc_matrix -import cudf -from pylibcugraph.testing.utils import gen_fixture_params_product -from cugraph.experimental.datasets import DATASETS_UNDIRECTED - -import cugraph -from cugraph.testing import utils, ResultSet -from cugraph.experimental import datasets - - -# Map of cuGraph input types to the expected output type for cuGraph -# connected_components calls. -cuGraph_input_output_map = { - cugraph.Graph: cudf.DataFrame, - cp_coo_matrix: tuple, - cp_csr_matrix: tuple, - cp_csc_matrix: tuple, - sp_coo_matrix: tuple, - sp_csr_matrix: tuple, - sp_csc_matrix: tuple, -} -cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] - -sssp_results = ResultSet(local_result_file="sssp_results.pkl") - - -# ============================================================================= -# Pytest Setup / Teardown - called for each test function -# ============================================================================= -def setup_function(): - gc.collect() - - -# ============================================================================= -# Helper functions -# ============================================================================= -def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=True): - """ - Call cugraph.sssp on input_G_or_matrix, then convert the result to a - standard format (dictionary of vertex IDs to (distance, predecessor) - tuples) for easy checking in the test code. - """ - result = gpu_benchmark_callable(cugraph.sssp, input_G_or_matrix, source) - - input_type = type(input_G_or_matrix) - expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] - assert type(result) is expected_return_type - - # Convert cudf and pandas: DF of 3 columns: (vertex, distance, predecessor) - if expected_return_type in [cudf.DataFrame, pd.DataFrame]: - if expected_return_type is pd.DataFrame: - result = cudf.from_pandas(result) - - if np.issubdtype(result["distance"].dtype, np.integer): - max_val = np.iinfo(result["distance"].dtype).max - else: - max_val = np.finfo(result["distance"].dtype).max - verts = result["vertex"].to_numpy() - dists = result["distance"].to_numpy() - preds = result["predecessor"].to_numpy() - - # A CuPy/SciPy input means the return value will be a 2-tuple of: - # distance: cupy.ndarray - # ndarray of shortest distances between source and vertex. - # predecessor: cupy.ndarray - # ndarray of predecessors of a vertex on the path from source, which - # can be used to reconstruct the shortest paths. - elif expected_return_type is tuple: - if input_type in cupy_types: - assert type(result[0]) is cp.ndarray - assert type(result[1]) is cp.ndarray - else: - assert type(result[0]) is np.ndarray - assert type(result[1]) is np.ndarray - - if np.issubdtype(result[0].dtype, np.integer): - max_val = np.iinfo(result[0].dtype).max - else: - max_val = np.finfo(result[0].dtype).max - - # Get unique verts from input since they are not incuded in output - if type(input_G_or_matrix) in [ - cp_csr_matrix, - cp_csc_matrix, - sp_csr_matrix, - sp_csc_matrix, - ]: - coo = input_G_or_matrix.tocoo(copy=False) - else: - coo = input_G_or_matrix - verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) - dists = [n.item() for n in result[0]] - preds = [n.item() for n in result[1]] - assert len(verts) == len(dists) == len(preds) - - else: - raise RuntimeError(f"unsupported return type: {expected_return_type}") - - result_dict = dict(zip(verts, zip(dists, preds))) - return result_dict, max_val - - -def networkx_call(graph_file, source, edgevals=True): - dataset_path = graph_file.get_path() - dataset_name = graph_file.metadata["name"] - - if edgevals is False: - # FIXME: no test coverage if edgevals is False, this assertion is never reached - assert False - nx_paths = sssp_results.results["{},{},ssspl".format(dataset_name, source)] - else: - # FIXME: The nx call below doesn't return accurate results as it seems to - # not support 'weights'. It matches cuGraph result only if the weight column - # is 1s. - nx_paths = sssp_results.results["{},{},ssdpl".format(dataset_name, source)] - - G = graph_file.get_graph( - create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals - ) - - return (G, dataset_path, graph_file, source, nx_paths) - - -# ============================================================================= -# Pytest fixtures -# ============================================================================= - -# Call gen_fixture_params_product() to calculate the cartesian product of -# multiple lists of params. This is required since parameterized fixtures do -# not do this automatically (unlike multiply-parameterized tests). The 2nd -# item in the tuple is a label for the param value used when displaying the -# full test name. -# FIXME: tests with datasets like 'netscience' which has a weight column different -# than than 1's fail because it looks like netwokX doesn't consider weights during -# the computation. -DATASETS = [pytest.param(d) for d in datasets.DATASETS_SMALL] -SOURCES = [pytest.param(1)] -fixture_params = gen_fixture_params_product((DATASETS, "ds"), (SOURCES, "src")) -fixture_params_single_dataset = gen_fixture_params_product( - ([DATASETS[0]], "ds"), (SOURCES, "src") -) - - -# These fixtures will call networkx BFS algos and save the result. The networkx -# call is only made only once per input param combination. -@pytest.fixture(scope="module", params=fixture_params) -def dataset_source_nxresults(request): - # request.param is a tuple of params from fixture_params. When expanded - # with *, will be passed to networkx_call() as args (graph_file, source) - return networkx_call(*(request.param)) - - -@pytest.fixture(scope="module", params=fixture_params_single_dataset) -def single_dataset_source_nxresults(request): - return networkx_call(*(request.param)) - - -@pytest.fixture(scope="module", params=fixture_params) -def dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), edgevals=True) - - -@pytest.fixture(scope="module", params=fixture_params_single_dataset) -def single_dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), edgevals=True) - - -# ============================================================================= -# Tests -# ============================================================================= -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): - # Extract the params generated from the fixture - (G, dataset_path, _, source, nx_paths) = dataset_source_nxresults - - if not isinstance(cugraph_input_type, cugraph.Graph): - input_G_or_matrix = utils.create_obj_from_csv( - dataset_path, cugraph_input_type, edgevals=True - ) - else: - input_G_or_matrix = G - - cu_paths, max_val = cugraph_call(gpubenchmark, input_G_or_matrix, source) - - # Calculating mismatch - err = 0 - for vid in cu_paths: - # Validate vertices that are reachable - # NOTE : If distance type is float64 then cu_paths[vid][0] - # should be compared against np.finfo(np.float64).max) - if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: - err = err + 1 - # check pred dist + 1 = current dist (since unweighted) - pred = cu_paths[vid][1] - if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: - err = err + 1 - else: - if vid in nx_paths.keys(): - err = err + 1 - - assert err == 0 - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_input_type): - (G, _, _, source, _) = dataset_source_nxresults - el = G.view_edge_list() - - newval = max(el.src.max(), el.dst.max()) + 1 - source = newval - - with pytest.raises(ValueError): - cugraph_call(gpubenchmark, G, source) - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) -def test_sssp_nonnative_inputs_matrix( - gpubenchmark, single_dataset_source_nxresults, cugraph_input_type -): - test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", ["nx.Graph", "nx.DiGraph"]) -def test_sssp_nonnative_inputs_nx( - gpubenchmark, single_dataset_source_nxresults, cugraph_input_type -): - (_, _, _, source, nx_paths) = single_dataset_source_nxresults - result = sssp_results.results[ - "nonnative_input,{},{}".format(cugraph_input_type, source) - ] - # ^^ should be a pd dataframe - result = cudf.from_pandas(result) - if np.issubdtype(result["distance"].dtype, np.integer): - max_val = np.iinfo(result["distance"].dtype).max - else: - max_val = np.finfo(result["distance"].dtype).max - verts = result["vertex"].to_numpy() - dists = result["distance"].to_numpy() - preds = result["predecessor"].to_numpy() - cu_paths = dict(zip(verts, zip(dists, preds))) - - # Calculating mismatch - err = 0 - for vid in cu_paths: - # Validate vertices that are reachable - # NOTE : If distance type is float64 then cu_paths[vid][0] - # should be compared against np.finfo(np.float64).max) - if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: - err = err + 1 - # check pred dist + 1 = current dist (since unweighted) - pred = cu_paths[vid][1] - if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: - err = err + 1 - else: - if vid in nx_paths.keys(): - err = err + 1 - - assert err == 0 - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp_edgevals( - gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type -): - # Extract the params generated from the fixture - (G, _, dataset, source, nx_paths) = dataset_source_nxresults_weighted - input_G_or_matrix = G - - cu_paths, max_val = cugraph_call( - gpubenchmark, input_G_or_matrix, source, edgevals=True - ) - - # Calculating mismatch - err = 0 - for vid in cu_paths: - # Validate vertices that are reachable - # NOTE : If distance type is float64 then cu_paths[vid][0] - # should be compared against np.finfo(np.float64).max) - distances = cugraph.sssp(G, source=vid) - if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: - err = err + 1 - # check pred dist + edge_weight = current dist - if vid != source: - pred = cu_paths[vid][1] - if G.has_edge(pred, vid): - edge_weight = distances[distances["vertex"] == pred].iloc[0, 0] - if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: - err = err + 1 - else: - if vid in nx_paths.keys(): - err = err + 1 - assert err == 0 - - -@pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_sssp_edgevals_nonnative_inputs( - gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type -): - test_sssp_edgevals( - gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type - ) - - -@pytest.mark.sg -@pytest.mark.parametrize("graph_file", DATASETS) -@pytest.mark.parametrize("source", SOURCES) -def test_sssp_data_type_conversion(graph_file, source): - dataset_path = graph_file.get_path() - dataset_name = graph_file.metadata["name"] - cu_M = utils.read_csv_file(dataset_path) - - # cugraph call with int32 weights - cu_M["2"] = cu_M["2"].astype(np.int32) - G = cugraph.Graph(directed=True) - G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") - # assert cugraph weights is int32 - assert G.edgelist.edgelist_df["weights"].dtype == np.int32 - df = cugraph.sssp(G, source) - max_val = np.finfo(df["distance"].dtype).max - verts_np = df["vertex"].to_numpy() - dist_np = df["distance"].to_numpy() - pred_np = df["predecessor"].to_numpy() - cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - nx_paths = sssp_results.results[ - "nx_paths,data_type_conversion,{}".format(dataset_name) - ] - - # Calculating mismatch - err = 0 - for vid in cu_paths: - # Validate vertices that are reachable - # NOTE : If distance type is float64 then cu_paths[vid][0] - # should be compared against np.finfo(np.float64).max) - distances = cugraph.sssp(G, source=vid) - if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: - err = err + 1 - # check pred dist + edge_weight = current dist - if vid != source: - pred = cu_paths[vid][1] - if G.has_edge(pred, vid): - edge_weight = distances[distances["vertex"] == pred].iloc[0, 0] - if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: - err = err + 1 - else: - if vid in nx_paths.keys(): - err = err + 1 - - assert err == 0 - - -@pytest.mark.sg -def test_sssp_networkx_edge_attr(): - df = sssp_results.results["network_edge_attr"] - df = cudf.DataFrame(df) - df = df.set_index("vertex") - assert df.loc[0, "distance"] == 0 - assert df.loc[1, "distance"] == 10 - assert df.loc[2, "distance"] == 30 - - -@pytest.mark.sg -def test_scipy_api_compat(): - graph_file = datasets.DATASETS[0] - dataset_path = graph_file.get_path() - input_cugraph_graph = graph_file.get_graph() - input_coo_matrix = utils.create_obj_from_csv( - dataset_path, cp_coo_matrix, edgevals=True - ) - - # Ensure scipy-only options are rejected for cugraph inputs - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, directed=False) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, unweighted=False) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, overwrite=False) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, return_predecessors=False) - - # Ensure cugraph-compatible options work as expected - # cannot set both source and indices, but must set one - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, indices=0) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph) - with pytest.raises(ValueError): - cugraph.shortest_path(input_cugraph_graph, source=0, method="BF") - cugraph.shortest_path(input_cugraph_graph, indices=0) - with pytest.raises(ValueError): - cugraph.shortest_path(input_cugraph_graph, indices=[0, 1, 2]) - cugraph.shortest_path(input_cugraph_graph, source=0, method="auto") - - # Ensure SciPy options for matrix inputs work as expected - # cannot set both source and indices, but must set one - with pytest.raises(TypeError): - cugraph.shortest_path(input_coo_matrix, source=0, indices=0) - with pytest.raises(TypeError): - cugraph.shortest_path(input_coo_matrix) - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, method="BF") - cugraph.shortest_path(input_coo_matrix, source=0, method="auto") - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, directed=3) - cugraph.shortest_path(input_coo_matrix, source=0, directed=True) - cugraph.shortest_path(input_coo_matrix, source=0, directed=False) - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, return_predecessors=3) - (distances, preds) = cugraph.shortest_path( - input_coo_matrix, source=0, return_predecessors=True - ) - distances = cugraph.shortest_path( - input_coo_matrix, source=0, return_predecessors=False - ) - assert type(distances) != tuple - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, unweighted=False) - cugraph.shortest_path(input_coo_matrix, source=0, unweighted=True) - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, overwrite=True) - cugraph.shortest_path(input_coo_matrix, source=0, overwrite=False) - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, indices=[0, 1, 2]) - cugraph.shortest_path(input_coo_matrix, indices=0) - - -@pytest.mark.sg -@pytest.mark.parametrize("graph_file", DATASETS_UNDIRECTED) -def test_sssp_csr_graph(graph_file): - df = graph_file.get_edgelist() - - M = cupyx.scipy.sparse.coo_matrix( - (df["wgt"].to_cupy(), (df["src"].to_cupy(), df["dst"].to_cupy())) - ) - M = M.tocsr() - - offsets = cudf.Series(M.indptr) - indices = cudf.Series(M.indices) - weights = cudf.Series(M.data) - G_csr = cugraph.Graph() - G_coo = graph_file.get_graph() - - source = G_coo.select_random_vertices(num_vertices=1)[0] - - print("source = ", source) - - G_csr.from_cudf_adjlist(offsets, indices, weights) - - result_csr = cugraph.sssp(G_csr, source) - result_coo = cugraph.sssp(G_coo, source) - - result_csr = result_csr.sort_values("vertex").reset_index(drop=True) - result_sssp = ( - result_coo.sort_values("vertex") - .reset_index(drop=True) - .rename(columns={"distance": "distance_coo", "predecessor": "predecessor_coo"}) - ) - result_sssp["distance_csr"] = result_csr["distance"] - result_sssp["predecessor_csr"] = result_csr["predecessor"] - - distance_diffs = result_sssp.query("distance_csr != distance_coo") - predecessor_diffs = result_sssp.query("predecessor_csr != predecessor_coo") - - assert len(distance_diffs) == 0 - assert len(predecessor_diffs) == 0 - - -@pytest.mark.sg -def test_sssp_unweighted_graph(): - karate = DATASETS_UNDIRECTED[0] - G = karate.get_graph(ignore_weights=True) - - error_msg = ( - "'SSSP' requires the input graph to be weighted." - "'BFS' should be used instead of 'SSSP' for unweighted graphs." - ) - - with pytest.raises(RuntimeError, match=error_msg): - cugraph.sssp(G, 1) diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py b/python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py deleted file mode 100644 index 1c99123f866..00000000000 --- a/python/cugraph/cugraph/tests/traversal/test_sssp_withnx.py +++ /dev/null @@ -1,519 +0,0 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. -# 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 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import gc -import time - -import numpy as np -import pytest -import pandas as pd -import cupy as cp -import cupyx -from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix -from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix -from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix -from scipy.sparse import coo_matrix as sp_coo_matrix -from scipy.sparse import csr_matrix as sp_csr_matrix -from scipy.sparse import csc_matrix as sp_csc_matrix -import cudf -from pylibcugraph.testing.utils import gen_fixture_params_product -from cugraph.experimental.datasets import DATASETS_UNDIRECTED - -import cugraph -from cugraph.testing import utils -from cugraph.experimental import datasets - - -# Temporarily suppress warnings till networkX fixes deprecation warnings -# (Using or importing the ABCs from 'collections' instead of from -# 'collections.abc' is deprecated, and in 3.8 it will stop working) for -# python 3.7. Also, this import networkx needs to be relocated in the -# third-party group once this gets fixed. -import warnings - -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - import networkx as nx - -print("Networkx version : {} ".format(nx.__version__)) - - -# Map of cuGraph input types to the expected output type for cuGraph -# connected_components calls. -cuGraph_input_output_map = { - cugraph.Graph: cudf.DataFrame, - nx.Graph: pd.DataFrame, - nx.DiGraph: pd.DataFrame, - cp_coo_matrix: tuple, - cp_csr_matrix: tuple, - cp_csc_matrix: tuple, - sp_coo_matrix: tuple, - sp_csr_matrix: tuple, - sp_csc_matrix: tuple, -} -cupy_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] - - -# ============================================================================= -# Pytest Setup / Teardown - called for each test function -# ============================================================================= -def setup_function(): - gc.collect() - - -# ============================================================================= -# Helper functions -# ============================================================================= -def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=True): - """ - Call cugraph.sssp on input_G_or_matrix, then convert the result to a - standard format (dictionary of vertex IDs to (distance, predecessor) - tuples) for easy checking in the test code. - """ - result = gpu_benchmark_callable(cugraph.sssp, input_G_or_matrix, source) - - input_type = type(input_G_or_matrix) - expected_return_type = cuGraph_input_output_map[type(input_G_or_matrix)] - assert type(result) is expected_return_type - - # Convert cudf and pandas: DF of 3 columns: (vertex, distance, predecessor) - if expected_return_type in [cudf.DataFrame, pd.DataFrame]: - if expected_return_type is pd.DataFrame: - result = cudf.from_pandas(result) - - if np.issubdtype(result["distance"].dtype, np.integer): - max_val = np.iinfo(result["distance"].dtype).max - else: - max_val = np.finfo(result["distance"].dtype).max - verts = result["vertex"].to_numpy() - dists = result["distance"].to_numpy() - preds = result["predecessor"].to_numpy() - - # A CuPy/SciPy input means the return value will be a 2-tuple of: - # distance: cupy.ndarray - # ndarray of shortest distances between source and vertex. - # predecessor: cupy.ndarray - # ndarray of predecessors of a vertex on the path from source, which - # can be used to reconstruct the shortest paths. - elif expected_return_type is tuple: - if input_type in cupy_types: - assert type(result[0]) is cp.ndarray - assert type(result[1]) is cp.ndarray - else: - assert type(result[0]) is np.ndarray - assert type(result[1]) is np.ndarray - - if np.issubdtype(result[0].dtype, np.integer): - max_val = np.iinfo(result[0].dtype).max - else: - max_val = np.finfo(result[0].dtype).max - - # Get unique verts from input since they are not incuded in output - if type(input_G_or_matrix) in [ - cp_csr_matrix, - cp_csc_matrix, - sp_csr_matrix, - sp_csc_matrix, - ]: - coo = input_G_or_matrix.tocoo(copy=False) - else: - coo = input_G_or_matrix - verts = sorted(set([n.item() for n in coo.col] + [n.item() for n in coo.row])) - dists = [n.item() for n in result[0]] - preds = [n.item() for n in result[1]] - assert len(verts) == len(dists) == len(preds) - - else: - raise RuntimeError(f"unsupported return type: {expected_return_type}") - - result_dict = dict(zip(verts, zip(dists, preds))) - return result_dict, max_val - - -def networkx_call(graph_file, source, edgevals=True): - dataset_path = graph_file.get_path() - M = utils.read_csv_for_nx(dataset_path, read_weights_in_sp=True) - # Directed NetworkX graph - edge_attr = "weight" if edgevals else None - - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr=edge_attr, - create_using=nx.DiGraph(), - ) - print("NX Solving... ") - t1 = time.time() - - if edgevals is False: - nx_paths = nx.single_source_shortest_path_length(Gnx, source) - else: - # FIXME: The nx call below doesn't return accurate results as it seems to - # not support 'weights'. It matches cuGraph result only if the weight column - # is 1s. - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) - - G = graph_file.get_graph( - create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals - ) - - t2 = time.time() - t1 - print("NX Time : " + str(t2)) - - return (G, dataset_path, source, nx_paths, Gnx) - - -# ============================================================================= -# Pytest fixtures -# ============================================================================= - -# Call gen_fixture_params_product() to caluculate the cartesian product of -# multiple lists of params. This is required since parameterized fixtures do -# not do this automatically (unlike multiply-parameterized tests). The 2nd -# item in the tuple is a label for the param value used when displaying the -# full test name. -# FIXME: tests with datasets like 'netscience' which has a weight column different -# than than 1's fail because it looks like netwokX doesn't consider weights during -# the computation. -DATASETS = [pytest.param(d) for d in datasets.DATASETS_SMALL] -SOURCES = [pytest.param(1)] -fixture_params = gen_fixture_params_product((DATASETS, "ds"), (SOURCES, "src")) -fixture_params_single_dataset = gen_fixture_params_product( - ([DATASETS[0]], "ds"), (SOURCES, "src") -) - - -# These fixtures will call networkx BFS algos and save the result. The networkx -# call is only made only once per input param combination. -@pytest.fixture(scope="module", params=fixture_params) -def dataset_source_nxresults(request): - # request.param is a tuple of params from fixture_params. When expanded - # with *, will be passed to networkx_call() as args (graph_file, source) - return networkx_call(*(request.param)) - - -@pytest.fixture(scope="module", params=fixture_params_single_dataset) -def single_dataset_source_nxresults(request): - return networkx_call(*(request.param)) - - -@pytest.fixture(scope="module", params=fixture_params) -def dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), edgevals=True) - - -@pytest.fixture(scope="module", params=fixture_params_single_dataset) -def single_dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), edgevals=True) - - -# ============================================================================= -# Tests -# ============================================================================= -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): - # Extract the params generated from the fixture - (G, dataset_path, source, nx_paths, Gnx) = dataset_source_nxresults - - if not isinstance(cugraph_input_type, cugraph.Graph): - input_G_or_matrix = utils.create_obj_from_csv( - dataset_path, cugraph_input_type, edgevals=True - ) - else: - input_G_or_matrix = G - - cu_paths, max_val = cugraph_call(gpubenchmark, input_G_or_matrix, source) - - # Calculating mismatch - err = 0 - for vid in cu_paths: - # Validate vertices that are reachable - # NOTE : If distance type is float64 then cu_paths[vid][0] - # should be compared against np.finfo(np.float64).max) - if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: - err = err + 1 - # check pred dist + 1 = current dist (since unweighted) - pred = cu_paths[vid][1] - if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: - err = err + 1 - else: - if vid in nx_paths.keys(): - err = err + 1 - - assert err == 0 - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_input_type): - (G, _, source, nx_paths, Gnx) = dataset_source_nxresults - el = G.view_edge_list() - - newval = max(el.src.max(), el.dst.max()) + 1 - source = newval - - with pytest.raises(ValueError): - cugraph_call(gpubenchmark, G, source) - - -@pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_sssp_nonnative_inputs( - gpubenchmark, single_dataset_source_nxresults, cugraph_input_type -): - test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) - - -@pytest.mark.sg -@pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp_edgevals( - gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type -): - # Extract the params generated from the fixture - (G, _, source, nx_paths, Gnx) = dataset_source_nxresults_weighted - input_G_or_matrix = G - - cu_paths, max_val = cugraph_call( - gpubenchmark, input_G_or_matrix, source, edgevals=True - ) - - # Calculating mismatch - err = 0 - for vid in cu_paths: - # Validate vertices that are reachable - # NOTE : If distance type is float64 then cu_paths[vid][0] - # should be compared against np.finfo(np.float64).max) - if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: - err = err + 1 - # check pred dist + edge_weight = current dist - if vid != source: - pred = cu_paths[vid][1] - edge_weight = Gnx[pred][vid]["weight"] - if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: - err = err + 1 - else: - if vid in nx_paths.keys(): - err = err + 1 - - assert err == 0 - - -@pytest.mark.sg -@pytest.mark.parametrize( - "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES -) -def test_sssp_edgevals_nonnative_inputs( - gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type -): - test_sssp_edgevals( - gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type - ) - - -@pytest.mark.sg -@pytest.mark.parametrize("graph_file", DATASETS) -@pytest.mark.parametrize("source", SOURCES) -def test_sssp_data_type_conversion(graph_file, source): - dataset_path = graph_file.get_path() - M = utils.read_csv_for_nx(dataset_path) - cu_M = utils.read_csv_file(dataset_path) - - # cugraph call with int32 weights - cu_M["2"] = cu_M["2"].astype(np.int32) - G = cugraph.Graph(directed=True) - G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") - # assert cugraph weights is int32 - assert G.edgelist.edgelist_df["weights"].dtype == np.int32 - df = cugraph.sssp(G, source) - max_val = np.finfo(df["distance"].dtype).max - verts_np = df["vertex"].to_numpy() - dist_np = df["distance"].to_numpy() - pred_np = df["predecessor"].to_numpy() - cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - - # networkx call with int32 weights - M["weight"] = M["weight"].astype(np.int32) - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr="weight", - create_using=nx.DiGraph(), - ) - # assert nx weights is int - assert type(list(Gnx.edges(data=True))[0][2]["weight"]) is int - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) - - # Calculating mismatch - err = 0 - for vid in cu_paths: - # Validate vertices that are reachable - # NOTE : If distance type is float64 then cu_paths[vid][0] - # should be compared against np.finfo(np.float64).max) - if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: - err = err + 1 - # check pred dist + edge_weight = current dist - if vid != source: - pred = cu_paths[vid][1] - edge_weight = Gnx[pred][vid]["weight"] - if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: - err = err + 1 - else: - if vid in nx_paths.keys(): - err = err + 1 - - assert err == 0 - - -@pytest.mark.sg -def test_sssp_networkx_edge_attr(): - G = nx.Graph() - G.add_edge(0, 1, other=10) - G.add_edge(1, 2, other=20) - df = cugraph.sssp(G, 0, edge_attr="other") - df = df.set_index("vertex") - assert df.loc[0, "distance"] == 0 - assert df.loc[1, "distance"] == 10 - assert df.loc[2, "distance"] == 30 - - -@pytest.mark.sg -def test_scipy_api_compat(): - graph_file = datasets.DATASETS[0] - dataset_path = graph_file.get_path() - input_cugraph_graph = graph_file.get_graph() - input_coo_matrix = utils.create_obj_from_csv( - dataset_path, cp_coo_matrix, edgevals=True - ) - - # Ensure scipy-only options are rejected for cugraph inputs - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, directed=False) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, unweighted=False) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, overwrite=False) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, return_predecessors=False) - - # Ensure cugraph-compatible options work as expected - # cannot set both source and indices, but must set one - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph, source=0, indices=0) - with pytest.raises(TypeError): - cugraph.shortest_path(input_cugraph_graph) - with pytest.raises(ValueError): - cugraph.shortest_path(input_cugraph_graph, source=0, method="BF") - cugraph.shortest_path(input_cugraph_graph, indices=0) - with pytest.raises(ValueError): - cugraph.shortest_path(input_cugraph_graph, indices=[0, 1, 2]) - cugraph.shortest_path(input_cugraph_graph, source=0, method="auto") - - # Ensure SciPy options for matrix inputs work as expected - # cannot set both source and indices, but must set one - with pytest.raises(TypeError): - cugraph.shortest_path(input_coo_matrix, source=0, indices=0) - with pytest.raises(TypeError): - cugraph.shortest_path(input_coo_matrix) - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, method="BF") - cugraph.shortest_path(input_coo_matrix, source=0, method="auto") - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, directed=3) - cugraph.shortest_path(input_coo_matrix, source=0, directed=True) - cugraph.shortest_path(input_coo_matrix, source=0, directed=False) - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, return_predecessors=3) - (distances, preds) = cugraph.shortest_path( - input_coo_matrix, source=0, return_predecessors=True - ) - distances = cugraph.shortest_path( - input_coo_matrix, source=0, return_predecessors=False - ) - assert type(distances) != tuple - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, unweighted=False) - cugraph.shortest_path(input_coo_matrix, source=0, unweighted=True) - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, source=0, overwrite=True) - cugraph.shortest_path(input_coo_matrix, source=0, overwrite=False) - - with pytest.raises(ValueError): - cugraph.shortest_path(input_coo_matrix, indices=[0, 1, 2]) - cugraph.shortest_path(input_coo_matrix, indices=0) - - -@pytest.mark.sg -@pytest.mark.parametrize("graph_file", DATASETS_UNDIRECTED) -def test_sssp_csr_graph(graph_file): - df = graph_file.get_edgelist() - - M = cupyx.scipy.sparse.coo_matrix( - (df["wgt"].to_cupy(), (df["src"].to_cupy(), df["dst"].to_cupy())) - ) - M = M.tocsr() - - offsets = cudf.Series(M.indptr) - indices = cudf.Series(M.indices) - weights = cudf.Series(M.data) - G_csr = cugraph.Graph() - G_coo = graph_file.get_graph() - - source = G_coo.select_random_vertices(num_vertices=1)[0] - - print("source = ", source) - - G_csr.from_cudf_adjlist(offsets, indices, weights) - - result_csr = cugraph.sssp(G_csr, source) - result_coo = cugraph.sssp(G_coo, source) - - result_csr = result_csr.sort_values("vertex").reset_index(drop=True) - result_sssp = ( - result_coo.sort_values("vertex") - .reset_index(drop=True) - .rename(columns={"distance": "distance_coo", "predecessor": "predecessor_coo"}) - ) - result_sssp["distance_csr"] = result_csr["distance"] - result_sssp["predecessor_csr"] = result_csr["predecessor"] - - distance_diffs = result_sssp.query("distance_csr != distance_coo") - predecessor_diffs = result_sssp.query("predecessor_csr != predecessor_coo") - - assert len(distance_diffs) == 0 - assert len(predecessor_diffs) == 0 - - -@pytest.mark.sg -def test_sssp_unweighted_graph(): - karate = DATASETS_UNDIRECTED[0] - G = karate.get_graph(ignore_weights=True) - - error_msg = ( - "'SSSP' requires the input graph to be weighted." - "'BFS' should be used instead of 'SSSP' for unweighted graphs." - ) - - with pytest.raises(RuntimeError, match=error_msg): - cugraph.sssp(G, 1) From 5b921b041f31b141dbbda9349367085fa8c59368 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Tue, 25 Jul 2023 22:39:40 +0000 Subject: [PATCH 07/20] Added results files for CI, can remove easily as needed --- .../results/traversal-1014939923221900.csv | 3 + .../results/traversal-10209535434255476.csv | 3 + .../results/traversal-10237264400944458.csv | 35 ++++++ .../results/traversal-11196971449711926.csv | 35 ++++++ .../results/traversal-1198291124021810.csv | 35 ++++++ .../results/traversal-12211229035620551.csv | 35 ++++++ .../results/traversal-13794012085099560.csv | 63 +++++++++++ .../results/traversal-16852839384883684.csv | 3 + .../results/traversal-17637631058920707.csv | 106 ++++++++++++++++++ .../results/traversal-17701312393774934.csv | 35 ++++++ .../results/traversal-18005711098893413.csv | 35 ++++++ .../results/traversal-20257532223395364.csv | 35 ++++++ .../results/traversal-20996818816802203.csv | 63 +++++++++++ .../results/traversal-21489979096431321.csv | 63 +++++++++++ .../results/traversal-22026915197979443.csv | 35 ++++++ .../results/traversal-22884663737948621.csv | 3 + .../results/traversal-23382061985704026.csv | 35 ++++++ .../results/traversal-23806279448496695.csv | 35 ++++++ .../results/traversal-24542947045216202.csv | 35 ++++++ .../results/traversal-24559072556563332.csv | 60 ++++++++++ .../results/traversal-24566330077712845.csv | 5 + .../results/traversal-24760070215193007.csv | 35 ++++++ .../results/traversal-25432193970951106.csv | 63 +++++++++++ .../results/traversal-25977799875707499.csv | 3 + .../results/traversal-26769783379741560.csv | 35 ++++++ .../results/traversal-2684007979152506.csv | 6 + .../results/traversal-29053032045714712.csv | 3 + .../results/traversal-30452085807441890.csv | 5 + .../results/traversal-30541863852431260.csv | 106 ++++++++++++++++++ .../results/traversal-33225028299752134.csv | 3 + .../results/traversal-34595993037949685.csv | 6 + .../results/traversal-35853313043454625.csv | 35 ++++++ .../results/traversal-35983514138250487.csv | 63 +++++++++++ .../results/traversal-457988537373597.csv | 3 + .../results/traversal-5509948256545934.csv | 63 +++++++++++ .../results/traversal-6028686672229212.csv | 8 ++ .../results/traversal-6076307202060871.csv | 35 ++++++ .../results/traversal-6102329022496213.csv | 60 ++++++++++ .../results/traversal-7136448615947447.csv | 8 ++ .../results/traversal-7700395001688692.csv | 35 ++++++ .../results/traversal-7863939874314132.csv | 8 ++ .../results/traversal-8862356193854587.csv | 35 ++++++ .../results/traversal-9148021614037858.csv | 35 ++++++ .../results/traversal-9867286825871764.csv | 4 + .../testing/results/traversal_mappings.csv | 45 ++++++++ python/cugraph/cugraph/testing/resultset.py | 28 +++-- 46 files changed, 1480 insertions(+), 7 deletions(-) create mode 100644 python/cugraph/cugraph/testing/results/traversal-1014939923221900.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-10209535434255476.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-10237264400944458.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-11196971449711926.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-1198291124021810.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-12211229035620551.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-13794012085099560.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-16852839384883684.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-17637631058920707.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-17701312393774934.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-18005711098893413.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-20257532223395364.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-20996818816802203.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-21489979096431321.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-22026915197979443.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-22884663737948621.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-23382061985704026.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-23806279448496695.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-24542947045216202.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-24559072556563332.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-24566330077712845.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-24760070215193007.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-25432193970951106.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-25977799875707499.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-26769783379741560.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-2684007979152506.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-29053032045714712.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-30452085807441890.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-30541863852431260.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-33225028299752134.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-34595993037949685.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-35853313043454625.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-35983514138250487.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-457988537373597.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-5509948256545934.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-6028686672229212.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-6076307202060871.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-6102329022496213.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-7136448615947447.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-7700395001688692.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-7863939874314132.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-8862356193854587.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-9148021614037858.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal-9867286825871764.csv create mode 100644 python/cugraph/cugraph/testing/results/traversal_mappings.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-1014939923221900.csv b/python/cugraph/cugraph/testing/results/traversal-1014939923221900.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-1014939923221900.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-10209535434255476.csv b/python/cugraph/cugraph/testing/results/traversal-10209535434255476.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-10209535434255476.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-10237264400944458.csv b/python/cugraph/cugraph/testing/results/traversal-10237264400944458.csv new file mode 100644 index 00000000000..5b2270cb9ed --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-10237264400944458.csv @@ -0,0 +1,35 @@ +distance,vertex,predecessor +2.0,33,13 +1.0,0,1 +2.0,32,2 +1.0,2,1 +0.0,1,-1 +1.0,3,1 +2.0,31,0 +2.0,8,0 +1.0,13,1 +3.0,23,33 +2.0,5,0 +2.0,6,0 +1.0,7,1 +2.0,27,2 +3.0,29,33 +1.0,30,1 +2.0,4,0 +2.0,10,0 +1.0,19,1 +3.0,24,31 +3.0,25,31 +2.0,28,2 +2.0,9,2 +2.0,12,0 +3.0,14,33 +3.0,15,33 +3.0,16,5 +1.0,17,1 +3.0,18,33 +3.0,20,33 +1.0,21,1 +3.0,22,33 +3.0,26,33 +2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-11196971449711926.csv b/python/cugraph/cugraph/testing/results/traversal-11196971449711926.csv new file mode 100644 index 00000000000..dda4c0b31ba --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-11196971449711926.csv @@ -0,0 +1,35 @@ +vertex,distance +1,0 +0,1 +2,1 +3,1 +7,1 +13,1 +17,1 +19,1 +21,1 +30,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +31,2 +9,2 +27,2 +28,2 +32,2 +33,2 +16,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-1198291124021810.csv b/python/cugraph/cugraph/testing/results/traversal-1198291124021810.csv new file mode 100644 index 00000000000..828e48615f0 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-1198291124021810.csv @@ -0,0 +1,35 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +19,2 +21,2 +31,2 +30,2 +9,2 +27,2 +28,2 +32,2 +16,3 +33,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-12211229035620551.csv b/python/cugraph/cugraph/testing/results/traversal-12211229035620551.csv new file mode 100644 index 00000000000..d7178211365 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-12211229035620551.csv @@ -0,0 +1,35 @@ +vertex,distance,predecessor +33,3,32 +0,1,7 +32,2,2 +2,1,7 +1,1,7 +3,1,7 +31,2,0 +8,2,0 +13,2,0 +23,3,32 +5,2,0 +6,2,0 +7,0,-1 +27,2,2 +29,3,32 +30,2,1 +4,2,0 +10,2,0 +19,2,0 +24,3,31 +25,3,31 +28,2,2 +9,2,2 +12,2,0 +14,3,32 +15,3,32 +16,3,5 +17,2,0 +18,3,32 +20,3,32 +21,2,0 +22,3,32 +26,4,33 +11,2,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-13794012085099560.csv b/python/cugraph/cugraph/testing/results/traversal-13794012085099560.csv new file mode 100644 index 00000000000..84194972ecf --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-13794012085099560.csv @@ -0,0 +1,63 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 +0,2 +3,2 +24,2 +34,2 +40,2 +43,2 +52,2 +8,2 +18,2 +28,2 +36,2 +44,2 +47,2 +12,2 +21,2 +45,2 +61,2 +58,2 +42,2 +51,2 +10,3 +15,3 +59,3 +29,3 +49,3 +7,3 +46,3 +53,3 +1,3 +30,3 +23,3 +39,3 +2,3 +4,3 +11,3 +55,3 +35,4 +19,4 +27,4 +54,4 +17,4 +26,4 +41,4 +57,4 +25,5 +6,5 +13,5 +9,5 +22,5 +31,5 +5,5 +48,5 +56,6 +32,6 +60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-16852839384883684.csv b/python/cugraph/cugraph/testing/results/traversal-16852839384883684.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-16852839384883684.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-17637631058920707.csv b/python/cugraph/cugraph/testing/results/traversal-17637631058920707.csv new file mode 100644 index 00000000000..2bf79ebfc3e --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-17637631058920707.csv @@ -0,0 +1,106 @@ +vertex,distance +1,0 +0,1 +3,1 +5,1 +6,1 +2,2 +4,2 +8,2 +9,2 +10,2 +11,2 +12,2 +13,2 +14,2 +15,2 +16,2 +17,2 +18,2 +19,2 +20,2 +21,2 +22,2 +23,2 +24,2 +25,2 +26,2 +27,2 +7,2 +29,2 +28,3 +30,3 +31,3 +32,3 +33,3 +35,3 +37,3 +40,3 +41,3 +42,3 +43,3 +44,3 +45,3 +46,3 +47,3 +48,3 +49,3 +50,3 +51,3 +52,3 +38,3 +39,3 +55,3 +56,3 +36,3 +54,3 +57,3 +58,3 +77,3 +53,3 +71,3 +85,3 +66,4 +72,4 +67,4 +70,4 +73,4 +74,4 +75,4 +76,4 +79,4 +80,4 +82,4 +83,4 +84,4 +86,4 +93,4 +99,4 +78,4 +91,4 +34,4 +102,4 +64,4 +65,4 +69,4 +68,4 +81,4 +88,5 +89,5 +90,5 +96,5 +97,5 +100,5 +87,5 +92,5 +103,5 +104,5 +94,5 +95,5 +98,5 +60,5 +62,5 +101,5 +61,5 +59,5 +63,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-17701312393774934.csv b/python/cugraph/cugraph/testing/results/traversal-17701312393774934.csv new file mode 100644 index 00000000000..6ac28e23f8c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-17701312393774934.csv @@ -0,0 +1,35 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 +2,2 +3,2 +4,2 +5,2 +6,2 +7,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +21,2 +31,2 +30,2 +9,2 +14,2 +15,2 +18,2 +20,2 +22,2 +23,2 +26,2 +27,2 +28,2 +29,2 +32,2 +16,3 +24,3 +25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-18005711098893413.csv b/python/cugraph/cugraph/testing/results/traversal-18005711098893413.csv new file mode 100644 index 00000000000..6ac28e23f8c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-18005711098893413.csv @@ -0,0 +1,35 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 +2,2 +3,2 +4,2 +5,2 +6,2 +7,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +21,2 +31,2 +30,2 +9,2 +14,2 +15,2 +18,2 +20,2 +22,2 +23,2 +26,2 +27,2 +28,2 +29,2 +32,2 +16,3 +24,3 +25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-20257532223395364.csv b/python/cugraph/cugraph/testing/results/traversal-20257532223395364.csv new file mode 100644 index 00000000000..5b2270cb9ed --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-20257532223395364.csv @@ -0,0 +1,35 @@ +distance,vertex,predecessor +2.0,33,13 +1.0,0,1 +2.0,32,2 +1.0,2,1 +0.0,1,-1 +1.0,3,1 +2.0,31,0 +2.0,8,0 +1.0,13,1 +3.0,23,33 +2.0,5,0 +2.0,6,0 +1.0,7,1 +2.0,27,2 +3.0,29,33 +1.0,30,1 +2.0,4,0 +2.0,10,0 +1.0,19,1 +3.0,24,31 +3.0,25,31 +2.0,28,2 +2.0,9,2 +2.0,12,0 +3.0,14,33 +3.0,15,33 +3.0,16,5 +1.0,17,1 +3.0,18,33 +3.0,20,33 +1.0,21,1 +3.0,22,33 +3.0,26,33 +2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-20996818816802203.csv b/python/cugraph/cugraph/testing/results/traversal-20996818816802203.csv new file mode 100644 index 00000000000..84194972ecf --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-20996818816802203.csv @@ -0,0 +1,63 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 +0,2 +3,2 +24,2 +34,2 +40,2 +43,2 +52,2 +8,2 +18,2 +28,2 +36,2 +44,2 +47,2 +12,2 +21,2 +45,2 +61,2 +58,2 +42,2 +51,2 +10,3 +15,3 +59,3 +29,3 +49,3 +7,3 +46,3 +53,3 +1,3 +30,3 +23,3 +39,3 +2,3 +4,3 +11,3 +55,3 +35,4 +19,4 +27,4 +54,4 +17,4 +26,4 +41,4 +57,4 +25,5 +6,5 +13,5 +9,5 +22,5 +31,5 +5,5 +48,5 +56,6 +32,6 +60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-21489979096431321.csv b/python/cugraph/cugraph/testing/results/traversal-21489979096431321.csv new file mode 100644 index 00000000000..227b61d8259 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-21489979096431321.csv @@ -0,0 +1,63 @@ +vertex,distance +1,0 +17,1 +19,1 +26,1 +27,1 +28,1 +36,1 +41,1 +54,1 +6,2 +9,2 +13,2 +22,2 +25,2 +31,2 +57,2 +7,2 +30,2 +8,2 +20,2 +47,2 +23,2 +37,2 +39,2 +40,2 +59,2 +56,3 +5,3 +32,3 +48,3 +42,3 +3,3 +45,3 +16,3 +18,3 +38,3 +44,3 +50,3 +0,3 +10,3 +51,3 +14,3 +21,3 +33,3 +34,3 +43,3 +61,3 +15,3 +52,3 +60,4 +2,4 +24,4 +29,4 +58,4 +4,4 +11,4 +55,4 +12,4 +49,4 +46,4 +53,4 +35,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-22026915197979443.csv b/python/cugraph/cugraph/testing/results/traversal-22026915197979443.csv new file mode 100644 index 00000000000..828e48615f0 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-22026915197979443.csv @@ -0,0 +1,35 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +19,2 +21,2 +31,2 +30,2 +9,2 +27,2 +28,2 +32,2 +16,3 +33,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-22884663737948621.csv b/python/cugraph/cugraph/testing/results/traversal-22884663737948621.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-22884663737948621.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-23382061985704026.csv b/python/cugraph/cugraph/testing/results/traversal-23382061985704026.csv new file mode 100644 index 00000000000..828e48615f0 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-23382061985704026.csv @@ -0,0 +1,35 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +19,2 +21,2 +31,2 +30,2 +9,2 +27,2 +28,2 +32,2 +16,3 +33,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-23806279448496695.csv b/python/cugraph/cugraph/testing/results/traversal-23806279448496695.csv new file mode 100644 index 00000000000..828e48615f0 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-23806279448496695.csv @@ -0,0 +1,35 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +19,2 +21,2 +31,2 +30,2 +9,2 +27,2 +28,2 +32,2 +16,3 +33,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-24542947045216202.csv b/python/cugraph/cugraph/testing/results/traversal-24542947045216202.csv new file mode 100644 index 00000000000..828e48615f0 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-24542947045216202.csv @@ -0,0 +1,35 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +19,2 +21,2 +31,2 +30,2 +9,2 +27,2 +28,2 +32,2 +16,3 +33,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-24559072556563332.csv b/python/cugraph/cugraph/testing/results/traversal-24559072556563332.csv new file mode 100644 index 00000000000..384b1e3707b --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-24559072556563332.csv @@ -0,0 +1,60 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 +0,2 +3,2 +24,2 +34,2 +40,2 +43,2 +52,2 +8,2 +18,2 +28,2 +36,2 +44,2 +47,2 +12,2 +21,2 +45,2 +61,2 +58,2 +42,2 +51,2 +10,3 +15,3 +59,3 +29,3 +49,3 +7,3 +46,3 +53,3 +1,3 +30,3 +23,3 +39,3 +2,3 +4,3 +11,3 +55,3 +35,4 +19,4 +27,4 +54,4 +17,4 +26,4 +41,4 +57,4 +25,5 +6,5 +13,5 +9,5 +22,5 +31,5 +5,5 +48,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-24566330077712845.csv b/python/cugraph/cugraph/testing/results/traversal-24566330077712845.csv new file mode 100644 index 00000000000..23e577378c6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-24566330077712845.csv @@ -0,0 +1,5 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-24760070215193007.csv b/python/cugraph/cugraph/testing/results/traversal-24760070215193007.csv new file mode 100644 index 00000000000..6ac28e23f8c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-24760070215193007.csv @@ -0,0 +1,35 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 +2,2 +3,2 +4,2 +5,2 +6,2 +7,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +21,2 +31,2 +30,2 +9,2 +14,2 +15,2 +18,2 +20,2 +22,2 +23,2 +26,2 +27,2 +28,2 +29,2 +32,2 +16,3 +24,3 +25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-25432193970951106.csv b/python/cugraph/cugraph/testing/results/traversal-25432193970951106.csv new file mode 100644 index 00000000000..84194972ecf --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-25432193970951106.csv @@ -0,0 +1,63 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 +0,2 +3,2 +24,2 +34,2 +40,2 +43,2 +52,2 +8,2 +18,2 +28,2 +36,2 +44,2 +47,2 +12,2 +21,2 +45,2 +61,2 +58,2 +42,2 +51,2 +10,3 +15,3 +59,3 +29,3 +49,3 +7,3 +46,3 +53,3 +1,3 +30,3 +23,3 +39,3 +2,3 +4,3 +11,3 +55,3 +35,4 +19,4 +27,4 +54,4 +17,4 +26,4 +41,4 +57,4 +25,5 +6,5 +13,5 +9,5 +22,5 +31,5 +5,5 +48,5 +56,6 +32,6 +60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-25977799875707499.csv b/python/cugraph/cugraph/testing/results/traversal-25977799875707499.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-25977799875707499.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-26769783379741560.csv b/python/cugraph/cugraph/testing/results/traversal-26769783379741560.csv new file mode 100644 index 00000000000..d7178211365 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-26769783379741560.csv @@ -0,0 +1,35 @@ +vertex,distance,predecessor +33,3,32 +0,1,7 +32,2,2 +2,1,7 +1,1,7 +3,1,7 +31,2,0 +8,2,0 +13,2,0 +23,3,32 +5,2,0 +6,2,0 +7,0,-1 +27,2,2 +29,3,32 +30,2,1 +4,2,0 +10,2,0 +19,2,0 +24,3,31 +25,3,31 +28,2,2 +9,2,2 +12,2,0 +14,3,32 +15,3,32 +16,3,5 +17,2,0 +18,3,32 +20,3,32 +21,2,0 +22,3,32 +26,4,33 +11,2,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-2684007979152506.csv b/python/cugraph/cugraph/testing/results/traversal-2684007979152506.csv new file mode 100644 index 00000000000..dd3b38a55c6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-2684007979152506.csv @@ -0,0 +1,6 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-29053032045714712.csv b/python/cugraph/cugraph/testing/results/traversal-29053032045714712.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-29053032045714712.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-30452085807441890.csv b/python/cugraph/cugraph/testing/results/traversal-30452085807441890.csv new file mode 100644 index 00000000000..23e577378c6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-30452085807441890.csv @@ -0,0 +1,5 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-30541863852431260.csv b/python/cugraph/cugraph/testing/results/traversal-30541863852431260.csv new file mode 100644 index 00000000000..2bf79ebfc3e --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-30541863852431260.csv @@ -0,0 +1,106 @@ +vertex,distance +1,0 +0,1 +3,1 +5,1 +6,1 +2,2 +4,2 +8,2 +9,2 +10,2 +11,2 +12,2 +13,2 +14,2 +15,2 +16,2 +17,2 +18,2 +19,2 +20,2 +21,2 +22,2 +23,2 +24,2 +25,2 +26,2 +27,2 +7,2 +29,2 +28,3 +30,3 +31,3 +32,3 +33,3 +35,3 +37,3 +40,3 +41,3 +42,3 +43,3 +44,3 +45,3 +46,3 +47,3 +48,3 +49,3 +50,3 +51,3 +52,3 +38,3 +39,3 +55,3 +56,3 +36,3 +54,3 +57,3 +58,3 +77,3 +53,3 +71,3 +85,3 +66,4 +72,4 +67,4 +70,4 +73,4 +74,4 +75,4 +76,4 +79,4 +80,4 +82,4 +83,4 +84,4 +86,4 +93,4 +99,4 +78,4 +91,4 +34,4 +102,4 +64,4 +65,4 +69,4 +68,4 +81,4 +88,5 +89,5 +90,5 +96,5 +97,5 +100,5 +87,5 +92,5 +103,5 +104,5 +94,5 +95,5 +98,5 +60,5 +62,5 +101,5 +61,5 +59,5 +63,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-33225028299752134.csv b/python/cugraph/cugraph/testing/results/traversal-33225028299752134.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-33225028299752134.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-34595993037949685.csv b/python/cugraph/cugraph/testing/results/traversal-34595993037949685.csv new file mode 100644 index 00000000000..dd3b38a55c6 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-34595993037949685.csv @@ -0,0 +1,6 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-35853313043454625.csv b/python/cugraph/cugraph/testing/results/traversal-35853313043454625.csv new file mode 100644 index 00000000000..6ac28e23f8c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-35853313043454625.csv @@ -0,0 +1,35 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 +2,2 +3,2 +4,2 +5,2 +6,2 +7,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +21,2 +31,2 +30,2 +9,2 +14,2 +15,2 +18,2 +20,2 +22,2 +23,2 +26,2 +27,2 +28,2 +29,2 +32,2 +16,3 +24,3 +25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-35983514138250487.csv b/python/cugraph/cugraph/testing/results/traversal-35983514138250487.csv new file mode 100644 index 00000000000..84194972ecf --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-35983514138250487.csv @@ -0,0 +1,63 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 +0,2 +3,2 +24,2 +34,2 +40,2 +43,2 +52,2 +8,2 +18,2 +28,2 +36,2 +44,2 +47,2 +12,2 +21,2 +45,2 +61,2 +58,2 +42,2 +51,2 +10,3 +15,3 +59,3 +29,3 +49,3 +7,3 +46,3 +53,3 +1,3 +30,3 +23,3 +39,3 +2,3 +4,3 +11,3 +55,3 +35,4 +19,4 +27,4 +54,4 +17,4 +26,4 +41,4 +57,4 +25,5 +6,5 +13,5 +9,5 +22,5 +31,5 +5,5 +48,5 +56,6 +32,6 +60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-457988537373597.csv b/python/cugraph/cugraph/testing/results/traversal-457988537373597.csv new file mode 100644 index 00000000000..a09c207f808 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-457988537373597.csv @@ -0,0 +1,3 @@ +vertex,distance +1237,0 +1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-5509948256545934.csv b/python/cugraph/cugraph/testing/results/traversal-5509948256545934.csv new file mode 100644 index 00000000000..227b61d8259 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-5509948256545934.csv @@ -0,0 +1,63 @@ +vertex,distance +1,0 +17,1 +19,1 +26,1 +27,1 +28,1 +36,1 +41,1 +54,1 +6,2 +9,2 +13,2 +22,2 +25,2 +31,2 +57,2 +7,2 +30,2 +8,2 +20,2 +47,2 +23,2 +37,2 +39,2 +40,2 +59,2 +56,3 +5,3 +32,3 +48,3 +42,3 +3,3 +45,3 +16,3 +18,3 +38,3 +44,3 +50,3 +0,3 +10,3 +51,3 +14,3 +21,3 +33,3 +34,3 +43,3 +61,3 +15,3 +52,3 +60,4 +2,4 +24,4 +29,4 +58,4 +4,4 +11,4 +55,4 +12,4 +49,4 +46,4 +53,4 +35,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-6028686672229212.csv b/python/cugraph/cugraph/testing/results/traversal-6028686672229212.csv new file mode 100644 index 00000000000..3a273143f56 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-6028686672229212.csv @@ -0,0 +1,8 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-6076307202060871.csv b/python/cugraph/cugraph/testing/results/traversal-6076307202060871.csv new file mode 100644 index 00000000000..6ac28e23f8c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-6076307202060871.csv @@ -0,0 +1,35 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 +2,2 +3,2 +4,2 +5,2 +6,2 +7,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +21,2 +31,2 +30,2 +9,2 +14,2 +15,2 +18,2 +20,2 +22,2 +23,2 +26,2 +27,2 +28,2 +29,2 +32,2 +16,3 +24,3 +25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-6102329022496213.csv b/python/cugraph/cugraph/testing/results/traversal-6102329022496213.csv new file mode 100644 index 00000000000..384b1e3707b --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-6102329022496213.csv @@ -0,0 +1,60 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 +0,2 +3,2 +24,2 +34,2 +40,2 +43,2 +52,2 +8,2 +18,2 +28,2 +36,2 +44,2 +47,2 +12,2 +21,2 +45,2 +61,2 +58,2 +42,2 +51,2 +10,3 +15,3 +59,3 +29,3 +49,3 +7,3 +46,3 +53,3 +1,3 +30,3 +23,3 +39,3 +2,3 +4,3 +11,3 +55,3 +35,4 +19,4 +27,4 +54,4 +17,4 +26,4 +41,4 +57,4 +25,5 +6,5 +13,5 +9,5 +22,5 +31,5 +5,5 +48,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-7136448615947447.csv b/python/cugraph/cugraph/testing/results/traversal-7136448615947447.csv new file mode 100644 index 00000000000..7ae0b62a55c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-7136448615947447.csv @@ -0,0 +1,8 @@ +vertex,distance +1,0.0 +4,1.0 +2,1.0 +6,2.0 +7,2.0 +5,2.0 +3,2.0 diff --git a/python/cugraph/cugraph/testing/results/traversal-7700395001688692.csv b/python/cugraph/cugraph/testing/results/traversal-7700395001688692.csv new file mode 100644 index 00000000000..828e48615f0 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-7700395001688692.csv @@ -0,0 +1,35 @@ +vertex,distance +7,0 +0,1 +1,1 +2,1 +3,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +19,2 +21,2 +31,2 +30,2 +9,2 +27,2 +28,2 +32,2 +16,3 +33,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-7863939874314132.csv b/python/cugraph/cugraph/testing/results/traversal-7863939874314132.csv new file mode 100644 index 00000000000..3a273143f56 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-7863939874314132.csv @@ -0,0 +1,8 @@ +vertex,distance +16,0 +14,1 +20,1 +33,1 +37,1 +38,1 +50,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-8862356193854587.csv b/python/cugraph/cugraph/testing/results/traversal-8862356193854587.csv new file mode 100644 index 00000000000..dda4c0b31ba --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-8862356193854587.csv @@ -0,0 +1,35 @@ +vertex,distance +1,0 +0,1 +2,1 +3,1 +7,1 +13,1 +17,1 +19,1 +21,1 +30,1 +4,2 +5,2 +6,2 +8,2 +10,2 +11,2 +12,2 +31,2 +9,2 +27,2 +28,2 +32,2 +33,2 +16,3 +24,3 +25,3 +23,3 +14,3 +15,3 +18,3 +20,3 +22,3 +29,3 +26,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-9148021614037858.csv b/python/cugraph/cugraph/testing/results/traversal-9148021614037858.csv new file mode 100644 index 00000000000..6ac28e23f8c --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-9148021614037858.csv @@ -0,0 +1,35 @@ +vertex,distance +19,0 +0,1 +1,1 +33,1 +2,2 +3,2 +4,2 +5,2 +6,2 +7,2 +8,2 +10,2 +11,2 +12,2 +13,2 +17,2 +21,2 +31,2 +30,2 +9,2 +14,2 +15,2 +18,2 +20,2 +22,2 +23,2 +26,2 +27,2 +28,2 +29,2 +32,2 +16,3 +24,3 +25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-9867286825871764.csv b/python/cugraph/cugraph/testing/results/traversal-9867286825871764.csv new file mode 100644 index 00000000000..4ce6a683be2 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal-9867286825871764.csv @@ -0,0 +1,4 @@ +distance,vertex,predecessor +10.0,1,0 +0.0,0,-1 +30.0,2,1 diff --git a/python/cugraph/cugraph/testing/results/traversal_mappings.csv b/python/cugraph/cugraph/testing/results/traversal_mappings.csv new file mode 100644 index 00000000000..13dd3fc2b50 --- /dev/null +++ b/python/cugraph/cugraph/testing/results/traversal_mappings.csv @@ -0,0 +1,45 @@ +hashable_dict_repr,filename +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-13794012085099560.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-20996818816802203.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-7863939874314132.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-6028686672229212.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-6102329022496213.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-24559072556563332.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-25432193970951106.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-35983514138250487.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-29053032045714712.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-10209535434255476.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-33225028299752134.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-457988537373597.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-16852839384883684.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-25977799875707499.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-22884663737948621.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-1014939923221900.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-6076307202060871.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-17701312393774934.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-30452085807441890.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-24566330077712845.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-18005711098893413.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-35853313043454625.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-24760070215193007.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-9148021614037858.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-22026915197979443.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-24542947045216202.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-34595993037949685.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-2684007979152506.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-23382061985704026.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-23806279448496695.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-1198291124021810.csv +"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-7700395001688692.csv +"(('algo', 'bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '7'))",traversal-12211229035620551.csv +"(('algo', 'bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('source', '7'))",traversal-26769783379741560.csv +"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '1'))",traversal-11196971449711926.csv +"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '1'), ('test', 'data_type_conversion'))",traversal-8862356193854587.csv +"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('source', '1'))",traversal-21489979096431321.csv +"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('source', '1'), ('test', 'data_type_conversion'))",traversal-5509948256545934.csv +"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', 'True'), ('source', '1'))",traversal-30541863852431260.csv +"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', 'True'), ('source', '1'), ('test', 'data_type_conversion'))",traversal-17637631058920707.csv +"(('algo', 'sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '1'))",traversal-10237264400944458.csv +"(('algo', 'sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('source', '1'))",traversal-20257532223395364.csv +"(('algo', 'sssp_nonnative'), ('test', 'network_edge_attr'))",traversal-9867286825871764.csv +"(('algo', 'shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', 'True'), ('source', '1'), ('weight', 'weight'))",traversal-7136448615947447.csv diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 0bc06bb38d7..f1f4cd81451 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -237,12 +237,9 @@ def get_resultset(category, **kwargs): weight="weight", ) -traversal_mappings = cudf.DataFrame(columns=["hashable_dict_repr", "filename"]) - - -random.seed(24) # Generating ALL results files +"""random.seed(24) for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() # Currently, only traversal results files are generated @@ -253,8 +250,25 @@ def get_resultset(category, **kwargs): traversal_mappings = cudf.concat( [traversal_mappings, temp_mapping], axis=0, ignore_index=True ) - print(temp_filename) + # print(temp_filename) # print("traversal_" + temp_filename) res.to_csv(results_dir / temp_filename, index=False) - -traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False) +traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False)""" + + +def generate_results(): + random.seed(24) + traversal_mappings = cudf.DataFrame(columns=["hashable_dict_repr", "filename"]) + # Generating ALL results files + for temp in _resultsets: + res = _resultsets[temp].get_cudf_dataframe() + # Currently, only traversal results files are generated + temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" + temp_mapping = cudf.DataFrame( + [[str(temp), temp_filename]], columns=["hashable_dict_repr", "filename"] + ) + traversal_mappings = cudf.concat( + [traversal_mappings, temp_mapping], axis=0, ignore_index=True + ) + res.to_csv(results_dir / temp_filename, index=False) + traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False) From f4b21d7bfb66e9d7d7a359eac507567cece99f48 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Mon, 31 Jul 2023 20:45:58 +0000 Subject: [PATCH 08/20] Change resultset mappings format --- python/cugraph/cugraph/testing/__init__.py | 2 +- ...4939923221900.csv => 1038281390523078.csv} | 0 ...4007979152506.csv => 1081121981713141.csv} | 0 ...1312393774934.csv => 1120419326843553.csv} | 0 ...4012085099560.csv => 1124485822090487.csv} | 0 ...209535434255476.csv => 14314120729501.csv} | 0 ...89979096431321.csv => 172188670880910.csv} | 0 ...28686672229212.csv => 188398733063004.csv} | 0 ...05711098893413.csv => 189882724201031.csv} | 0 ...59072556563332.csv => 190697381576149.csv} | 0 ...36448615947447.csv => 223015853235383.csv} | 0 ...98291124021810.csv => 240638103958132.csv} | 0 ...63939874314132.csv => 245745928001428.csv} | 0 ...96971449711926.csv => 276948497384571.csv} | 0 ...60070215193007.csv => 285876289784674.csv} | 0 ...67286825871764.csv => 308351777319316.csv} | 0 ...852839384883684.csv => 31714534985100.csv} | 0 ...84663737948621.csv => 319050385288308.csv} | 0 ...37264400944458.csv => 319914331540810.csv} | 0 ...62356193854587.csv => 349902694645046.csv} | 0 ...026915197979443.csv => 37447363258930.csv} | 0 ...11229035620551.csv => 381600612247751.csv} | 0 ...96818816802203.csv => 431063157185576.csv} | 0 ...77799875707499.csv => 526650785538532.csv} | 0 ...37631058920707.csv => 551177413608707.csv} | 0 ...53313043454625.csv => 553165838223190.csv} | 0 ...76307202060871.csv => 562676383765605.csv} | 0 ...57532223395364.csv => 633044963923492.csv} | 0 ...32193970951106.csv => 656150055689627.csv} | 0 ...09948256545934.csv => 671563943115481.csv} | 0 ...82061985704026.csv => 688340850412339.csv} | 0 ...53032045714712.csv => 715146362591693.csv} | 0 ...06279448496695.csv => 730687934441562.csv} | 0 ...42947045216202.csv => 743945746483767.csv} | 0 ...00395001688692.csv => 766965872267210.csv} | 0 ...02329022496213.csv => 767470587558788.csv} | 0 ...66330077712845.csv => 767697247244749.csv} | 0 ...48021614037858.csv => 773751608857007.csv} | 0 ...83514138250487.csv => 794754027574210.csv} | 0 ...25028299752134.csv => 811808371982955.csv} | 0 ...69783379741560.csv => 836556098128760.csv} | 0 ...595993037949685.csv => 83873432859770.csv} | 0 ...57988537373597.csv => 907905196596504.csv} | 0 ...52085807441890.csv => 951630488463330.csv} | 0 ...41863852431260.csv => 954435445708700.csv} | 0 .../testing/results/traversal_mappings.csv | 90 ++++++++--------- python/cugraph/cugraph/testing/resultset.py | 98 ++++++++++++++++--- 47 files changed, 133 insertions(+), 57 deletions(-) rename python/cugraph/cugraph/testing/results/{traversal-1014939923221900.csv => 1038281390523078.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-2684007979152506.csv => 1081121981713141.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-17701312393774934.csv => 1120419326843553.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-13794012085099560.csv => 1124485822090487.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-10209535434255476.csv => 14314120729501.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-21489979096431321.csv => 172188670880910.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-6028686672229212.csv => 188398733063004.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-18005711098893413.csv => 189882724201031.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-24559072556563332.csv => 190697381576149.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-7136448615947447.csv => 223015853235383.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-1198291124021810.csv => 240638103958132.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-7863939874314132.csv => 245745928001428.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-11196971449711926.csv => 276948497384571.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-24760070215193007.csv => 285876289784674.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-9867286825871764.csv => 308351777319316.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-16852839384883684.csv => 31714534985100.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-22884663737948621.csv => 319050385288308.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-10237264400944458.csv => 319914331540810.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-8862356193854587.csv => 349902694645046.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-22026915197979443.csv => 37447363258930.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-12211229035620551.csv => 381600612247751.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-20996818816802203.csv => 431063157185576.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-25977799875707499.csv => 526650785538532.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-17637631058920707.csv => 551177413608707.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-35853313043454625.csv => 553165838223190.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-6076307202060871.csv => 562676383765605.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-20257532223395364.csv => 633044963923492.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-25432193970951106.csv => 656150055689627.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-5509948256545934.csv => 671563943115481.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-23382061985704026.csv => 688340850412339.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-29053032045714712.csv => 715146362591693.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-23806279448496695.csv => 730687934441562.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-24542947045216202.csv => 743945746483767.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-7700395001688692.csv => 766965872267210.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-6102329022496213.csv => 767470587558788.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-24566330077712845.csv => 767697247244749.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-9148021614037858.csv => 773751608857007.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-35983514138250487.csv => 794754027574210.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-33225028299752134.csv => 811808371982955.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-26769783379741560.csv => 836556098128760.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-34595993037949685.csv => 83873432859770.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-457988537373597.csv => 907905196596504.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-30452085807441890.csv => 951630488463330.csv} (100%) rename python/cugraph/cugraph/testing/results/{traversal-30541863852431260.csv => 954435445708700.csv} (100%) diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 52490ba1424..d9d6a614551 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -11,6 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH +# from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH from cugraph.testing.resultset import get_resultset diff --git a/python/cugraph/cugraph/testing/results/traversal-1014939923221900.csv b/python/cugraph/cugraph/testing/results/1038281390523078.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-1014939923221900.csv rename to python/cugraph/cugraph/testing/results/1038281390523078.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-2684007979152506.csv b/python/cugraph/cugraph/testing/results/1081121981713141.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-2684007979152506.csv rename to python/cugraph/cugraph/testing/results/1081121981713141.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-17701312393774934.csv b/python/cugraph/cugraph/testing/results/1120419326843553.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-17701312393774934.csv rename to python/cugraph/cugraph/testing/results/1120419326843553.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-13794012085099560.csv b/python/cugraph/cugraph/testing/results/1124485822090487.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-13794012085099560.csv rename to python/cugraph/cugraph/testing/results/1124485822090487.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-10209535434255476.csv b/python/cugraph/cugraph/testing/results/14314120729501.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-10209535434255476.csv rename to python/cugraph/cugraph/testing/results/14314120729501.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-21489979096431321.csv b/python/cugraph/cugraph/testing/results/172188670880910.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-21489979096431321.csv rename to python/cugraph/cugraph/testing/results/172188670880910.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-6028686672229212.csv b/python/cugraph/cugraph/testing/results/188398733063004.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-6028686672229212.csv rename to python/cugraph/cugraph/testing/results/188398733063004.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-18005711098893413.csv b/python/cugraph/cugraph/testing/results/189882724201031.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-18005711098893413.csv rename to python/cugraph/cugraph/testing/results/189882724201031.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-24559072556563332.csv b/python/cugraph/cugraph/testing/results/190697381576149.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-24559072556563332.csv rename to python/cugraph/cugraph/testing/results/190697381576149.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-7136448615947447.csv b/python/cugraph/cugraph/testing/results/223015853235383.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-7136448615947447.csv rename to python/cugraph/cugraph/testing/results/223015853235383.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-1198291124021810.csv b/python/cugraph/cugraph/testing/results/240638103958132.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-1198291124021810.csv rename to python/cugraph/cugraph/testing/results/240638103958132.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-7863939874314132.csv b/python/cugraph/cugraph/testing/results/245745928001428.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-7863939874314132.csv rename to python/cugraph/cugraph/testing/results/245745928001428.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-11196971449711926.csv b/python/cugraph/cugraph/testing/results/276948497384571.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-11196971449711926.csv rename to python/cugraph/cugraph/testing/results/276948497384571.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-24760070215193007.csv b/python/cugraph/cugraph/testing/results/285876289784674.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-24760070215193007.csv rename to python/cugraph/cugraph/testing/results/285876289784674.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-9867286825871764.csv b/python/cugraph/cugraph/testing/results/308351777319316.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-9867286825871764.csv rename to python/cugraph/cugraph/testing/results/308351777319316.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-16852839384883684.csv b/python/cugraph/cugraph/testing/results/31714534985100.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-16852839384883684.csv rename to python/cugraph/cugraph/testing/results/31714534985100.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-22884663737948621.csv b/python/cugraph/cugraph/testing/results/319050385288308.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-22884663737948621.csv rename to python/cugraph/cugraph/testing/results/319050385288308.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-10237264400944458.csv b/python/cugraph/cugraph/testing/results/319914331540810.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-10237264400944458.csv rename to python/cugraph/cugraph/testing/results/319914331540810.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-8862356193854587.csv b/python/cugraph/cugraph/testing/results/349902694645046.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-8862356193854587.csv rename to python/cugraph/cugraph/testing/results/349902694645046.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-22026915197979443.csv b/python/cugraph/cugraph/testing/results/37447363258930.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-22026915197979443.csv rename to python/cugraph/cugraph/testing/results/37447363258930.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-12211229035620551.csv b/python/cugraph/cugraph/testing/results/381600612247751.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-12211229035620551.csv rename to python/cugraph/cugraph/testing/results/381600612247751.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-20996818816802203.csv b/python/cugraph/cugraph/testing/results/431063157185576.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-20996818816802203.csv rename to python/cugraph/cugraph/testing/results/431063157185576.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-25977799875707499.csv b/python/cugraph/cugraph/testing/results/526650785538532.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-25977799875707499.csv rename to python/cugraph/cugraph/testing/results/526650785538532.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-17637631058920707.csv b/python/cugraph/cugraph/testing/results/551177413608707.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-17637631058920707.csv rename to python/cugraph/cugraph/testing/results/551177413608707.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-35853313043454625.csv b/python/cugraph/cugraph/testing/results/553165838223190.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-35853313043454625.csv rename to python/cugraph/cugraph/testing/results/553165838223190.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-6076307202060871.csv b/python/cugraph/cugraph/testing/results/562676383765605.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-6076307202060871.csv rename to python/cugraph/cugraph/testing/results/562676383765605.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-20257532223395364.csv b/python/cugraph/cugraph/testing/results/633044963923492.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-20257532223395364.csv rename to python/cugraph/cugraph/testing/results/633044963923492.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-25432193970951106.csv b/python/cugraph/cugraph/testing/results/656150055689627.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-25432193970951106.csv rename to python/cugraph/cugraph/testing/results/656150055689627.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-5509948256545934.csv b/python/cugraph/cugraph/testing/results/671563943115481.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-5509948256545934.csv rename to python/cugraph/cugraph/testing/results/671563943115481.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-23382061985704026.csv b/python/cugraph/cugraph/testing/results/688340850412339.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-23382061985704026.csv rename to python/cugraph/cugraph/testing/results/688340850412339.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-29053032045714712.csv b/python/cugraph/cugraph/testing/results/715146362591693.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-29053032045714712.csv rename to python/cugraph/cugraph/testing/results/715146362591693.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-23806279448496695.csv b/python/cugraph/cugraph/testing/results/730687934441562.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-23806279448496695.csv rename to python/cugraph/cugraph/testing/results/730687934441562.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-24542947045216202.csv b/python/cugraph/cugraph/testing/results/743945746483767.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-24542947045216202.csv rename to python/cugraph/cugraph/testing/results/743945746483767.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-7700395001688692.csv b/python/cugraph/cugraph/testing/results/766965872267210.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-7700395001688692.csv rename to python/cugraph/cugraph/testing/results/766965872267210.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-6102329022496213.csv b/python/cugraph/cugraph/testing/results/767470587558788.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-6102329022496213.csv rename to python/cugraph/cugraph/testing/results/767470587558788.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-24566330077712845.csv b/python/cugraph/cugraph/testing/results/767697247244749.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-24566330077712845.csv rename to python/cugraph/cugraph/testing/results/767697247244749.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-9148021614037858.csv b/python/cugraph/cugraph/testing/results/773751608857007.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-9148021614037858.csv rename to python/cugraph/cugraph/testing/results/773751608857007.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-35983514138250487.csv b/python/cugraph/cugraph/testing/results/794754027574210.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-35983514138250487.csv rename to python/cugraph/cugraph/testing/results/794754027574210.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-33225028299752134.csv b/python/cugraph/cugraph/testing/results/811808371982955.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-33225028299752134.csv rename to python/cugraph/cugraph/testing/results/811808371982955.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-26769783379741560.csv b/python/cugraph/cugraph/testing/results/836556098128760.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-26769783379741560.csv rename to python/cugraph/cugraph/testing/results/836556098128760.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-34595993037949685.csv b/python/cugraph/cugraph/testing/results/83873432859770.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-34595993037949685.csv rename to python/cugraph/cugraph/testing/results/83873432859770.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-457988537373597.csv b/python/cugraph/cugraph/testing/results/907905196596504.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-457988537373597.csv rename to python/cugraph/cugraph/testing/results/907905196596504.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-30452085807441890.csv b/python/cugraph/cugraph/testing/results/951630488463330.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-30452085807441890.csv rename to python/cugraph/cugraph/testing/results/951630488463330.csv diff --git a/python/cugraph/cugraph/testing/results/traversal-30541863852431260.csv b/python/cugraph/cugraph/testing/results/954435445708700.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/traversal-30541863852431260.csv rename to python/cugraph/cugraph/testing/results/954435445708700.csv diff --git a/python/cugraph/cugraph/testing/results/traversal_mappings.csv b/python/cugraph/cugraph/testing/results/traversal_mappings.csv index 13dd3fc2b50..f0e38d6f4ef 100644 --- a/python/cugraph/cugraph/testing/results/traversal_mappings.csv +++ b/python/cugraph/cugraph/testing/results/traversal_mappings.csv @@ -1,45 +1,45 @@ -hashable_dict_repr,filename -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-13794012085099560.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-20996818816802203.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-7863939874314132.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-6028686672229212.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-6102329022496213.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-24559072556563332.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('start_vertex', '16'))",traversal-25432193970951106.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'dolphins'), ('graph_directed', 'False'), ('start_vertex', '16'))",traversal-35983514138250487.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-29053032045714712.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-10209535434255476.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-33225028299752134.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-457988537373597.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-16852839384883684.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-25977799875707499.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'netscience'), ('graph_directed', 'True'), ('start_vertex', '1237'))",traversal-22884663737948621.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'netscience'), ('graph_directed', 'False'), ('start_vertex', '1237'))",traversal-1014939923221900.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-6076307202060871.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-17701312393774934.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-30452085807441890.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-24566330077712845.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-18005711098893413.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-35853313043454625.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'True'), ('start_vertex', '19'))",traversal-24760070215193007.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate-disjoint'), ('graph_directed', 'False'), ('start_vertex', '19'))",traversal-9148021614037858.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-22026915197979443.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', 'None'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-24542947045216202.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-34595993037949685.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '1'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-2684007979152506.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-23382061985704026.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '5'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-23806279448496695.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('start_vertex', '7'))",traversal-1198291124021810.csv -"(('algo', 'single_source_shortest_path_length'), ('cutoff', '18'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('start_vertex', '7'))",traversal-7700395001688692.csv -"(('algo', 'bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '7'))",traversal-12211229035620551.csv -"(('algo', 'bfs_edges'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('source', '7'))",traversal-26769783379741560.csv -"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '1'))",traversal-11196971449711926.csv -"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '1'), ('test', 'data_type_conversion'))",traversal-8862356193854587.csv -"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('source', '1'))",traversal-21489979096431321.csv -"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'dolphins'), ('graph_directed', 'True'), ('source', '1'), ('test', 'data_type_conversion'))",traversal-5509948256545934.csv -"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', 'True'), ('source', '1'))",traversal-30541863852431260.csv -"(('algo', 'single_source_dijkstra_path_length'), ('graph_dataset', 'polbooks'), ('graph_directed', 'True'), ('source', '1'), ('test', 'data_type_conversion'))",traversal-17637631058920707.csv -"(('algo', 'sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', 'True'), ('source', '1'))",traversal-10237264400944458.csv -"(('algo', 'sssp_nonnative'), ('graph_dataset', 'karate'), ('graph_directed', 'False'), ('source', '1'))",traversal-20257532223395364.csv -"(('algo', 'sssp_nonnative'), ('test', 'network_edge_attr'))",traversal-9867286825871764.csv -"(('algo', 'shortest_path_length'), ('graph_dataset', 'DISCONNECTED'), ('graph_directed', 'True'), ('source', '1'), ('weight', 'weight'))",traversal-7136448615947447.csv +UUID algo arg1 arg1val arg2 arg2val arg3 arg3val arg4 arg4val arg5 arg5val arg6 arg6val arg7 arg7val arg8 arg8val arg9 arg9val +431063157185576 single_source_shortest_path_length cutoff None graph_dataset dolphins graph_directed True start_vertex 16 +656150055689627 single_source_shortest_path_length cutoff None graph_dataset dolphins graph_directed False start_vertex 16 +245745928001428 single_source_shortest_path_length cutoff 1 graph_dataset dolphins graph_directed True start_vertex 16 +188398733063004 single_source_shortest_path_length cutoff 1 graph_dataset dolphins graph_directed False start_vertex 16 +190697381576149 single_source_shortest_path_length cutoff 5 graph_dataset dolphins graph_directed True start_vertex 16 +767470587558788 single_source_shortest_path_length cutoff 5 graph_dataset dolphins graph_directed False start_vertex 16 +794754027574210 single_source_shortest_path_length cutoff 18 graph_dataset dolphins graph_directed True start_vertex 16 +1124485822090487 single_source_shortest_path_length cutoff 18 graph_dataset dolphins graph_directed False start_vertex 16 +907905196596504 single_source_shortest_path_length cutoff None graph_dataset netscience graph_directed True start_vertex 1237 +319050385288308 single_source_shortest_path_length cutoff None graph_dataset netscience graph_directed False start_vertex 1237 +1038281390523078 single_source_shortest_path_length cutoff 1 graph_dataset netscience graph_directed True start_vertex 1237 +14314120729501 single_source_shortest_path_length cutoff 1 graph_dataset netscience graph_directed False start_vertex 1237 +526650785538532 single_source_shortest_path_length cutoff 5 graph_dataset netscience graph_directed True start_vertex 1237 +811808371982955 single_source_shortest_path_length cutoff 5 graph_dataset netscience graph_directed False start_vertex 1237 +715146362591693 single_source_shortest_path_length cutoff 18 graph_dataset netscience graph_directed True start_vertex 1237 +31714534985100 single_source_shortest_path_length cutoff 18 graph_dataset netscience graph_directed False start_vertex 1237 +189882724201031 single_source_shortest_path_length cutoff None graph_dataset karate-disjoint graph_directed True start_vertex 19 +553165838223190 single_source_shortest_path_length cutoff None graph_dataset karate-disjoint graph_directed False start_vertex 19 +951630488463330 single_source_shortest_path_length cutoff 1 graph_dataset karate-disjoint graph_directed True start_vertex 19 +767697247244749 single_source_shortest_path_length cutoff 1 graph_dataset karate-disjoint graph_directed False start_vertex 19 +562676383765605 single_source_shortest_path_length cutoff 5 graph_dataset karate-disjoint graph_directed True start_vertex 19 +1120419326843553 single_source_shortest_path_length cutoff 5 graph_dataset karate-disjoint graph_directed False start_vertex 19 +773751608857007 single_source_shortest_path_length cutoff 18 graph_dataset karate-disjoint graph_directed True start_vertex 19 +285876289784674 single_source_shortest_path_length cutoff 18 graph_dataset karate-disjoint graph_directed False start_vertex 19 +688340850412339 single_source_shortest_path_length cutoff None graph_dataset karate graph_directed True start_vertex 7 +766965872267210 single_source_shortest_path_length cutoff None graph_dataset karate graph_directed False start_vertex 7 +1081121981713141 single_source_shortest_path_length cutoff 1 graph_dataset karate graph_directed True start_vertex 7 +83873432859770 single_source_shortest_path_length cutoff 1 graph_dataset karate graph_directed False start_vertex 7 +730687934441562 single_source_shortest_path_length cutoff 5 graph_dataset karate graph_directed True start_vertex 7 +743945746483767 single_source_shortest_path_length cutoff 5 graph_dataset karate graph_directed False start_vertex 7 +37447363258930 single_source_shortest_path_length cutoff 18 graph_dataset karate graph_directed True start_vertex 7 +240638103958132 single_source_shortest_path_length cutoff 18 graph_dataset karate graph_directed False start_vertex 7 +381600612247751 bfs_edges graph_dataset karate graph_directed True source 7 +836556098128760 bfs_edges graph_dataset karate graph_directed False source 7 +349902694645046 single_source_dijkstra_path_length graph_dataset karate graph_directed True source 1 +276948497384571 single_source_dijkstra_path_length graph_dataset karate graph_directed True source 1 test data_type_conversion +671563943115481 single_source_dijkstra_path_length graph_dataset dolphins graph_directed True source 1 +172188670880910 single_source_dijkstra_path_length graph_dataset dolphins graph_directed True source 1 test data_type_conversion +954435445708700 single_source_dijkstra_path_length graph_dataset polbooks graph_directed True source 1 +551177413608707 single_source_dijkstra_path_length graph_dataset polbooks graph_directed True source 1 test data_type_conversion +319914331540810 sssp_nonnative graph_dataset karate graph_directed True source 1 +633044963923492 sssp_nonnative graph_dataset karate graph_directed False source 1 +308351777319316 sssp_nonnative test network_edge_attr +223015853235383 shortest_path_length graph_dataset DISCONNECTED graph_directed True source 1 weight weight diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index f1f4cd81451..e5f3ac607d5 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -42,14 +42,27 @@ def add_resultset(result_data_dictionary, **kwargs): def get_resultset(category, **kwargs): - # THIS IS CALLED IN TESTS hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) mappings_path = results_dir / (category + "_mappings.csv") - mappings = cudf.read_csv(mappings_path) - results_filename = mappings[ - mappings["hashable_dict_repr"] == str(hashable_dict_repr) - ]["filename"].iloc[0] - # The assumption is that results_filename already includes the algorithm category + # Had to set dtype=str to prevent 1s being converted to True + mappings = cudf.read_csv(mappings_path, sep=" ", dtype=str) + colnames = mappings.columns + query_cols = [t for t in colnames][1:] + dict_repr = dict(hashable_dict_repr) + argnames, argvals = [t for t in dict_repr.keys()], [t for t in dict_repr.values()] + mapping_length = 2 * len(argvals) - 1 + single_mapping = np.empty(mapping_length, dtype=object) + single_mapping[0] = argvals[0] + for i in np.arange(1, len(argvals)): + single_mapping[2 * i - 1] = argnames[i] + single_mapping[2 * i] = argvals[i] + for i in np.arange(mapping_length): + mappings = mappings[mappings[query_cols[i]] == single_mapping[i]] + # results_filename = category + "-" + mappings.head(1)["UUID"].values_host[0] + # values_host is used instead of values bc strings aren't saved/possible on device + results_filename = mappings.head(1)["UUID"].values_host[0] + results_filename = results_filename + ".csv" + # Ignore for now -> Assumption is the filename already has the alg category path = results_dir / results_filename # path = Path("https://data.rapids.ai/cugraph/results/" / path return cudf.read_csv(path) @@ -258,17 +271,80 @@ def get_resultset(category, **kwargs): def generate_results(): random.seed(24) - traversal_mappings = cudf.DataFrame(columns=["hashable_dict_repr", "filename"]) + # traversal_mappings = cudf.DataFrame(columns=["hashable_dict_repr", "filename"]) + traversal_mappings = cudf.DataFrame( + columns=[ + "UUID", + "algo", + "arg1", + "arg1val", + "arg2", + "arg2val", + "arg3", + "arg3val", + "arg4", + "arg4val", + "arg5", + "arg5val", + "arg6", + "arg6val", + "arg7", + "arg7val", + "arg8", + "arg8val", + "arg9", + "arg9val", + ] + ) # Generating ALL results files for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() # Currently, only traversal results files are generated - temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" + # temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" + temp_filename = str(random.getrandbits(50)) + temp_dict = dict(temp) + argnames, argvals = [t for t in temp_dict.keys()], [ + t for t in temp_dict.values() + ] + single_mapping = np.empty(20, dtype=object) + dict_length = len(argnames) + single_mapping[0] = temp_filename + single_mapping[1] = argvals[0] + for i in np.arange(1, dict_length): + single_mapping[2 * i] = argnames[i] + single_mapping[2 * i + 1] = argvals[i] temp_mapping = cudf.DataFrame( - [[str(temp), temp_filename]], columns=["hashable_dict_repr", "filename"] + [single_mapping], + columns=[ + "UUID", + "algo", + "arg1", + "arg1val", + "arg2", + "arg2val", + "arg3", + "arg3val", + "arg4", + "arg4val", + "arg5", + "arg5val", + "arg6", + "arg6val", + "arg7", + "arg7val", + "arg8", + "arg8val", + "arg9", + "arg9val", + ], ) traversal_mappings = cudf.concat( [traversal_mappings, temp_mapping], axis=0, ignore_index=True ) - res.to_csv(results_dir / temp_filename, index=False) - traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False) + res.to_csv(results_dir / (temp_filename + ".csv"), index=False) + traversal_mappings.to_csv( + results_dir / "traversal_mappings.csv", index=False, sep=" " + ) + + +generate_results() From 45d12bcf43d9a1b9b4eddad11d927c9a6ac848da Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Mon, 31 Jul 2023 23:40:38 +0000 Subject: [PATCH 09/20] Style check and result file relabeling --- ...38281390523078.csv => traversal-1038281390523078.csv} | 0 ...81121981713141.csv => traversal-1081121981713141.csv} | 0 ...20419326843553.csv => traversal-1120419326843553.csv} | 0 ...24485822090487.csv => traversal-1124485822090487.csv} | 0 .../{14314120729501.csv => traversal-14314120729501.csv} | 0 ...172188670880910.csv => traversal-172188670880910.csv} | 0 ...188398733063004.csv => traversal-188398733063004.csv} | 0 ...189882724201031.csv => traversal-189882724201031.csv} | 0 ...190697381576149.csv => traversal-190697381576149.csv} | 0 ...223015853235383.csv => traversal-223015853235383.csv} | 0 ...240638103958132.csv => traversal-240638103958132.csv} | 0 ...245745928001428.csv => traversal-245745928001428.csv} | 0 ...276948497384571.csv => traversal-276948497384571.csv} | 0 ...285876289784674.csv => traversal-285876289784674.csv} | 0 ...308351777319316.csv => traversal-308351777319316.csv} | 0 .../{31714534985100.csv => traversal-31714534985100.csv} | 0 ...319050385288308.csv => traversal-319050385288308.csv} | 0 ...319914331540810.csv => traversal-319914331540810.csv} | 0 ...349902694645046.csv => traversal-349902694645046.csv} | 0 .../{37447363258930.csv => traversal-37447363258930.csv} | 0 ...381600612247751.csv => traversal-381600612247751.csv} | 0 ...431063157185576.csv => traversal-431063157185576.csv} | 0 ...526650785538532.csv => traversal-526650785538532.csv} | 0 ...551177413608707.csv => traversal-551177413608707.csv} | 0 ...553165838223190.csv => traversal-553165838223190.csv} | 0 ...562676383765605.csv => traversal-562676383765605.csv} | 0 ...633044963923492.csv => traversal-633044963923492.csv} | 0 ...656150055689627.csv => traversal-656150055689627.csv} | 0 ...671563943115481.csv => traversal-671563943115481.csv} | 0 ...688340850412339.csv => traversal-688340850412339.csv} | 0 ...715146362591693.csv => traversal-715146362591693.csv} | 0 ...730687934441562.csv => traversal-730687934441562.csv} | 0 ...743945746483767.csv => traversal-743945746483767.csv} | 0 ...766965872267210.csv => traversal-766965872267210.csv} | 0 ...767470587558788.csv => traversal-767470587558788.csv} | 0 ...767697247244749.csv => traversal-767697247244749.csv} | 0 ...773751608857007.csv => traversal-773751608857007.csv} | 0 ...794754027574210.csv => traversal-794754027574210.csv} | 0 ...811808371982955.csv => traversal-811808371982955.csv} | 0 ...836556098128760.csv => traversal-836556098128760.csv} | 0 .../{83873432859770.csv => traversal-83873432859770.csv} | 0 ...907905196596504.csv => traversal-907905196596504.csv} | 0 ...951630488463330.csv => traversal-951630488463330.csv} | 0 ...954435445708700.csv => traversal-954435445708700.csv} | 0 python/cugraph/cugraph/testing/resultset.py | 9 ++++----- python/cugraph/cugraph/tests/traversal/test_bfs.py | 5 ----- python/cugraph/cugraph/tests/traversal/test_paths.py | 3 +-- 47 files changed, 5 insertions(+), 12 deletions(-) rename python/cugraph/cugraph/testing/results/{1038281390523078.csv => traversal-1038281390523078.csv} (100%) rename python/cugraph/cugraph/testing/results/{1081121981713141.csv => traversal-1081121981713141.csv} (100%) rename python/cugraph/cugraph/testing/results/{1120419326843553.csv => traversal-1120419326843553.csv} (100%) rename python/cugraph/cugraph/testing/results/{1124485822090487.csv => traversal-1124485822090487.csv} (100%) rename python/cugraph/cugraph/testing/results/{14314120729501.csv => traversal-14314120729501.csv} (100%) rename python/cugraph/cugraph/testing/results/{172188670880910.csv => traversal-172188670880910.csv} (100%) rename python/cugraph/cugraph/testing/results/{188398733063004.csv => traversal-188398733063004.csv} (100%) rename python/cugraph/cugraph/testing/results/{189882724201031.csv => traversal-189882724201031.csv} (100%) rename python/cugraph/cugraph/testing/results/{190697381576149.csv => traversal-190697381576149.csv} (100%) rename python/cugraph/cugraph/testing/results/{223015853235383.csv => traversal-223015853235383.csv} (100%) rename python/cugraph/cugraph/testing/results/{240638103958132.csv => traversal-240638103958132.csv} (100%) rename python/cugraph/cugraph/testing/results/{245745928001428.csv => traversal-245745928001428.csv} (100%) rename python/cugraph/cugraph/testing/results/{276948497384571.csv => traversal-276948497384571.csv} (100%) rename python/cugraph/cugraph/testing/results/{285876289784674.csv => traversal-285876289784674.csv} (100%) rename python/cugraph/cugraph/testing/results/{308351777319316.csv => traversal-308351777319316.csv} (100%) rename python/cugraph/cugraph/testing/results/{31714534985100.csv => traversal-31714534985100.csv} (100%) rename python/cugraph/cugraph/testing/results/{319050385288308.csv => traversal-319050385288308.csv} (100%) rename python/cugraph/cugraph/testing/results/{319914331540810.csv => traversal-319914331540810.csv} (100%) rename python/cugraph/cugraph/testing/results/{349902694645046.csv => traversal-349902694645046.csv} (100%) rename python/cugraph/cugraph/testing/results/{37447363258930.csv => traversal-37447363258930.csv} (100%) rename python/cugraph/cugraph/testing/results/{381600612247751.csv => traversal-381600612247751.csv} (100%) rename python/cugraph/cugraph/testing/results/{431063157185576.csv => traversal-431063157185576.csv} (100%) rename python/cugraph/cugraph/testing/results/{526650785538532.csv => traversal-526650785538532.csv} (100%) rename python/cugraph/cugraph/testing/results/{551177413608707.csv => traversal-551177413608707.csv} (100%) rename python/cugraph/cugraph/testing/results/{553165838223190.csv => traversal-553165838223190.csv} (100%) rename python/cugraph/cugraph/testing/results/{562676383765605.csv => traversal-562676383765605.csv} (100%) rename python/cugraph/cugraph/testing/results/{633044963923492.csv => traversal-633044963923492.csv} (100%) rename python/cugraph/cugraph/testing/results/{656150055689627.csv => traversal-656150055689627.csv} (100%) rename python/cugraph/cugraph/testing/results/{671563943115481.csv => traversal-671563943115481.csv} (100%) rename python/cugraph/cugraph/testing/results/{688340850412339.csv => traversal-688340850412339.csv} (100%) rename python/cugraph/cugraph/testing/results/{715146362591693.csv => traversal-715146362591693.csv} (100%) rename python/cugraph/cugraph/testing/results/{730687934441562.csv => traversal-730687934441562.csv} (100%) rename python/cugraph/cugraph/testing/results/{743945746483767.csv => traversal-743945746483767.csv} (100%) rename python/cugraph/cugraph/testing/results/{766965872267210.csv => traversal-766965872267210.csv} (100%) rename python/cugraph/cugraph/testing/results/{767470587558788.csv => traversal-767470587558788.csv} (100%) rename python/cugraph/cugraph/testing/results/{767697247244749.csv => traversal-767697247244749.csv} (100%) rename python/cugraph/cugraph/testing/results/{773751608857007.csv => traversal-773751608857007.csv} (100%) rename python/cugraph/cugraph/testing/results/{794754027574210.csv => traversal-794754027574210.csv} (100%) rename python/cugraph/cugraph/testing/results/{811808371982955.csv => traversal-811808371982955.csv} (100%) rename python/cugraph/cugraph/testing/results/{836556098128760.csv => traversal-836556098128760.csv} (100%) rename python/cugraph/cugraph/testing/results/{83873432859770.csv => traversal-83873432859770.csv} (100%) rename python/cugraph/cugraph/testing/results/{907905196596504.csv => traversal-907905196596504.csv} (100%) rename python/cugraph/cugraph/testing/results/{951630488463330.csv => traversal-951630488463330.csv} (100%) rename python/cugraph/cugraph/testing/results/{954435445708700.csv => traversal-954435445708700.csv} (100%) diff --git a/python/cugraph/cugraph/testing/results/1038281390523078.csv b/python/cugraph/cugraph/testing/results/traversal-1038281390523078.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/1038281390523078.csv rename to python/cugraph/cugraph/testing/results/traversal-1038281390523078.csv diff --git a/python/cugraph/cugraph/testing/results/1081121981713141.csv b/python/cugraph/cugraph/testing/results/traversal-1081121981713141.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/1081121981713141.csv rename to python/cugraph/cugraph/testing/results/traversal-1081121981713141.csv diff --git a/python/cugraph/cugraph/testing/results/1120419326843553.csv b/python/cugraph/cugraph/testing/results/traversal-1120419326843553.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/1120419326843553.csv rename to python/cugraph/cugraph/testing/results/traversal-1120419326843553.csv diff --git a/python/cugraph/cugraph/testing/results/1124485822090487.csv b/python/cugraph/cugraph/testing/results/traversal-1124485822090487.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/1124485822090487.csv rename to python/cugraph/cugraph/testing/results/traversal-1124485822090487.csv diff --git a/python/cugraph/cugraph/testing/results/14314120729501.csv b/python/cugraph/cugraph/testing/results/traversal-14314120729501.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/14314120729501.csv rename to python/cugraph/cugraph/testing/results/traversal-14314120729501.csv diff --git a/python/cugraph/cugraph/testing/results/172188670880910.csv b/python/cugraph/cugraph/testing/results/traversal-172188670880910.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/172188670880910.csv rename to python/cugraph/cugraph/testing/results/traversal-172188670880910.csv diff --git a/python/cugraph/cugraph/testing/results/188398733063004.csv b/python/cugraph/cugraph/testing/results/traversal-188398733063004.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/188398733063004.csv rename to python/cugraph/cugraph/testing/results/traversal-188398733063004.csv diff --git a/python/cugraph/cugraph/testing/results/189882724201031.csv b/python/cugraph/cugraph/testing/results/traversal-189882724201031.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/189882724201031.csv rename to python/cugraph/cugraph/testing/results/traversal-189882724201031.csv diff --git a/python/cugraph/cugraph/testing/results/190697381576149.csv b/python/cugraph/cugraph/testing/results/traversal-190697381576149.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/190697381576149.csv rename to python/cugraph/cugraph/testing/results/traversal-190697381576149.csv diff --git a/python/cugraph/cugraph/testing/results/223015853235383.csv b/python/cugraph/cugraph/testing/results/traversal-223015853235383.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/223015853235383.csv rename to python/cugraph/cugraph/testing/results/traversal-223015853235383.csv diff --git a/python/cugraph/cugraph/testing/results/240638103958132.csv b/python/cugraph/cugraph/testing/results/traversal-240638103958132.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/240638103958132.csv rename to python/cugraph/cugraph/testing/results/traversal-240638103958132.csv diff --git a/python/cugraph/cugraph/testing/results/245745928001428.csv b/python/cugraph/cugraph/testing/results/traversal-245745928001428.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/245745928001428.csv rename to python/cugraph/cugraph/testing/results/traversal-245745928001428.csv diff --git a/python/cugraph/cugraph/testing/results/276948497384571.csv b/python/cugraph/cugraph/testing/results/traversal-276948497384571.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/276948497384571.csv rename to python/cugraph/cugraph/testing/results/traversal-276948497384571.csv diff --git a/python/cugraph/cugraph/testing/results/285876289784674.csv b/python/cugraph/cugraph/testing/results/traversal-285876289784674.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/285876289784674.csv rename to python/cugraph/cugraph/testing/results/traversal-285876289784674.csv diff --git a/python/cugraph/cugraph/testing/results/308351777319316.csv b/python/cugraph/cugraph/testing/results/traversal-308351777319316.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/308351777319316.csv rename to python/cugraph/cugraph/testing/results/traversal-308351777319316.csv diff --git a/python/cugraph/cugraph/testing/results/31714534985100.csv b/python/cugraph/cugraph/testing/results/traversal-31714534985100.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/31714534985100.csv rename to python/cugraph/cugraph/testing/results/traversal-31714534985100.csv diff --git a/python/cugraph/cugraph/testing/results/319050385288308.csv b/python/cugraph/cugraph/testing/results/traversal-319050385288308.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/319050385288308.csv rename to python/cugraph/cugraph/testing/results/traversal-319050385288308.csv diff --git a/python/cugraph/cugraph/testing/results/319914331540810.csv b/python/cugraph/cugraph/testing/results/traversal-319914331540810.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/319914331540810.csv rename to python/cugraph/cugraph/testing/results/traversal-319914331540810.csv diff --git a/python/cugraph/cugraph/testing/results/349902694645046.csv b/python/cugraph/cugraph/testing/results/traversal-349902694645046.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/349902694645046.csv rename to python/cugraph/cugraph/testing/results/traversal-349902694645046.csv diff --git a/python/cugraph/cugraph/testing/results/37447363258930.csv b/python/cugraph/cugraph/testing/results/traversal-37447363258930.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/37447363258930.csv rename to python/cugraph/cugraph/testing/results/traversal-37447363258930.csv diff --git a/python/cugraph/cugraph/testing/results/381600612247751.csv b/python/cugraph/cugraph/testing/results/traversal-381600612247751.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/381600612247751.csv rename to python/cugraph/cugraph/testing/results/traversal-381600612247751.csv diff --git a/python/cugraph/cugraph/testing/results/431063157185576.csv b/python/cugraph/cugraph/testing/results/traversal-431063157185576.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/431063157185576.csv rename to python/cugraph/cugraph/testing/results/traversal-431063157185576.csv diff --git a/python/cugraph/cugraph/testing/results/526650785538532.csv b/python/cugraph/cugraph/testing/results/traversal-526650785538532.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/526650785538532.csv rename to python/cugraph/cugraph/testing/results/traversal-526650785538532.csv diff --git a/python/cugraph/cugraph/testing/results/551177413608707.csv b/python/cugraph/cugraph/testing/results/traversal-551177413608707.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/551177413608707.csv rename to python/cugraph/cugraph/testing/results/traversal-551177413608707.csv diff --git a/python/cugraph/cugraph/testing/results/553165838223190.csv b/python/cugraph/cugraph/testing/results/traversal-553165838223190.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/553165838223190.csv rename to python/cugraph/cugraph/testing/results/traversal-553165838223190.csv diff --git a/python/cugraph/cugraph/testing/results/562676383765605.csv b/python/cugraph/cugraph/testing/results/traversal-562676383765605.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/562676383765605.csv rename to python/cugraph/cugraph/testing/results/traversal-562676383765605.csv diff --git a/python/cugraph/cugraph/testing/results/633044963923492.csv b/python/cugraph/cugraph/testing/results/traversal-633044963923492.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/633044963923492.csv rename to python/cugraph/cugraph/testing/results/traversal-633044963923492.csv diff --git a/python/cugraph/cugraph/testing/results/656150055689627.csv b/python/cugraph/cugraph/testing/results/traversal-656150055689627.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/656150055689627.csv rename to python/cugraph/cugraph/testing/results/traversal-656150055689627.csv diff --git a/python/cugraph/cugraph/testing/results/671563943115481.csv b/python/cugraph/cugraph/testing/results/traversal-671563943115481.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/671563943115481.csv rename to python/cugraph/cugraph/testing/results/traversal-671563943115481.csv diff --git a/python/cugraph/cugraph/testing/results/688340850412339.csv b/python/cugraph/cugraph/testing/results/traversal-688340850412339.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/688340850412339.csv rename to python/cugraph/cugraph/testing/results/traversal-688340850412339.csv diff --git a/python/cugraph/cugraph/testing/results/715146362591693.csv b/python/cugraph/cugraph/testing/results/traversal-715146362591693.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/715146362591693.csv rename to python/cugraph/cugraph/testing/results/traversal-715146362591693.csv diff --git a/python/cugraph/cugraph/testing/results/730687934441562.csv b/python/cugraph/cugraph/testing/results/traversal-730687934441562.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/730687934441562.csv rename to python/cugraph/cugraph/testing/results/traversal-730687934441562.csv diff --git a/python/cugraph/cugraph/testing/results/743945746483767.csv b/python/cugraph/cugraph/testing/results/traversal-743945746483767.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/743945746483767.csv rename to python/cugraph/cugraph/testing/results/traversal-743945746483767.csv diff --git a/python/cugraph/cugraph/testing/results/766965872267210.csv b/python/cugraph/cugraph/testing/results/traversal-766965872267210.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/766965872267210.csv rename to python/cugraph/cugraph/testing/results/traversal-766965872267210.csv diff --git a/python/cugraph/cugraph/testing/results/767470587558788.csv b/python/cugraph/cugraph/testing/results/traversal-767470587558788.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/767470587558788.csv rename to python/cugraph/cugraph/testing/results/traversal-767470587558788.csv diff --git a/python/cugraph/cugraph/testing/results/767697247244749.csv b/python/cugraph/cugraph/testing/results/traversal-767697247244749.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/767697247244749.csv rename to python/cugraph/cugraph/testing/results/traversal-767697247244749.csv diff --git a/python/cugraph/cugraph/testing/results/773751608857007.csv b/python/cugraph/cugraph/testing/results/traversal-773751608857007.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/773751608857007.csv rename to python/cugraph/cugraph/testing/results/traversal-773751608857007.csv diff --git a/python/cugraph/cugraph/testing/results/794754027574210.csv b/python/cugraph/cugraph/testing/results/traversal-794754027574210.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/794754027574210.csv rename to python/cugraph/cugraph/testing/results/traversal-794754027574210.csv diff --git a/python/cugraph/cugraph/testing/results/811808371982955.csv b/python/cugraph/cugraph/testing/results/traversal-811808371982955.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/811808371982955.csv rename to python/cugraph/cugraph/testing/results/traversal-811808371982955.csv diff --git a/python/cugraph/cugraph/testing/results/836556098128760.csv b/python/cugraph/cugraph/testing/results/traversal-836556098128760.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/836556098128760.csv rename to python/cugraph/cugraph/testing/results/traversal-836556098128760.csv diff --git a/python/cugraph/cugraph/testing/results/83873432859770.csv b/python/cugraph/cugraph/testing/results/traversal-83873432859770.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/83873432859770.csv rename to python/cugraph/cugraph/testing/results/traversal-83873432859770.csv diff --git a/python/cugraph/cugraph/testing/results/907905196596504.csv b/python/cugraph/cugraph/testing/results/traversal-907905196596504.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/907905196596504.csv rename to python/cugraph/cugraph/testing/results/traversal-907905196596504.csv diff --git a/python/cugraph/cugraph/testing/results/951630488463330.csv b/python/cugraph/cugraph/testing/results/traversal-951630488463330.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/951630488463330.csv rename to python/cugraph/cugraph/testing/results/traversal-951630488463330.csv diff --git a/python/cugraph/cugraph/testing/results/954435445708700.csv b/python/cugraph/cugraph/testing/results/traversal-954435445708700.csv similarity index 100% rename from python/cugraph/cugraph/testing/results/954435445708700.csv rename to python/cugraph/cugraph/testing/results/traversal-954435445708700.csv diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index e5f3ac607d5..49e20e6f57f 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -15,11 +15,10 @@ import random from pathlib import Path -# import cupy as cp import numpy as np +import networkx as nx import cudf -import networkx as nx import cugraph from cugraph.experimental.datasets import ( dolphins, @@ -58,9 +57,9 @@ def get_resultset(category, **kwargs): single_mapping[2 * i] = argvals[i] for i in np.arange(mapping_length): mappings = mappings[mappings[query_cols[i]] == single_mapping[i]] - # results_filename = category + "-" + mappings.head(1)["UUID"].values_host[0] # values_host is used instead of values bc strings aren't saved/possible on device - results_filename = mappings.head(1)["UUID"].values_host[0] + results_filename = category + "-" + mappings.head(1)["UUID"].values_host[0] + # results_filename = mappings.head(1)["UUID"].values_host[0] results_filename = results_filename + ".csv" # Ignore for now -> Assumption is the filename already has the alg category path = results_dir / results_filename @@ -341,7 +340,7 @@ def generate_results(): traversal_mappings = cudf.concat( [traversal_mappings, temp_mapping], axis=0, ignore_index=True ) - res.to_csv(results_dir / (temp_filename + ".csv"), index=False) + res.to_csv(results_dir / ("traversal-" + temp_filename + ".csv"), index=False) traversal_mappings.to_csv( results_dir / "traversal_mappings.csv", index=False, sep=" " ) diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs.py b/python/cugraph/cugraph/tests/traversal/test_bfs.py index 73ddae24e89..c10ee473a4e 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs.py @@ -13,14 +13,9 @@ import gc -# import random - import pytest import cupy as cp import numpy as np -import pandas as pd -import networkx as nx -import networkx.algorithms.centrality.betweenness as nxacb from scipy.sparse import coo_matrix as sp_coo_matrix from scipy.sparse import csr_matrix as sp_csr_matrix from scipy.sparse import csc_matrix as sp_csc_matrix diff --git a/python/cugraph/cugraph/tests/traversal/test_paths.py b/python/cugraph/cugraph/tests/traversal/test_paths.py index ab2406d264a..a04fa9b0b0d 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths.py @@ -16,13 +16,12 @@ import math import numpy as np - -from cugraph.testing import get_resultset import pytest import cudf import cupy import cugraph +from cugraph.testing import get_resultset from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix From fc90fef60f750d2bb4fca361d222a6095a3f4e69 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Tue, 1 Aug 2023 19:50:35 +0000 Subject: [PATCH 10/20] Edits to generating results and utils.py --- python/cugraph/cugraph/testing/resultset.py | 2 +- python/cugraph/cugraph/testing/utils.py | 73 --------------------- 2 files changed, 1 insertion(+), 74 deletions(-) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 49e20e6f57f..059a63fb7df 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -346,4 +346,4 @@ def generate_results(): ) -generate_results() +# generate_results() diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index 5a7443cf3f1..c7f7ddd4fdd 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -416,84 +416,11 @@ def compare_mst(mst_cugraph, mst_nx): assert np.isclose(cg_sum, nx_sum) -"""def convert_nx_view_to_dict(Gnx): - Gnx_dict = {} - for u in Gnx.nodes: - Gnx_dict[u] = {} - for v in Gnx[u]: - Gnx_dict[u][v] = Gnx[u][v] - return Gnx_dict""" - default_results_download_dir = ( Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" ) -""" -class ResultSet: - # A Resultset Object, which imports output data from networkX algs or cuGraph algs - # with networkX inputs. This is to be used in the testing module, as to fully remove - # nx as a dependency. - # Parameters - # ---------- - # local_file_name : str - # The string path for the pickled results file, stored locally somewhere. - # cloud_file_name : str - # The string path for the pickled results file, stored on the cloud. (s3) - # unsure about naming of 'cloud_result_file' - def __init__(self, local_result_file=None, cloud_result_file=None): - self._path = None - - # self._result_file = None - if cloud_result_file is not None and local_result_file is not None: - raise ValueError( - "only one of cloud_result_file or local_result_file can be specified" - ) - elif cloud_result_file is not None: - raise NotImplementedError("results files are not yet on cloud bucket") - # self._path=Path("https://data.rapids.ai/cugraph/tsting/"+cloud_result_file) - # not right syntax but the overall process would be similar to below: vv - elif local_result_file is not None: - # self._path = default_results_download_dir / local_result_file - # breakpoint() - self._path = Path("testing") / local_result_file - if self._path.exists() is False: - # try to load results, if file doesn't exist raise pref. RuntimeError - raise FileNotFoundError(local_result_file) - else: - # with open( - # default_results_download_dir / local_result_file, "rb" - # ) as file: - # with open("testing/" + local_result_file, "rb") as file: - with open(self._path, "rb") as file: - self.results = pickle.load(file) - else: - raise ValueError( - "must specify either local_result_file or cloud_result_file" - ) -""" - - -""" -class ResultSet: - # A Resultset Object which imports output data from networkX algs or cuGraph algs - # with networkX inputs. This will eventually remove nx as a dependency. - def __init__(self, lib=None, alg=None, graph=None, params=None): - self._path = None - - if lib is not None: - self._path = Path(Path("testing/nxresults") / lib / alg / graph / params) - .with_suffix(".csv") - if self._path.exists() is False: - raise FileNotFoundError(self._path) - else: - self.results = cudf.read_csv(self._path) - - else: - raise ValueError("must specify result_file") -""" - - class ResultSet: def __init__(self, data_dictionary): self._data_dictionary = data_dictionary From 2159ba2887514e845ebbcf140fd0d37ec1b72f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDylan?= <“dylanc@nvidia.com”> Date: Tue, 1 Aug 2023 21:32:54 +0000 Subject: [PATCH 11/20] Minor comment edit --- python/cugraph/cugraph/testing/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index c7f7ddd4fdd..5fc5c81ab6a 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -426,5 +426,5 @@ def __init__(self, data_dictionary): self._data_dictionary = data_dictionary def get_cudf_dataframe(self): - # THIS IS CALLED IN RESULTS GENERATION BEFORE WRITING ALL RESULTS TO FILES + # This is called in testing/resultset.py before writing all results to files return cudf.DataFrame(self._data_dictionary) From 7a002fc1949c8db16482eb990c121a205a54f564 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Tue, 1 Aug 2023 21:40:13 +0000 Subject: [PATCH 12/20] comment fix, try to verify commit via sig --- python/cugraph/cugraph/testing/resultset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 059a63fb7df..7ac0cd39f05 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -138,7 +138,7 @@ def get_resultset(category, **kwargs): for source in SOURCES: Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) - # stest_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths + # test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths vertices = cudf.Series(nx_paths.keys()) distances = cudf.Series(nx_paths.values()) add_resultset( From 6f71cb188bbf798ae3a7203953e14a11e8bf248d Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Tue, 1 Aug 2023 21:43:30 +0000 Subject: [PATCH 13/20] Attempt to sign commits --- python/cugraph/cugraph/testing/resultset.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 7ac0cd39f05..0a5f188e624 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -231,7 +231,6 @@ def get_resultset(category, **kwargs): "disconnected": [("1", "10"), ("1", "8")], } -# CONNECTED_GRAPH with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: graph_tf.writelines(DISCONNECTED_GRAPH) graph_tf.seek(0) From 54258e9a498e5a3d1436ad18d4ef395444d7432d Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Tue, 8 Aug 2023 22:58:25 +0000 Subject: [PATCH 14/20] Reuse datasets path env to load resultsets near datasets, testing improvements --- python/cugraph/cugraph/testing/__init__.py | 3 +- .../cugraph/testing/generate_resultsets.py | 325 ++++++++++++++ .../results/traversal-1038281390523078.csv | 3 - .../results/traversal-1081121981713141.csv | 6 - .../results/traversal-1120419326843553.csv | 35 -- .../results/traversal-1124485822090487.csv | 63 --- .../results/traversal-14314120729501.csv | 3 - .../results/traversal-172188670880910.csv | 63 --- .../results/traversal-188398733063004.csv | 8 - .../results/traversal-189882724201031.csv | 35 -- .../results/traversal-190697381576149.csv | 60 --- .../results/traversal-223015853235383.csv | 8 - .../results/traversal-240638103958132.csv | 35 -- .../results/traversal-245745928001428.csv | 8 - .../results/traversal-276948497384571.csv | 35 -- .../results/traversal-285876289784674.csv | 35 -- .../results/traversal-308351777319316.csv | 4 - .../results/traversal-31714534985100.csv | 3 - .../results/traversal-319050385288308.csv | 3 - .../results/traversal-319914331540810.csv | 35 -- .../results/traversal-349902694645046.csv | 35 -- .../results/traversal-37447363258930.csv | 35 -- .../results/traversal-381600612247751.csv | 35 -- .../results/traversal-431063157185576.csv | 63 --- .../results/traversal-526650785538532.csv | 3 - .../results/traversal-551177413608707.csv | 106 ----- .../results/traversal-553165838223190.csv | 35 -- .../results/traversal-562676383765605.csv | 35 -- .../results/traversal-633044963923492.csv | 35 -- .../results/traversal-656150055689627.csv | 63 --- .../results/traversal-671563943115481.csv | 63 --- .../results/traversal-688340850412339.csv | 35 -- .../results/traversal-715146362591693.csv | 3 - .../results/traversal-730687934441562.csv | 35 -- .../results/traversal-743945746483767.csv | 35 -- .../results/traversal-766965872267210.csv | 35 -- .../results/traversal-767470587558788.csv | 60 --- .../results/traversal-767697247244749.csv | 5 - .../results/traversal-773751608857007.csv | 35 -- .../results/traversal-794754027574210.csv | 63 --- .../results/traversal-811808371982955.csv | 3 - .../results/traversal-836556098128760.csv | 35 -- .../results/traversal-83873432859770.csv | 6 - .../results/traversal-907905196596504.csv | 3 - .../results/traversal-951630488463330.csv | 5 - .../results/traversal-954435445708700.csv | 106 ----- .../testing/results/traversal_mappings.csv | 45 -- python/cugraph/cugraph/testing/resultset.py | 413 ++++-------------- python/cugraph/cugraph/testing/utils.py | 14 - .../cugraph/tests/traversal/test_bfs.py | 89 ++-- .../cugraph/tests/traversal/test_paths.py | 60 +-- .../cugraph/tests/traversal/test_sssp.py | 39 +- 52 files changed, 533 insertions(+), 1869 deletions(-) create mode 100644 python/cugraph/cugraph/testing/generate_resultsets.py delete mode 100644 python/cugraph/cugraph/testing/results/traversal-1038281390523078.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-1081121981713141.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-1120419326843553.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-1124485822090487.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-14314120729501.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-172188670880910.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-188398733063004.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-189882724201031.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-190697381576149.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-223015853235383.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-240638103958132.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-245745928001428.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-276948497384571.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-285876289784674.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-308351777319316.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-31714534985100.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-319050385288308.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-319914331540810.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-349902694645046.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-37447363258930.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-381600612247751.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-431063157185576.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-526650785538532.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-551177413608707.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-553165838223190.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-562676383765605.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-633044963923492.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-656150055689627.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-671563943115481.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-688340850412339.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-715146362591693.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-730687934441562.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-743945746483767.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-766965872267210.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-767470587558788.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-767697247244749.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-773751608857007.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-794754027574210.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-811808371982955.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-836556098128760.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-83873432859770.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-907905196596504.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-951630488463330.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal-954435445708700.csv delete mode 100644 python/cugraph/cugraph/testing/results/traversal_mappings.csv diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index cf22c0093a4..bd9314608b1 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -11,8 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cugraph.testing.resultset import get_resultset +# from cugraph.testing.resultset import get_resultset, get_resultset2 from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH, RAPIDS_DATASET_ROOT_DIR +from cugraph.testing.resultset import load_resultset, get_resultset from cugraph.datasets import ( cyber, dolphins, diff --git a/python/cugraph/cugraph/testing/generate_resultsets.py b/python/cugraph/cugraph/testing/generate_resultsets.py new file mode 100644 index 00000000000..d3ad2625792 --- /dev/null +++ b/python/cugraph/cugraph/testing/generate_resultsets.py @@ -0,0 +1,325 @@ +# Copyright (c) 2023, NVIDIA CORPORATION. +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from tempfile import NamedTemporaryFile +import random + +import numpy as np +import networkx as nx + +import cudf +import cugraph +from cugraph.experimental.datasets import ( + dolphins, + netscience, + karate_disjoint, + karate, + polbooks, +) +from cugraph.testing import utils + + +_results_dir = utils.RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" +_resultsets = {} + + +def add_resultset(result_data_dictionary, **kwargs): + rs = utils.Resultset(result_data_dictionary) + hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) + _resultsets[hashable_dict_repr] = rs + + +# ============================================================================= +# Parameters +# ============================================================================= +# This will be refactored once the datasets variables are fixed/changed +SEEDS = [42] + +DIRECTED_GRAPH_OPTIONS = [True, False] + +DEPTH_LIMITS = [None, 1, 5, 18] + +DATASETS = [dolphins, netscience, karate_disjoint] + +DATASETS_SMALL = [karate, dolphins, polbooks] + +# ============================================================================= +# tests/traversal/test_bfs.py +# ============================================================================= +test_bfs_results = {} + +for ds in DATASETS + [karate]: + for seed in SEEDS: + for depth_limit in DEPTH_LIMITS: + for dirctd in DIRECTED_GRAPH_OPTIONS: + # this does the work of get_cu_graph_nx_results_and_params + Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=dirctd) + random.seed(seed) + start_vertex = random.sample(list(Gnx.nodes()), 1)[0] + nx_values = nx.single_source_shortest_path_length( + Gnx, start_vertex, cutoff=depth_limit + ) + """test_bfs_results[ + "{},{},{},{},{}".format(seed, depth_limit, ds, dirctd, start_vertex) + ] = nx_values""" + vertices = cudf.Series(nx_values.keys()) + distances = cudf.Series(nx_values.values()) + add_resultset( + {"vertex": vertices, "distance": distances}, + graph_dataset=ds.metadata["name"], + graph_directed=str(dirctd), + algo="single_source_shortest_path_length", + start_vertex=str(start_vertex), + cutoff=str(depth_limit), + ) + # test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex + +# these are pandas dataframes +for dirctd in DIRECTED_GRAPH_OPTIONS: + Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) + result = cugraph.bfs_edges(Gnx, source=7) + cugraph_df = cudf.from_pandas(result) + # test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df + add_resultset( + cugraph_df, + graph_dataset="karate", + graph_directed=str(dirctd), + algo="bfs_edges", + source="7", + ) + + +# ============================================================================= +# tests/traversal/test_sssp.py +# ============================================================================= +test_sssp_results = {} + +SOURCES = [1] + +for ds in DATASETS_SMALL: + for source in SOURCES: + Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) + nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) + # test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths + vertices = cudf.Series(nx_paths.keys()) + distances = cudf.Series(nx_paths.values()) + add_resultset( + {"vertex": vertices, "distance": distances}, + graph_dataset=ds.metadata["name"], + graph_directed="True", + algo="single_source_dijkstra_path_length", + source=str(source), + ) + + M = utils.read_csv_for_nx(ds.get_path(), read_weights_in_sp=True) + edge_attr = "weight" + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr=edge_attr, + create_using=nx.DiGraph(), + ) + + M["weight"] = M["weight"].astype(np.int32) + Gnx = nx.from_pandas_edgelist( + M, + source="0", + target="1", + edge_attr="weight", + create_using=nx.DiGraph(), + ) + nx_paths_datatypeconv = nx.single_source_dijkstra_path_length(Gnx, source) + """test_sssp_results[ + "nx_paths,data_type_conversion,{}".format(ds) + ] = nx_paths_datatypeconv""" + vertices_datatypeconv = cudf.Series(nx_paths_datatypeconv.keys()) + distances_datatypeconv = cudf.Series(nx_paths_datatypeconv.values()) + add_resultset( + {"vertex": vertices_datatypeconv, "distance": distances_datatypeconv}, + graph_dataset=ds.metadata["name"], + graph_directed="True", + algo="single_source_dijkstra_path_length", + test="data_type_conversion", + source=str(source), + ) + +for dirctd in DIRECTED_GRAPH_OPTIONS: + for source in SOURCES: + Gnx = utils.generate_nx_graph_from_file( + karate.get_path(), directed=dirctd, edgevals=True + ) + """if dirctd: + test_sssp_results[ + "nonnative_input,nx.DiGraph,{}".format(source) + ] = cugraph.sssp(Gnx, source) + else: + test_sssp_results[ + "nonnative_input,nx.Graph,{}".format(source) + ] = cugraph.sssp(Gnx, source)""" + add_resultset( + cugraph.sssp(Gnx, source), + graph_dataset="karate", + graph_directed=str(dirctd), + algo="sssp_nonnative", + source=str(source), + ) + +G = nx.Graph() +G.add_edge(0, 1, other=10) +G.add_edge(1, 2, other=20) +df = cugraph.sssp(G, 0, edge_attr="other") +# test_sssp_results["network_edge_attr"] = df +add_resultset(df, algo="sssp_nonnative", test="network_edge_attr") + +# ============================================================================= +# tests/traversal/test_paths.py +# ============================================================================= +CONNECTED_GRAPH = """1,5,3 +1,4,1 +1,2,1 +1,6,2 +1,7,2 +4,5,1 +2,3,1 +7,6,2 +""" + +DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" + +paths = [("1", "1"), ("1", "5"), ("1", "3"), ("1", "6")] +invalid_paths = { + "connected": [("-1", "1"), ("0", "42")], + "disconnected": [("1", "10"), ("1", "8")], +} + +with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: + graph_tf.writelines(DISCONNECTED_GRAPH) + graph_tf.seek(0) + Gnx_DIS = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") + +res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") +vertices = cudf.Series(res1.keys()) +distances = cudf.Series(res1.values()) +add_resultset( + {"vertex": vertices, "distance": distances}, + algo="shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed="True", + source="1", + weight="weight", +) + + +# Generating ALL results files +"""random.seed(24) +for temp in _resultsets: + res = _resultsets[temp].get_cudf_dataframe() + # Currently, only traversal results files are generated + temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" + temp_mapping = cudf.DataFrame( + [[str(temp), temp_filename]], columns=["hashable_dict_repr", "filename"] + ) + traversal_mappings = cudf.concat( + [traversal_mappings, temp_mapping], axis=0, ignore_index=True + ) + # print(temp_filename) + # print("traversal_" + temp_filename) + res.to_csv(results_dir / temp_filename, index=False) +traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False)""" + + +def generate_results(): + # FIXME: Currently, only traversal results files are generated + random.seed(24) + traversal_mappings = cudf.DataFrame( + columns=[ + "#UUID", + "arg0", + "arg0val", + "arg1", + "arg1val", + "arg2", + "arg2val", + "arg3", + "arg3val", + "arg4", + "arg4val", + "arg5", + "arg5val", + "arg6", + "arg6val", + "arg7", + "arg7val", + "arg8", + "arg8val", + "arg9", + "arg9val", + ] + ) + # Generating ALL results files + for temp in _resultsets: + res = _resultsets[temp].get_cudf_dataframe() + # temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" + temp_filename = str(random.getrandbits(50)) + temp_dict = dict(temp) + argnames, argvals = [t for t in temp_dict.keys()], [ + t for t in temp_dict.values() + ] + single_mapping = np.empty(21, dtype=object) + dict_length = len(argnames) + + single_mapping[0] = temp_filename + # single_mapping[1] = argvals[0] + # for i in np.arange(1, dict_length): + for i in np.arange(dict_length): + # single_mapping[2 * i] = argnames[i] + # single_mapping[2 * i + 1] = argvals[i] + single_mapping[2 * i + 1] = argnames[i] + single_mapping[2 * i + 2] = argvals[i] + temp_mapping = cudf.DataFrame( + [single_mapping], + columns=[ + "#UUID", + "arg0", + "arg0val", + "arg1", + "arg1val", + "arg2", + "arg2val", + "arg3", + "arg3val", + "arg4", + "arg4val", + "arg5", + "arg5val", + "arg6", + "arg6val", + "arg7", + "arg7val", + "arg8", + "arg8val", + "arg9", + "arg9val", + ], + ) + traversal_mappings = cudf.concat( + [traversal_mappings, temp_mapping], axis=0, ignore_index=True + ) + res.to_csv(_results_dir / (temp_filename + ".csv"), index=False) + traversal_mappings.to_csv( + _results_dir / "traversal_mappings.csv", index=False, sep=" " + ) + + +# generate_results() diff --git a/python/cugraph/cugraph/testing/results/traversal-1038281390523078.csv b/python/cugraph/cugraph/testing/results/traversal-1038281390523078.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-1038281390523078.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-1081121981713141.csv b/python/cugraph/cugraph/testing/results/traversal-1081121981713141.csv deleted file mode 100644 index dd3b38a55c6..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-1081121981713141.csv +++ /dev/null @@ -1,6 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-1120419326843553.csv b/python/cugraph/cugraph/testing/results/traversal-1120419326843553.csv deleted file mode 100644 index 6ac28e23f8c..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-1120419326843553.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 -2,2 -3,2 -4,2 -5,2 -6,2 -7,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -21,2 -31,2 -30,2 -9,2 -14,2 -15,2 -18,2 -20,2 -22,2 -23,2 -26,2 -27,2 -28,2 -29,2 -32,2 -16,3 -24,3 -25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-1124485822090487.csv b/python/cugraph/cugraph/testing/results/traversal-1124485822090487.csv deleted file mode 100644 index 84194972ecf..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-1124485822090487.csv +++ /dev/null @@ -1,63 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 -0,2 -3,2 -24,2 -34,2 -40,2 -43,2 -52,2 -8,2 -18,2 -28,2 -36,2 -44,2 -47,2 -12,2 -21,2 -45,2 -61,2 -58,2 -42,2 -51,2 -10,3 -15,3 -59,3 -29,3 -49,3 -7,3 -46,3 -53,3 -1,3 -30,3 -23,3 -39,3 -2,3 -4,3 -11,3 -55,3 -35,4 -19,4 -27,4 -54,4 -17,4 -26,4 -41,4 -57,4 -25,5 -6,5 -13,5 -9,5 -22,5 -31,5 -5,5 -48,5 -56,6 -32,6 -60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-14314120729501.csv b/python/cugraph/cugraph/testing/results/traversal-14314120729501.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-14314120729501.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-172188670880910.csv b/python/cugraph/cugraph/testing/results/traversal-172188670880910.csv deleted file mode 100644 index 227b61d8259..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-172188670880910.csv +++ /dev/null @@ -1,63 +0,0 @@ -vertex,distance -1,0 -17,1 -19,1 -26,1 -27,1 -28,1 -36,1 -41,1 -54,1 -6,2 -9,2 -13,2 -22,2 -25,2 -31,2 -57,2 -7,2 -30,2 -8,2 -20,2 -47,2 -23,2 -37,2 -39,2 -40,2 -59,2 -56,3 -5,3 -32,3 -48,3 -42,3 -3,3 -45,3 -16,3 -18,3 -38,3 -44,3 -50,3 -0,3 -10,3 -51,3 -14,3 -21,3 -33,3 -34,3 -43,3 -61,3 -15,3 -52,3 -60,4 -2,4 -24,4 -29,4 -58,4 -4,4 -11,4 -55,4 -12,4 -49,4 -46,4 -53,4 -35,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-188398733063004.csv b/python/cugraph/cugraph/testing/results/traversal-188398733063004.csv deleted file mode 100644 index 3a273143f56..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-188398733063004.csv +++ /dev/null @@ -1,8 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-189882724201031.csv b/python/cugraph/cugraph/testing/results/traversal-189882724201031.csv deleted file mode 100644 index 6ac28e23f8c..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-189882724201031.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 -2,2 -3,2 -4,2 -5,2 -6,2 -7,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -21,2 -31,2 -30,2 -9,2 -14,2 -15,2 -18,2 -20,2 -22,2 -23,2 -26,2 -27,2 -28,2 -29,2 -32,2 -16,3 -24,3 -25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-190697381576149.csv b/python/cugraph/cugraph/testing/results/traversal-190697381576149.csv deleted file mode 100644 index 384b1e3707b..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-190697381576149.csv +++ /dev/null @@ -1,60 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 -0,2 -3,2 -24,2 -34,2 -40,2 -43,2 -52,2 -8,2 -18,2 -28,2 -36,2 -44,2 -47,2 -12,2 -21,2 -45,2 -61,2 -58,2 -42,2 -51,2 -10,3 -15,3 -59,3 -29,3 -49,3 -7,3 -46,3 -53,3 -1,3 -30,3 -23,3 -39,3 -2,3 -4,3 -11,3 -55,3 -35,4 -19,4 -27,4 -54,4 -17,4 -26,4 -41,4 -57,4 -25,5 -6,5 -13,5 -9,5 -22,5 -31,5 -5,5 -48,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-223015853235383.csv b/python/cugraph/cugraph/testing/results/traversal-223015853235383.csv deleted file mode 100644 index 7ae0b62a55c..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-223015853235383.csv +++ /dev/null @@ -1,8 +0,0 @@ -vertex,distance -1,0.0 -4,1.0 -2,1.0 -6,2.0 -7,2.0 -5,2.0 -3,2.0 diff --git a/python/cugraph/cugraph/testing/results/traversal-240638103958132.csv b/python/cugraph/cugraph/testing/results/traversal-240638103958132.csv deleted file mode 100644 index 828e48615f0..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-240638103958132.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -19,2 -21,2 -31,2 -30,2 -9,2 -27,2 -28,2 -32,2 -16,3 -33,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-245745928001428.csv b/python/cugraph/cugraph/testing/results/traversal-245745928001428.csv deleted file mode 100644 index 3a273143f56..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-245745928001428.csv +++ /dev/null @@ -1,8 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-276948497384571.csv b/python/cugraph/cugraph/testing/results/traversal-276948497384571.csv deleted file mode 100644 index dda4c0b31ba..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-276948497384571.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -1,0 -0,1 -2,1 -3,1 -7,1 -13,1 -17,1 -19,1 -21,1 -30,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -31,2 -9,2 -27,2 -28,2 -32,2 -33,2 -16,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-285876289784674.csv b/python/cugraph/cugraph/testing/results/traversal-285876289784674.csv deleted file mode 100644 index 6ac28e23f8c..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-285876289784674.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 -2,2 -3,2 -4,2 -5,2 -6,2 -7,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -21,2 -31,2 -30,2 -9,2 -14,2 -15,2 -18,2 -20,2 -22,2 -23,2 -26,2 -27,2 -28,2 -29,2 -32,2 -16,3 -24,3 -25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-308351777319316.csv b/python/cugraph/cugraph/testing/results/traversal-308351777319316.csv deleted file mode 100644 index 4ce6a683be2..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-308351777319316.csv +++ /dev/null @@ -1,4 +0,0 @@ -distance,vertex,predecessor -10.0,1,0 -0.0,0,-1 -30.0,2,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-31714534985100.csv b/python/cugraph/cugraph/testing/results/traversal-31714534985100.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-31714534985100.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-319050385288308.csv b/python/cugraph/cugraph/testing/results/traversal-319050385288308.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-319050385288308.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-319914331540810.csv b/python/cugraph/cugraph/testing/results/traversal-319914331540810.csv deleted file mode 100644 index 5b2270cb9ed..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-319914331540810.csv +++ /dev/null @@ -1,35 +0,0 @@ -distance,vertex,predecessor -2.0,33,13 -1.0,0,1 -2.0,32,2 -1.0,2,1 -0.0,1,-1 -1.0,3,1 -2.0,31,0 -2.0,8,0 -1.0,13,1 -3.0,23,33 -2.0,5,0 -2.0,6,0 -1.0,7,1 -2.0,27,2 -3.0,29,33 -1.0,30,1 -2.0,4,0 -2.0,10,0 -1.0,19,1 -3.0,24,31 -3.0,25,31 -2.0,28,2 -2.0,9,2 -2.0,12,0 -3.0,14,33 -3.0,15,33 -3.0,16,5 -1.0,17,1 -3.0,18,33 -3.0,20,33 -1.0,21,1 -3.0,22,33 -3.0,26,33 -2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-349902694645046.csv b/python/cugraph/cugraph/testing/results/traversal-349902694645046.csv deleted file mode 100644 index dda4c0b31ba..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-349902694645046.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -1,0 -0,1 -2,1 -3,1 -7,1 -13,1 -17,1 -19,1 -21,1 -30,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -31,2 -9,2 -27,2 -28,2 -32,2 -33,2 -16,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-37447363258930.csv b/python/cugraph/cugraph/testing/results/traversal-37447363258930.csv deleted file mode 100644 index 828e48615f0..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-37447363258930.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -19,2 -21,2 -31,2 -30,2 -9,2 -27,2 -28,2 -32,2 -16,3 -33,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-381600612247751.csv b/python/cugraph/cugraph/testing/results/traversal-381600612247751.csv deleted file mode 100644 index d7178211365..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-381600612247751.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance,predecessor -33,3,32 -0,1,7 -32,2,2 -2,1,7 -1,1,7 -3,1,7 -31,2,0 -8,2,0 -13,2,0 -23,3,32 -5,2,0 -6,2,0 -7,0,-1 -27,2,2 -29,3,32 -30,2,1 -4,2,0 -10,2,0 -19,2,0 -24,3,31 -25,3,31 -28,2,2 -9,2,2 -12,2,0 -14,3,32 -15,3,32 -16,3,5 -17,2,0 -18,3,32 -20,3,32 -21,2,0 -22,3,32 -26,4,33 -11,2,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-431063157185576.csv b/python/cugraph/cugraph/testing/results/traversal-431063157185576.csv deleted file mode 100644 index 84194972ecf..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-431063157185576.csv +++ /dev/null @@ -1,63 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 -0,2 -3,2 -24,2 -34,2 -40,2 -43,2 -52,2 -8,2 -18,2 -28,2 -36,2 -44,2 -47,2 -12,2 -21,2 -45,2 -61,2 -58,2 -42,2 -51,2 -10,3 -15,3 -59,3 -29,3 -49,3 -7,3 -46,3 -53,3 -1,3 -30,3 -23,3 -39,3 -2,3 -4,3 -11,3 -55,3 -35,4 -19,4 -27,4 -54,4 -17,4 -26,4 -41,4 -57,4 -25,5 -6,5 -13,5 -9,5 -22,5 -31,5 -5,5 -48,5 -56,6 -32,6 -60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-526650785538532.csv b/python/cugraph/cugraph/testing/results/traversal-526650785538532.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-526650785538532.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-551177413608707.csv b/python/cugraph/cugraph/testing/results/traversal-551177413608707.csv deleted file mode 100644 index 2bf79ebfc3e..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-551177413608707.csv +++ /dev/null @@ -1,106 +0,0 @@ -vertex,distance -1,0 -0,1 -3,1 -5,1 -6,1 -2,2 -4,2 -8,2 -9,2 -10,2 -11,2 -12,2 -13,2 -14,2 -15,2 -16,2 -17,2 -18,2 -19,2 -20,2 -21,2 -22,2 -23,2 -24,2 -25,2 -26,2 -27,2 -7,2 -29,2 -28,3 -30,3 -31,3 -32,3 -33,3 -35,3 -37,3 -40,3 -41,3 -42,3 -43,3 -44,3 -45,3 -46,3 -47,3 -48,3 -49,3 -50,3 -51,3 -52,3 -38,3 -39,3 -55,3 -56,3 -36,3 -54,3 -57,3 -58,3 -77,3 -53,3 -71,3 -85,3 -66,4 -72,4 -67,4 -70,4 -73,4 -74,4 -75,4 -76,4 -79,4 -80,4 -82,4 -83,4 -84,4 -86,4 -93,4 -99,4 -78,4 -91,4 -34,4 -102,4 -64,4 -65,4 -69,4 -68,4 -81,4 -88,5 -89,5 -90,5 -96,5 -97,5 -100,5 -87,5 -92,5 -103,5 -104,5 -94,5 -95,5 -98,5 -60,5 -62,5 -101,5 -61,5 -59,5 -63,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-553165838223190.csv b/python/cugraph/cugraph/testing/results/traversal-553165838223190.csv deleted file mode 100644 index 6ac28e23f8c..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-553165838223190.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 -2,2 -3,2 -4,2 -5,2 -6,2 -7,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -21,2 -31,2 -30,2 -9,2 -14,2 -15,2 -18,2 -20,2 -22,2 -23,2 -26,2 -27,2 -28,2 -29,2 -32,2 -16,3 -24,3 -25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-562676383765605.csv b/python/cugraph/cugraph/testing/results/traversal-562676383765605.csv deleted file mode 100644 index 6ac28e23f8c..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-562676383765605.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 -2,2 -3,2 -4,2 -5,2 -6,2 -7,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -21,2 -31,2 -30,2 -9,2 -14,2 -15,2 -18,2 -20,2 -22,2 -23,2 -26,2 -27,2 -28,2 -29,2 -32,2 -16,3 -24,3 -25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-633044963923492.csv b/python/cugraph/cugraph/testing/results/traversal-633044963923492.csv deleted file mode 100644 index 5b2270cb9ed..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-633044963923492.csv +++ /dev/null @@ -1,35 +0,0 @@ -distance,vertex,predecessor -2.0,33,13 -1.0,0,1 -2.0,32,2 -1.0,2,1 -0.0,1,-1 -1.0,3,1 -2.0,31,0 -2.0,8,0 -1.0,13,1 -3.0,23,33 -2.0,5,0 -2.0,6,0 -1.0,7,1 -2.0,27,2 -3.0,29,33 -1.0,30,1 -2.0,4,0 -2.0,10,0 -1.0,19,1 -3.0,24,31 -3.0,25,31 -2.0,28,2 -2.0,9,2 -2.0,12,0 -3.0,14,33 -3.0,15,33 -3.0,16,5 -1.0,17,1 -3.0,18,33 -3.0,20,33 -1.0,21,1 -3.0,22,33 -3.0,26,33 -2.0,11,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-656150055689627.csv b/python/cugraph/cugraph/testing/results/traversal-656150055689627.csv deleted file mode 100644 index 84194972ecf..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-656150055689627.csv +++ /dev/null @@ -1,63 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 -0,2 -3,2 -24,2 -34,2 -40,2 -43,2 -52,2 -8,2 -18,2 -28,2 -36,2 -44,2 -47,2 -12,2 -21,2 -45,2 -61,2 -58,2 -42,2 -51,2 -10,3 -15,3 -59,3 -29,3 -49,3 -7,3 -46,3 -53,3 -1,3 -30,3 -23,3 -39,3 -2,3 -4,3 -11,3 -55,3 -35,4 -19,4 -27,4 -54,4 -17,4 -26,4 -41,4 -57,4 -25,5 -6,5 -13,5 -9,5 -22,5 -31,5 -5,5 -48,5 -56,6 -32,6 -60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-671563943115481.csv b/python/cugraph/cugraph/testing/results/traversal-671563943115481.csv deleted file mode 100644 index 227b61d8259..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-671563943115481.csv +++ /dev/null @@ -1,63 +0,0 @@ -vertex,distance -1,0 -17,1 -19,1 -26,1 -27,1 -28,1 -36,1 -41,1 -54,1 -6,2 -9,2 -13,2 -22,2 -25,2 -31,2 -57,2 -7,2 -30,2 -8,2 -20,2 -47,2 -23,2 -37,2 -39,2 -40,2 -59,2 -56,3 -5,3 -32,3 -48,3 -42,3 -3,3 -45,3 -16,3 -18,3 -38,3 -44,3 -50,3 -0,3 -10,3 -51,3 -14,3 -21,3 -33,3 -34,3 -43,3 -61,3 -15,3 -52,3 -60,4 -2,4 -24,4 -29,4 -58,4 -4,4 -11,4 -55,4 -12,4 -49,4 -46,4 -53,4 -35,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-688340850412339.csv b/python/cugraph/cugraph/testing/results/traversal-688340850412339.csv deleted file mode 100644 index 828e48615f0..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-688340850412339.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -19,2 -21,2 -31,2 -30,2 -9,2 -27,2 -28,2 -32,2 -16,3 -33,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-715146362591693.csv b/python/cugraph/cugraph/testing/results/traversal-715146362591693.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-715146362591693.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-730687934441562.csv b/python/cugraph/cugraph/testing/results/traversal-730687934441562.csv deleted file mode 100644 index 828e48615f0..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-730687934441562.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -19,2 -21,2 -31,2 -30,2 -9,2 -27,2 -28,2 -32,2 -16,3 -33,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-743945746483767.csv b/python/cugraph/cugraph/testing/results/traversal-743945746483767.csv deleted file mode 100644 index 828e48615f0..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-743945746483767.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -19,2 -21,2 -31,2 -30,2 -9,2 -27,2 -28,2 -32,2 -16,3 -33,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-766965872267210.csv b/python/cugraph/cugraph/testing/results/traversal-766965872267210.csv deleted file mode 100644 index 828e48615f0..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-766965872267210.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 -4,2 -5,2 -6,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -19,2 -21,2 -31,2 -30,2 -9,2 -27,2 -28,2 -32,2 -16,3 -33,3 -24,3 -25,3 -23,3 -14,3 -15,3 -18,3 -20,3 -22,3 -29,3 -26,4 diff --git a/python/cugraph/cugraph/testing/results/traversal-767470587558788.csv b/python/cugraph/cugraph/testing/results/traversal-767470587558788.csv deleted file mode 100644 index 384b1e3707b..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-767470587558788.csv +++ /dev/null @@ -1,60 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 -0,2 -3,2 -24,2 -34,2 -40,2 -43,2 -52,2 -8,2 -18,2 -28,2 -36,2 -44,2 -47,2 -12,2 -21,2 -45,2 -61,2 -58,2 -42,2 -51,2 -10,3 -15,3 -59,3 -29,3 -49,3 -7,3 -46,3 -53,3 -1,3 -30,3 -23,3 -39,3 -2,3 -4,3 -11,3 -55,3 -35,4 -19,4 -27,4 -54,4 -17,4 -26,4 -41,4 -57,4 -25,5 -6,5 -13,5 -9,5 -22,5 -31,5 -5,5 -48,5 diff --git a/python/cugraph/cugraph/testing/results/traversal-767697247244749.csv b/python/cugraph/cugraph/testing/results/traversal-767697247244749.csv deleted file mode 100644 index 23e577378c6..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-767697247244749.csv +++ /dev/null @@ -1,5 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-773751608857007.csv b/python/cugraph/cugraph/testing/results/traversal-773751608857007.csv deleted file mode 100644 index 6ac28e23f8c..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-773751608857007.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 -2,2 -3,2 -4,2 -5,2 -6,2 -7,2 -8,2 -10,2 -11,2 -12,2 -13,2 -17,2 -21,2 -31,2 -30,2 -9,2 -14,2 -15,2 -18,2 -20,2 -22,2 -23,2 -26,2 -27,2 -28,2 -29,2 -32,2 -16,3 -24,3 -25,3 diff --git a/python/cugraph/cugraph/testing/results/traversal-794754027574210.csv b/python/cugraph/cugraph/testing/results/traversal-794754027574210.csv deleted file mode 100644 index 84194972ecf..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-794754027574210.csv +++ /dev/null @@ -1,63 +0,0 @@ -vertex,distance -16,0 -14,1 -20,1 -33,1 -37,1 -38,1 -50,1 -0,2 -3,2 -24,2 -34,2 -40,2 -43,2 -52,2 -8,2 -18,2 -28,2 -36,2 -44,2 -47,2 -12,2 -21,2 -45,2 -61,2 -58,2 -42,2 -51,2 -10,3 -15,3 -59,3 -29,3 -49,3 -7,3 -46,3 -53,3 -1,3 -30,3 -23,3 -39,3 -2,3 -4,3 -11,3 -55,3 -35,4 -19,4 -27,4 -54,4 -17,4 -26,4 -41,4 -57,4 -25,5 -6,5 -13,5 -9,5 -22,5 -31,5 -5,5 -48,5 -56,6 -32,6 -60,7 diff --git a/python/cugraph/cugraph/testing/results/traversal-811808371982955.csv b/python/cugraph/cugraph/testing/results/traversal-811808371982955.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-811808371982955.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-836556098128760.csv b/python/cugraph/cugraph/testing/results/traversal-836556098128760.csv deleted file mode 100644 index d7178211365..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-836556098128760.csv +++ /dev/null @@ -1,35 +0,0 @@ -vertex,distance,predecessor -33,3,32 -0,1,7 -32,2,2 -2,1,7 -1,1,7 -3,1,7 -31,2,0 -8,2,0 -13,2,0 -23,3,32 -5,2,0 -6,2,0 -7,0,-1 -27,2,2 -29,3,32 -30,2,1 -4,2,0 -10,2,0 -19,2,0 -24,3,31 -25,3,31 -28,2,2 -9,2,2 -12,2,0 -14,3,32 -15,3,32 -16,3,5 -17,2,0 -18,3,32 -20,3,32 -21,2,0 -22,3,32 -26,4,33 -11,2,0 diff --git a/python/cugraph/cugraph/testing/results/traversal-83873432859770.csv b/python/cugraph/cugraph/testing/results/traversal-83873432859770.csv deleted file mode 100644 index dd3b38a55c6..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-83873432859770.csv +++ /dev/null @@ -1,6 +0,0 @@ -vertex,distance -7,0 -0,1 -1,1 -2,1 -3,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-907905196596504.csv b/python/cugraph/cugraph/testing/results/traversal-907905196596504.csv deleted file mode 100644 index a09c207f808..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-907905196596504.csv +++ /dev/null @@ -1,3 +0,0 @@ -vertex,distance -1237,0 -1238,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-951630488463330.csv b/python/cugraph/cugraph/testing/results/traversal-951630488463330.csv deleted file mode 100644 index 23e577378c6..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-951630488463330.csv +++ /dev/null @@ -1,5 +0,0 @@ -vertex,distance -19,0 -0,1 -1,1 -33,1 diff --git a/python/cugraph/cugraph/testing/results/traversal-954435445708700.csv b/python/cugraph/cugraph/testing/results/traversal-954435445708700.csv deleted file mode 100644 index 2bf79ebfc3e..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal-954435445708700.csv +++ /dev/null @@ -1,106 +0,0 @@ -vertex,distance -1,0 -0,1 -3,1 -5,1 -6,1 -2,2 -4,2 -8,2 -9,2 -10,2 -11,2 -12,2 -13,2 -14,2 -15,2 -16,2 -17,2 -18,2 -19,2 -20,2 -21,2 -22,2 -23,2 -24,2 -25,2 -26,2 -27,2 -7,2 -29,2 -28,3 -30,3 -31,3 -32,3 -33,3 -35,3 -37,3 -40,3 -41,3 -42,3 -43,3 -44,3 -45,3 -46,3 -47,3 -48,3 -49,3 -50,3 -51,3 -52,3 -38,3 -39,3 -55,3 -56,3 -36,3 -54,3 -57,3 -58,3 -77,3 -53,3 -71,3 -85,3 -66,4 -72,4 -67,4 -70,4 -73,4 -74,4 -75,4 -76,4 -79,4 -80,4 -82,4 -83,4 -84,4 -86,4 -93,4 -99,4 -78,4 -91,4 -34,4 -102,4 -64,4 -65,4 -69,4 -68,4 -81,4 -88,5 -89,5 -90,5 -96,5 -97,5 -100,5 -87,5 -92,5 -103,5 -104,5 -94,5 -95,5 -98,5 -60,5 -62,5 -101,5 -61,5 -59,5 -63,5 diff --git a/python/cugraph/cugraph/testing/results/traversal_mappings.csv b/python/cugraph/cugraph/testing/results/traversal_mappings.csv deleted file mode 100644 index f0e38d6f4ef..00000000000 --- a/python/cugraph/cugraph/testing/results/traversal_mappings.csv +++ /dev/null @@ -1,45 +0,0 @@ -UUID algo arg1 arg1val arg2 arg2val arg3 arg3val arg4 arg4val arg5 arg5val arg6 arg6val arg7 arg7val arg8 arg8val arg9 arg9val -431063157185576 single_source_shortest_path_length cutoff None graph_dataset dolphins graph_directed True start_vertex 16 -656150055689627 single_source_shortest_path_length cutoff None graph_dataset dolphins graph_directed False start_vertex 16 -245745928001428 single_source_shortest_path_length cutoff 1 graph_dataset dolphins graph_directed True start_vertex 16 -188398733063004 single_source_shortest_path_length cutoff 1 graph_dataset dolphins graph_directed False start_vertex 16 -190697381576149 single_source_shortest_path_length cutoff 5 graph_dataset dolphins graph_directed True start_vertex 16 -767470587558788 single_source_shortest_path_length cutoff 5 graph_dataset dolphins graph_directed False start_vertex 16 -794754027574210 single_source_shortest_path_length cutoff 18 graph_dataset dolphins graph_directed True start_vertex 16 -1124485822090487 single_source_shortest_path_length cutoff 18 graph_dataset dolphins graph_directed False start_vertex 16 -907905196596504 single_source_shortest_path_length cutoff None graph_dataset netscience graph_directed True start_vertex 1237 -319050385288308 single_source_shortest_path_length cutoff None graph_dataset netscience graph_directed False start_vertex 1237 -1038281390523078 single_source_shortest_path_length cutoff 1 graph_dataset netscience graph_directed True start_vertex 1237 -14314120729501 single_source_shortest_path_length cutoff 1 graph_dataset netscience graph_directed False start_vertex 1237 -526650785538532 single_source_shortest_path_length cutoff 5 graph_dataset netscience graph_directed True start_vertex 1237 -811808371982955 single_source_shortest_path_length cutoff 5 graph_dataset netscience graph_directed False start_vertex 1237 -715146362591693 single_source_shortest_path_length cutoff 18 graph_dataset netscience graph_directed True start_vertex 1237 -31714534985100 single_source_shortest_path_length cutoff 18 graph_dataset netscience graph_directed False start_vertex 1237 -189882724201031 single_source_shortest_path_length cutoff None graph_dataset karate-disjoint graph_directed True start_vertex 19 -553165838223190 single_source_shortest_path_length cutoff None graph_dataset karate-disjoint graph_directed False start_vertex 19 -951630488463330 single_source_shortest_path_length cutoff 1 graph_dataset karate-disjoint graph_directed True start_vertex 19 -767697247244749 single_source_shortest_path_length cutoff 1 graph_dataset karate-disjoint graph_directed False start_vertex 19 -562676383765605 single_source_shortest_path_length cutoff 5 graph_dataset karate-disjoint graph_directed True start_vertex 19 -1120419326843553 single_source_shortest_path_length cutoff 5 graph_dataset karate-disjoint graph_directed False start_vertex 19 -773751608857007 single_source_shortest_path_length cutoff 18 graph_dataset karate-disjoint graph_directed True start_vertex 19 -285876289784674 single_source_shortest_path_length cutoff 18 graph_dataset karate-disjoint graph_directed False start_vertex 19 -688340850412339 single_source_shortest_path_length cutoff None graph_dataset karate graph_directed True start_vertex 7 -766965872267210 single_source_shortest_path_length cutoff None graph_dataset karate graph_directed False start_vertex 7 -1081121981713141 single_source_shortest_path_length cutoff 1 graph_dataset karate graph_directed True start_vertex 7 -83873432859770 single_source_shortest_path_length cutoff 1 graph_dataset karate graph_directed False start_vertex 7 -730687934441562 single_source_shortest_path_length cutoff 5 graph_dataset karate graph_directed True start_vertex 7 -743945746483767 single_source_shortest_path_length cutoff 5 graph_dataset karate graph_directed False start_vertex 7 -37447363258930 single_source_shortest_path_length cutoff 18 graph_dataset karate graph_directed True start_vertex 7 -240638103958132 single_source_shortest_path_length cutoff 18 graph_dataset karate graph_directed False start_vertex 7 -381600612247751 bfs_edges graph_dataset karate graph_directed True source 7 -836556098128760 bfs_edges graph_dataset karate graph_directed False source 7 -349902694645046 single_source_dijkstra_path_length graph_dataset karate graph_directed True source 1 -276948497384571 single_source_dijkstra_path_length graph_dataset karate graph_directed True source 1 test data_type_conversion -671563943115481 single_source_dijkstra_path_length graph_dataset dolphins graph_directed True source 1 -172188670880910 single_source_dijkstra_path_length graph_dataset dolphins graph_directed True source 1 test data_type_conversion -954435445708700 single_source_dijkstra_path_length graph_dataset polbooks graph_directed True source 1 -551177413608707 single_source_dijkstra_path_length graph_dataset polbooks graph_directed True source 1 test data_type_conversion -319914331540810 sssp_nonnative graph_dataset karate graph_directed True source 1 -633044963923492 sssp_nonnative graph_dataset karate graph_directed False source 1 -308351777319316 sssp_nonnative test network_edge_attr -223015853235383 shortest_path_length graph_dataset DISCONNECTED graph_directed True source 1 weight weight diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 0a5f188e624..1b232914f22 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -11,338 +11,107 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tempfile import NamedTemporaryFile -import random -from pathlib import Path - -import numpy as np -import networkx as nx +import tarfile import cudf -import cugraph -from cugraph.experimental.datasets import ( - dolphins, - netscience, - karate_disjoint, - karate, - polbooks, -) -from cugraph.testing import utils - -results_dir = Path("testing/results") - -_resultsets = {} - - -def add_resultset(result_data_dictionary, **kwargs): - rs = utils.ResultSet(result_data_dictionary) - hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - _resultsets[hashable_dict_repr] = rs - - -def get_resultset(category, **kwargs): - hashable_dict_repr = tuple((k, kwargs[k]) for k in sorted(kwargs.keys())) - mappings_path = results_dir / (category + "_mappings.csv") - # Had to set dtype=str to prevent 1s being converted to True - mappings = cudf.read_csv(mappings_path, sep=" ", dtype=str) - colnames = mappings.columns - query_cols = [t for t in colnames][1:] - dict_repr = dict(hashable_dict_repr) - argnames, argvals = [t for t in dict_repr.keys()], [t for t in dict_repr.values()] - mapping_length = 2 * len(argvals) - 1 - single_mapping = np.empty(mapping_length, dtype=object) - single_mapping[0] = argvals[0] - for i in np.arange(1, len(argvals)): - single_mapping[2 * i - 1] = argnames[i] - single_mapping[2 * i] = argvals[i] - for i in np.arange(mapping_length): - mappings = mappings[mappings[query_cols[i]] == single_mapping[i]] - # values_host is used instead of values bc strings aren't saved/possible on device - results_filename = category + "-" + mappings.head(1)["UUID"].values_host[0] - # results_filename = mappings.head(1)["UUID"].values_host[0] - results_filename = results_filename + ".csv" - # Ignore for now -> Assumption is the filename already has the alg category - path = results_dir / results_filename - # path = Path("https://data.rapids.ai/cugraph/results/" / path - return cudf.read_csv(path) - - -# ============================================================================= -# Parameters -# ============================================================================= -# This will be refactored once the datasets variables are fixed/changed -SEEDS = [42] +from cugraph.testing import RAPIDS_DATASET_ROOT_DIR_PATH -DIRECTED_GRAPH_OPTIONS = [True, False] - -DEPTH_LIMITS = [None, 1, 5, 18] - -DATASETS = [dolphins, netscience, karate_disjoint] - -DATASETS_SMALL = [karate, dolphins, polbooks] - -# ============================================================================= -# tests/traversal/test_bfs.py -# ============================================================================= -test_bfs_results = {} - -for ds in DATASETS + [karate]: - for seed in SEEDS: - for depth_limit in DEPTH_LIMITS: - for dirctd in DIRECTED_GRAPH_OPTIONS: - # this does the work of get_cu_graph_nx_results_and_params - Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=dirctd) - random.seed(seed) - start_vertex = random.sample(list(Gnx.nodes()), 1)[0] - nx_values = nx.single_source_shortest_path_length( - Gnx, start_vertex, cutoff=depth_limit - ) - """test_bfs_results[ - "{},{},{},{},{}".format(seed, depth_limit, ds, dirctd, start_vertex) - ] = nx_values""" - vertices = cudf.Series(nx_values.keys()) - distances = cudf.Series(nx_values.values()) - add_resultset( - {"vertex": vertices, "distance": distances}, - graph_dataset=ds.metadata["name"], - graph_directed=str(dirctd), - algo="single_source_shortest_path_length", - start_vertex=str(start_vertex), - cutoff=str(depth_limit), - ) - # test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex - -# these are pandas dataframes -for dirctd in DIRECTED_GRAPH_OPTIONS: - Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) - result = cugraph.bfs_edges(Gnx, source=7) - cugraph_df = cudf.from_pandas(result) - # test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df - add_resultset( - cugraph_df, - graph_dataset="karate", - graph_directed=str(dirctd), - algo="bfs_edges", - source="7", - ) +class Resultset: + def __init__(self, data_dictionary): + self._data_dictionary = data_dictionary -# ============================================================================= -# tests/traversal/test_sssp.py -# ============================================================================= -test_sssp_results = {} + def get_cudf_dataframe(self): + # This is called in testing/resultset.py before writing all results to files + return cudf.DataFrame(self._data_dictionary) -SOURCES = [1] -for ds in DATASETS_SMALL: - for source in SOURCES: - Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) - # test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths - vertices = cudf.Series(nx_paths.keys()) - distances = cudf.Series(nx_paths.values()) - add_resultset( - {"vertex": vertices, "distance": distances}, - graph_dataset=ds.metadata["name"], - graph_directed="True", - algo="single_source_dijkstra_path_length", - source=str(source), - ) - - M = utils.read_csv_for_nx(ds.get_path(), read_weights_in_sp=True) - edge_attr = "weight" - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr=edge_attr, - create_using=nx.DiGraph(), - ) - - M["weight"] = M["weight"].astype(np.int32) - Gnx = nx.from_pandas_edgelist( - M, - source="0", - target="1", - edge_attr="weight", - create_using=nx.DiGraph(), - ) - nx_paths_datatypeconv = nx.single_source_dijkstra_path_length(Gnx, source) - """test_sssp_results[ - "nx_paths,data_type_conversion,{}".format(ds) - ] = nx_paths_datatypeconv""" - vertices_datatypeconv = cudf.Series(nx_paths_datatypeconv.keys()) - distances_datatypeconv = cudf.Series(nx_paths_datatypeconv.values()) - add_resultset( - {"vertex": vertices_datatypeconv, "distance": distances_datatypeconv}, - graph_dataset=ds.metadata["name"], - graph_directed="True", - algo="single_source_dijkstra_path_length", - test="data_type_conversion", - source=str(source), - ) - -for dirctd in DIRECTED_GRAPH_OPTIONS: - for source in SOURCES: - Gnx = utils.generate_nx_graph_from_file( - karate.get_path(), directed=dirctd, edgevals=True - ) - """if dirctd: - test_sssp_results[ - "nonnative_input,nx.DiGraph,{}".format(source) - ] = cugraph.sssp(Gnx, source) - else: - test_sssp_results[ - "nonnative_input,nx.Graph,{}".format(source) - ] = cugraph.sssp(Gnx, source)""" - add_resultset( - cugraph.sssp(Gnx, source), - graph_dataset="karate", - graph_directed=str(dirctd), - algo="sssp_nonnative", - source=str(source), - ) - -G = nx.Graph() -G.add_edge(0, 1, other=10) -G.add_edge(1, 2, other=20) -df = cugraph.sssp(G, 0, edge_attr="other") -# test_sssp_results["network_edge_attr"] = df -add_resultset(df, algo="sssp_nonnative", test="network_edge_attr") - -# ============================================================================= -# tests/traversal/test_paths.py -# ============================================================================= -CONNECTED_GRAPH = """1,5,3 -1,4,1 -1,2,1 -1,6,2 -1,7,2 -4,5,1 -2,3,1 -7,6,2 -""" - -DISCONNECTED_GRAPH = CONNECTED_GRAPH + "8,9,4" - -paths = [("1", "1"), ("1", "5"), ("1", "3"), ("1", "6")] -invalid_paths = { - "connected": [("-1", "1"), ("0", "42")], - "disconnected": [("1", "10"), ("1", "8")], -} - -with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: - graph_tf.writelines(DISCONNECTED_GRAPH) - graph_tf.seek(0) - Gnx_DIS = nx.read_weighted_edgelist(graph_tf.name, delimiter=",") - -res1 = nx.shortest_path_length(Gnx_DIS, source="1", weight="weight") -vertices = cudf.Series(res1.keys()) -distances = cudf.Series(res1.values()) -add_resultset( - {"vertex": vertices, "distance": distances}, - algo="shortest_path_length", - graph_dataset="DISCONNECTED", - graph_directed="True", - source="1", - weight="weight", -) +_resultsets = {} -# Generating ALL results files -"""random.seed(24) -for temp in _resultsets: - res = _resultsets[temp].get_cudf_dataframe() - # Currently, only traversal results files are generated - temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" - temp_mapping = cudf.DataFrame( - [[str(temp), temp_filename]], columns=["hashable_dict_repr", "filename"] - ) - traversal_mappings = cudf.concat( - [traversal_mappings, temp_mapping], axis=0, ignore_index=True +def load_resultset(resultset_name, resultset_download_url): + """ + Read a mapping file (.csv) in the _results_dir and save the + mappings between each unique set of args/identifiers to UUIDs to the + _resultsets dictionary. If .csv does not exist in + _results_dir, use resultset_download_url to download a file to + install/unpack/etc. to _results_dir first. + """ + # mapping_file_path = ( + # RAPIDS_RESULTSET_ROOT_DIR_PATH + # / (resultset_name + "_mappings.csv") + # ) + mapping_file_path = ( + RAPIDS_DATASET_ROOT_DIR_PATH + / "tests" + / "resultsets" + / (resultset_name + "_mappings.csv") ) - # print(temp_filename) - # print("traversal_" + temp_filename) - res.to_csv(results_dir / temp_filename, index=False) -traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False)""" - - -def generate_results(): - random.seed(24) - # traversal_mappings = cudf.DataFrame(columns=["hashable_dict_repr", "filename"]) - traversal_mappings = cudf.DataFrame( - columns=[ - "UUID", - "algo", - "arg1", - "arg1val", - "arg2", - "arg2val", - "arg3", - "arg3val", - "arg4", - "arg4val", - "arg5", - "arg5val", - "arg6", - "arg6val", - "arg7", - "arg7val", - "arg8", - "arg8val", - "arg9", - "arg9val", - ] - ) - # Generating ALL results files - for temp in _resultsets: - res = _resultsets[temp].get_cudf_dataframe() - # Currently, only traversal results files are generated - # temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" - temp_filename = str(random.getrandbits(50)) - temp_dict = dict(temp) - argnames, argvals = [t for t in temp_dict.keys()], [ - t for t in temp_dict.values() + if not mapping_file_path.exists(): + # Downloads a tar gz from s3 bucket, then decompresses the zipped results files + compressed_file_dir = RAPIDS_DATASET_ROOT_DIR_PATH / "tests" + compressed_file_path = compressed_file_dir / "resultsets.tar.gz" + if not compressed_file_path.exists(): + # FIXME: download a tar gz from s3 bucket + raise FileNotFoundError(compressed_file_path, "zipped data not found") + # Currently, it expects to have at least resultsets.tar.gz + tar = tarfile.open(str(compressed_file_path), "r:gz") + tar.extractall(str(compressed_file_dir)) + tar.close() + + # FIXME: This assumes separator is " ", but should this be configurable? + sep = " " + with open(mapping_file_path) as mapping_file: + for line in mapping_file.readlines(): + if line.startswith("#"): + continue + + (uuid, *row_args) = line.split(sep) + if (len(row_args) % 2) != 0: + raise ValueError( + f'bad row in {mapping_file_path}: "{line}", must ' + "contain UUID followed by an even number of items" + ) + row_keys = row_args[::2] + row_vals = row_args[1::2] + row_keys = " ".join(row_keys).split() + row_vals = " ".join(row_vals).split() + arg_dict = dict(zip(row_keys, row_vals)) + arg_dict["resultset_name"] = resultset_name + # Create a unique string key for the _resultsets dict based on + # sorted row_keys. Looking up results based on args will also have + # to sort, but this will ensure results can looked up without + # requiring maintaining a specific order. Example: + # {'a': 1, 'z': 9, 'c': 5, 'b': 2} becomes 'a-1-b-2-c-5-z-9' + resultset_key = "-".join( + [ + str(val) + for arg_dict_pair in sorted(arg_dict.items()) + for val in arg_dict_pair + ] + ) + + _resultsets[resultset_key] = uuid + + +def get_resultset(resultset_name, **kwargs): + arg_dict = dict(kwargs) + arg_dict["resultset_name"] = resultset_name + # Example: + # {'a': 1, 'z': 9, 'c': 5, 'b': 2} becomes 'a-1-b-2-c-5-z-9' + resultset_key = "-".join( + [ + str(val) + for arg_dict_pair in sorted(arg_dict.items()) + for val in arg_dict_pair ] - single_mapping = np.empty(20, dtype=object) - dict_length = len(argnames) - single_mapping[0] = temp_filename - single_mapping[1] = argvals[0] - for i in np.arange(1, dict_length): - single_mapping[2 * i] = argnames[i] - single_mapping[2 * i + 1] = argvals[i] - temp_mapping = cudf.DataFrame( - [single_mapping], - columns=[ - "UUID", - "algo", - "arg1", - "arg1val", - "arg2", - "arg2val", - "arg3", - "arg3val", - "arg4", - "arg4val", - "arg5", - "arg5val", - "arg6", - "arg6val", - "arg7", - "arg7val", - "arg8", - "arg8val", - "arg9", - "arg9val", - ], - ) - traversal_mappings = cudf.concat( - [traversal_mappings, temp_mapping], axis=0, ignore_index=True - ) - res.to_csv(results_dir / ("traversal-" + temp_filename + ".csv"), index=False) - traversal_mappings.to_csv( - results_dir / "traversal_mappings.csv", index=False, sep=" " ) + uuid = _resultsets.get(resultset_key) + if uuid is None: + raise KeyError(f"results for {arg_dict} not found") - -# generate_results() + # results_filename = RAPIDS_RESULTSET_ROOT_DIR_PATH / (uuid + ".csv") + results_filename = ( + RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" / (uuid + ".csv") + ) + return cudf.read_csv(results_filename) diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index 5fc5c81ab6a..793063eb3ed 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -414,17 +414,3 @@ def compare_mst(mst_cugraph, mst_nx): print(cg_sum) print(nx_sum) assert np.isclose(cg_sum, nx_sum) - - -default_results_download_dir = ( - Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" -) - - -class ResultSet: - def __init__(self, data_dictionary): - self._data_dictionary = data_dictionary - - def get_cudf_dataframe(self): - # This is called in testing/resultset.py before writing all results to files - return cudf.DataFrame(self._data_dictionary) diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs.py b/python/cugraph/cugraph/tests/traversal/test_bfs.py index c10ee473a4e..d4eca46ef65 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs.py @@ -26,7 +26,13 @@ from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix from pylibcugraph.testing.utils import gen_fixture_params_product -from cugraph.testing import utils, get_resultset, DEFAULT_DATASETS, SMALL_DATASETS +from cugraph.testing import ( + utils, + get_resultset, + load_resultset, + DEFAULT_DATASETS, + SMALL_DATASETS, +) # ============================================================================= @@ -181,7 +187,7 @@ def func_to_benchmark(): raise NotImplementedError("Invalid type for start_vertex") -def _compare_bfs(cugraph_df, nx_distances, source): +def _compare_bfs(cugraph_df, golden_distances, source): # This call should only contain 3 columns: # 'vertex', 'distance', 'predecessor' # It also confirms wether or not 'sp_counter' has been created by the call @@ -213,10 +219,10 @@ def _compare_bfs(cugraph_df, nx_distances, source): missing_vertex_error = 0 distance_mismatch_error = 0 invalid_predecessor_error = 0 - for vertex in nx_distances: + for vertex in golden_distances: if vertex in cu_distances: result = cu_distances[vertex] - expected = nx_distances[vertex] + expected = golden_distances[vertex] if result != expected: print( "[ERR] Mismatch on distances: " @@ -227,12 +233,12 @@ def _compare_bfs(cugraph_df, nx_distances, source): missing_vertex_error += 1 else: pred = cu_predecessors[vertex] - if vertex != source and pred not in nx_distances: + if vertex != source and pred not in golden_distances: invalid_predecessor_error += 1 else: # The graph is unweighted thus, predecessors are 1 away if vertex != source and ( - (nx_distances[pred] + 1 != cu_distances[vertex]) + (golden_distances[pred] + 1 != cu_distances[vertex]) ): print( "[ERR] Invalid on predecessors: " @@ -257,24 +263,27 @@ def get_cu_graph_and_params(dataset, directed): return (G, dataset_path, dataset_name, directed) -def get_cu_graph_nx_results_and_params( - seed, depth_limit, G, dataset_path, dataset_name, directed +def get_cu_graph_golden_results_and_params( + seed, depth_limit, G, dataset_path, dataset_name, directed, load_results ): """ Helper for fixtures returning Nx results and params. """ start_vertex = DATASET_STARTS[dataset_name] - nx_values = get_resultset( - category="traversal", + golden_values = get_resultset( + resultset_name="traversal", algo="single_source_shortest_path_length", cutoff=str(depth_limit), graph_dataset=dataset_name, graph_directed=str(directed), start_vertex=str(start_vertex), ) - nx_values = cudf.Series(nx_values.distance.values, index=nx_values.vertex).to_dict() - return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) + golden_values = cudf.Series( + golden_values.distance.values, index=golden_values.vertex + ).to_dict() + + return (G, dataset_path, directed, golden_values, start_vertex, depth_limit) # ============================================================================= @@ -316,21 +325,26 @@ def get_cu_graph_nx_results_and_params( ) +@pytest.fixture(scope="module") +def load_traversal_results(): + return load_resultset("traversal", None) + + # Fixtures that result in a test-per (dataset X directed/undirected) # combination. These return the path to the dataset, a bool indicating if a # directed graph is being used, and the Nx graph object. @pytest.fixture(scope="module", params=graph_fixture_params) -def dataset_nx_results(request): +def dataset_golden_results(request): return get_cu_graph_and_params(*request.param) @pytest.fixture(scope="module", params=small_graph_fixture_params) -def small_dataset_nx_results(request): +def small_dataset_golden_results(request): return get_cu_graph_and_params(*request.param) @pytest.fixture(scope="module", params=single_small_graph_fixture_params) -def single_small_dataset_nx_results(request): +def single_small_dataset_golden_results(request): return get_cu_graph_and_params(*request.param) @@ -340,17 +354,24 @@ def single_small_dataset_nx_results(request): # results, the starting vertex for BFS, and flag if shortes path counting was # used. @pytest.fixture(scope="module", params=algo_test_fixture_params) -def dataset_nxresults_startvertex_spc(dataset_nx_results, request): - return get_cu_graph_nx_results_and_params(*request.param, *dataset_nx_results) +def dataset_goldenresults_startvertex_spc( + dataset_golden_results, load_traversal_results, request +): + return get_cu_graph_golden_results_and_params( + *request.param, *dataset_golden_results, load_traversal_results + ) @pytest.fixture(scope="module", params=single_algo_test_fixture_params) -def single_dataset_nxresults_startvertex_spc(single_small_dataset_nx_results, request): - return get_cu_graph_nx_results_and_params( - *request.param, *single_small_dataset_nx_results +def single_dataset_goldenresults_startvertex_spc( + single_small_dataset_golden_results, load_traversal_results, request +): + return get_cu_graph_golden_results_and_params( + *request.param, *single_small_dataset_golden_results, load_traversal_results ) +# FIXME: this is unused, remove? """@pytest.fixture(scope="module") def dataset_nxresults_allstartvertices_spc(small_dataset_nx_results): @@ -375,7 +396,7 @@ def dataset_nxresults_allstartvertices_spc(small_dataset_nx_results): # ============================================================================= @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type): +def test_bfs(gpubenchmark, dataset_goldenresults_startvertex_spc, cugraph_input_type): """ Test BFS traversal on random source with distance and predecessors """ @@ -383,10 +404,10 @@ def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type G, dataset, directed, - nx_values, + golden_values, start_vertex, depth_limit, - ) = dataset_nxresults_startvertex_spc + ) = dataset_goldenresults_startvertex_spc if directed: if isinstance(cugraph_input_type, cugraph.Graph): @@ -397,32 +418,34 @@ def test_bfs(gpubenchmark, dataset_nxresults_startvertex_spc, cugraph_input_type else: G_or_matrix = G - compare_bfs(gpubenchmark, G_or_matrix, nx_values, start_vertex, depth_limit) + compare_bfs(gpubenchmark, G_or_matrix, golden_values, start_vertex, depth_limit) @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) def test_bfs_nonnative_inputs_matrix( - gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type + gpubenchmark, single_dataset_goldenresults_startvertex_spc, cugraph_input_type ): - test_bfs(gpubenchmark, single_dataset_nxresults_startvertex_spc, cugraph_input_type) + test_bfs( + gpubenchmark, single_dataset_goldenresults_startvertex_spc, cugraph_input_type + ) @pytest.mark.sg def test_bfs_nonnative_inputs_nx( - single_dataset_nxresults_startvertex_spc, + single_dataset_goldenresults_startvertex_spc, ): ( _, _, directed, - nx_values, + golden_values, start_vertex, _, - ) = single_dataset_nxresults_startvertex_spc + ) = single_dataset_goldenresults_startvertex_spc cugraph_df = get_resultset( - category="traversal", + resultset_name="traversal", algo="bfs_edges", graph_dataset="karate", graph_directed=str(directed), @@ -430,13 +453,13 @@ def test_bfs_nonnative_inputs_nx( ) compare_func = _compare_bfs - compare_func(cugraph_df, nx_values, start_vertex) + compare_func(cugraph_df, golden_values, start_vertex) @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_INPUT_TYPES) -def test_bfs_invalid_start(dataset_nxresults_startvertex_spc, cugraph_input_type): - (G, _, _, _, start_vertex, depth_limit) = dataset_nxresults_startvertex_spc +def test_bfs_invalid_start(dataset_goldenresults_startvertex_spc, cugraph_input_type): + (G, _, _, _, start_vertex, depth_limit) = dataset_goldenresults_startvertex_spc el = G.view_edge_list() diff --git a/python/cugraph/cugraph/tests/traversal/test_paths.py b/python/cugraph/cugraph/tests/traversal/test_paths.py index a04fa9b0b0d..7f933ec5523 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths.py @@ -21,7 +21,7 @@ import cudf import cupy import cugraph -from cugraph.testing import get_resultset +from cugraph.testing import get_resultset, load_resultset from cupyx.scipy.sparse import coo_matrix as cupy_coo_matrix @@ -39,21 +39,22 @@ paths_test_data = { - "nx.shortest_path_length_1_1": 0, - # "cu.shortest_path_length_1_1": 0.0, - "nx.shortest_path_length_1_5": 2.0, - # "cu.shortest_path_length_1_5": 2.0, - "nx.shortest_path_length_1_3": 2.0, - # "cu.shortest_path_length_1_3": 2.0, - "nx.shortest_path_length_1_6": 2.0, - # "cu.shortest_path_length_1_6": 2.0, - "cu.shortest_path_length_nx_-1_1": ValueError, - "cu.shortest_path_length_nx_1_10": ValueError, - "cu.shortest_path_length_nx_0_42": ValueError, - "cu.shortest_path_length_nx_1_8": 3.4028235e38, + "shortest_path_length_1_1": 0, + "shortest_path_length_1_5": 2.0, + "shortest_path_length_1_3": 2.0, + "shortest_path_length_1_6": 2.0, + "shortest_path_length_nx_-1_1": ValueError, + "shortest_path_length_nx_1_10": ValueError, + "shortest_path_length_nx_0_42": ValueError, + "shortest_path_length_nx_1_8": 3.4028235e38, } +@pytest.fixture(scope="module") +def load_traversal_results(): + return load_resultset("traversal", None) + + @pytest.fixture def graphs(request): with NamedTemporaryFile(mode="w+", suffix=".csv") as graph_tf: @@ -99,27 +100,24 @@ def test_connected_graph_shortest_path_length(graphs): cugraph_G, cupy_df = graphs path_1_to_1_length = cugraph.shortest_path_length(cugraph_G, 1, 1) + # FIXME: aren't the first two assertions in each batch essentially redundant? assert path_1_to_1_length == 0.0 - assert path_1_to_1_length == paths_test_data["nx.shortest_path_length_1_1"] - # assert path_1_to_1_length == paths_test_data["cu.shortest_path_length_1_1"] + assert path_1_to_1_length == paths_test_data["shortest_path_length_1_1"] assert path_1_to_1_length == cugraph.shortest_path_length(cupy_df, 1, 1) path_1_to_5_length = cugraph.shortest_path_length(cugraph_G, 1, 5) assert path_1_to_5_length == 2.0 - assert path_1_to_5_length == paths_test_data["nx.shortest_path_length_1_5"] - # assert path_1_to_5_length == paths_test_data["cu.shortest_path_length_1_5"] + assert path_1_to_5_length == paths_test_data["shortest_path_length_1_5"] assert path_1_to_5_length == cugraph.shortest_path_length(cupy_df, 1, 5) path_1_to_3_length = cugraph.shortest_path_length(cugraph_G, 1, 3) assert path_1_to_3_length == 2.0 - assert path_1_to_3_length == paths_test_data["nx.shortest_path_length_1_3"] - # assert path_1_to_3_length == paths_test_data["cu.shortest_path_length_1_3"] + assert path_1_to_3_length == paths_test_data["shortest_path_length_1_3"] assert path_1_to_3_length == cugraph.shortest_path_length(cupy_df, 1, 3) path_1_to_6_length = cugraph.shortest_path_length(cugraph_G, 1, 6) assert path_1_to_6_length == 2.0 - assert path_1_to_6_length == paths_test_data["nx.shortest_path_length_1_6"] - # assert path_1_to_6_length == paths_test_data["cu.shortest_path_length_1_6"] + assert path_1_to_6_length == paths_test_data["shortest_path_length_1_6"] assert path_1_to_6_length == cugraph.shortest_path_length(cupy_df, 1, 6) @@ -131,7 +129,7 @@ def test_shortest_path_length_invalid_source(graphs): with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, -1, 1) - result = paths_test_data["cu.shortest_path_length_nx_-1_1"] + result = paths_test_data["shortest_path_length_nx_-1_1"] if callable(result): with pytest.raises(ValueError): raise result() @@ -148,7 +146,7 @@ def test_shortest_path_length_invalid_target(graphs): with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 1, 10) - result = paths_test_data["cu.shortest_path_length_nx_1_10"] + result = paths_test_data["shortest_path_length_nx_1_10"] if callable(result): with pytest.raises(ValueError): raise result() @@ -165,7 +163,7 @@ def test_shortest_path_length_invalid_vertexes(graphs): with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 0, 42) - result = paths_test_data["cu.shortest_path_length_nx_0_42"] + result = paths_test_data["shortest_path_length_nx_0_42"] if callable(result): with pytest.raises(ValueError): raise result() @@ -186,7 +184,7 @@ def test_shortest_path_length_no_path(graphs): path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) assert path_1_to_8 == sys.float_info.max - nx_path_1_to_8 = paths_test_data["cu.shortest_path_length_nx_1_8"] + nx_path_1_to_8 = paths_test_data["shortest_path_length_nx_1_8"] nx_path_1_to_8 = np.float32(nx_path_1_to_8) assert nx_path_1_to_8 in [ max_float_32, @@ -197,18 +195,26 @@ def test_shortest_path_length_no_path(graphs): @pytest.mark.sg @pytest.mark.parametrize("graphs", [DISCONNECTED_GRAPH], indirect=True) -def test_shortest_path_length_no_target(graphs): +def test_shortest_path_length_no_target(graphs, load_traversal_results): cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) nx_path_1_to_all = get_resultset( - category="traversal", + resultset_name="traversal", algo="shortest_path_length", graph_dataset="DISCONNECTED", graph_directed=str(True), source="1", weight="weight", ) + """nx_path_1_to_all = get_resultset( + category="traversal", + algo="shortest_path_length", + graph_dataset="DISCONNECTED", + graph_directed=str(True), + source="1", + weight="weight", + )""" cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) # Cast networkx graph on cugraph vertex column type from str to int. diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp.py b/python/cugraph/cugraph/tests/traversal/test_sssp.py index d948227d651..0d0f8f60769 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp.py @@ -28,7 +28,13 @@ from scipy.sparse import csr_matrix as sp_csr_matrix from scipy.sparse import csc_matrix as sp_csc_matrix from pylibcugraph.testing.utils import gen_fixture_params_product -from cugraph.testing import utils, get_resultset, UNDIRECTED_DATASETS, SMALL_DATASETS +from cugraph.testing import ( + utils, + get_resultset, + load_resultset, + UNDIRECTED_DATASETS, + SMALL_DATASETS, +) # Map of cuGraph input types to the expected output type for cuGraph @@ -121,7 +127,7 @@ def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=Tru return result_dict, max_val -def networkx_call(graph_file, source, edgevals=True): +def networkx_call(graph_file, source, load_results, edgevals=True): dataset_path = graph_file.get_path() dataset_name = graph_file.metadata["name"] @@ -129,7 +135,7 @@ def networkx_call(graph_file, source, edgevals=True): # FIXME: no test coverage if edgevals is False, this assertion is never reached assert False nx_paths = get_resultset( - category="traversal", + resultset_name="traversal", algo="single_source_shortest_path_length", graph_dataset=dataset_name, graph_directed=str(True), @@ -140,13 +146,12 @@ def networkx_call(graph_file, source, edgevals=True): # not support 'weights'. It matches cuGraph result only if the weight column # is 1s. nx_paths = get_resultset( - category="traversal", + resultset_name="traversal", algo="single_source_dijkstra_path_length", graph_dataset=dataset_name, graph_directed=str(True), source=str(source), ) - # nx_paths = nx_paths.drop(columns="Unnamed: 0") nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() G = graph_file.get_graph( @@ -178,26 +183,31 @@ def networkx_call(graph_file, source, edgevals=True): # These fixtures will call networkx BFS algos and save the result. The networkx # call is only made only once per input param combination. +@pytest.fixture(scope="module") +def load_traversal_results(): + return load_resultset("traversal", None) + + @pytest.fixture(scope="module", params=fixture_params) def dataset_source_nxresults(request): # request.param is a tuple of params from fixture_params. When expanded # with *, will be passed to networkx_call() as args (graph_file, source) - return networkx_call(*(request.param)) + return networkx_call(*(request.param), load_traversal_results) @pytest.fixture(scope="module", params=fixture_params_single_dataset) def single_dataset_source_nxresults(request): - return networkx_call(*(request.param)) + return networkx_call(*(request.param), load_traversal_results) @pytest.fixture(scope="module", params=fixture_params) def dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), edgevals=True) + return networkx_call(*(request.param), load_traversal_results, edgevals=True) @pytest.fixture(scope="module", params=fixture_params_single_dataset) def single_dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), edgevals=True) + return networkx_call(*(request.param), load_traversal_results, edgevals=True) # ============================================================================= @@ -265,7 +275,7 @@ def test_sssp_nonnative_inputs_nx(single_dataset_source_nxresults, directed): (_, _, graph_file, source, nx_paths) = single_dataset_source_nxresults dataset_name = graph_file.metadata["name"] result = get_resultset( - category="traversal", + resultset_name="traversal", algo="sssp_nonnative", graph_dataset=dataset_name, graph_directed=str(directed), @@ -369,7 +379,7 @@ def test_sssp_data_type_conversion(graph_file, source): pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) nx_paths = get_resultset( - category="traversal", + resultset_name="traversal", algo="single_source_dijkstra_path_length", graph_dataset=dataset_name, graph_directed=str(True), @@ -403,10 +413,13 @@ def test_sssp_data_type_conversion(graph_file, source): @pytest.mark.sg -def test_sssp_networkx_edge_attr(): +def test_sssp_networkx_edge_attr(load_traversal_results): df = get_resultset( - category="traversal", algo="sssp_nonnative", test="network_edge_attr" + resultset_name="traversal", algo="sssp_nonnative", test="network_edge_attr" ) + """df = get_resultset( + category="traversal", algo="sssp_nonnative", test="network_edge_attr" + )""" df = df.set_index("vertex") assert df.loc[0, "distance"] == 0 assert df.loc[1, "distance"] == 10 From 95685db3e5bf06e5b19bc0d1161be54c15523cc5 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Wed, 9 Aug 2023 00:46:44 +0000 Subject: [PATCH 15/20] Removed comments, renaming variables --- python/cugraph/cugraph/testing/__init__.py | 1 - .../cugraph/testing/generate_resultsets.py | 73 ++++------------ python/cugraph/cugraph/testing/resultset.py | 4 +- python/cugraph/cugraph/testing/utils.py | 2 - .../cugraph/tests/traversal/test_bfs.py | 3 - .../cugraph/tests/traversal/test_paths.py | 36 +++----- .../cugraph/tests/traversal/test_sssp.py | 85 ++++++++++--------- 7 files changed, 77 insertions(+), 127 deletions(-) diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index bd9314608b1..5dd7a58000d 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -11,7 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# from cugraph.testing.resultset import get_resultset, get_resultset2 from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH, RAPIDS_DATASET_ROOT_DIR from cugraph.testing.resultset import load_resultset, get_resultset from cugraph.datasets import ( diff --git a/python/cugraph/cugraph/testing/generate_resultsets.py b/python/cugraph/cugraph/testing/generate_resultsets.py index d3ad2625792..5a996f9cf4f 100644 --- a/python/cugraph/cugraph/testing/generate_resultsets.py +++ b/python/cugraph/cugraph/testing/generate_resultsets.py @@ -66,14 +66,11 @@ def add_resultset(result_data_dictionary, **kwargs): Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=dirctd) random.seed(seed) start_vertex = random.sample(list(Gnx.nodes()), 1)[0] - nx_values = nx.single_source_shortest_path_length( + golden_values = nx.single_source_shortest_path_length( Gnx, start_vertex, cutoff=depth_limit ) - """test_bfs_results[ - "{},{},{},{},{}".format(seed, depth_limit, ds, dirctd, start_vertex) - ] = nx_values""" - vertices = cudf.Series(nx_values.keys()) - distances = cudf.Series(nx_values.values()) + vertices = cudf.Series(golden_values.keys()) + distances = cudf.Series(golden_values.values()) add_resultset( {"vertex": vertices, "distance": distances}, graph_dataset=ds.metadata["name"], @@ -82,14 +79,12 @@ def add_resultset(result_data_dictionary, **kwargs): start_vertex=str(start_vertex), cutoff=str(depth_limit), ) - # test_bfs_results["{},{},starts".format(seed, ds)] = start_vertex # these are pandas dataframes for dirctd in DIRECTED_GRAPH_OPTIONS: Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) - result = cugraph.bfs_edges(Gnx, source=7) - cugraph_df = cudf.from_pandas(result) - # test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df + golden_result = cugraph.bfs_edges(Gnx, source=7) + cugraph_df = cudf.from_pandas(golden_result) add_resultset( cugraph_df, graph_dataset="karate", @@ -109,10 +104,9 @@ def add_resultset(result_data_dictionary, **kwargs): for ds in DATASETS_SMALL: for source in SOURCES: Gnx = utils.generate_nx_graph_from_file(ds.get_path(), directed=True) - nx_paths = nx.single_source_dijkstra_path_length(Gnx, source) - # test_sssp_results["{},{},ssdpl".format(ds, source)] = nx_paths - vertices = cudf.Series(nx_paths.keys()) - distances = cudf.Series(nx_paths.values()) + golden_paths = nx.single_source_dijkstra_path_length(Gnx, source) + vertices = cudf.Series(golden_paths.keys()) + distances = cudf.Series(golden_paths.values()) add_resultset( {"vertex": vertices, "distance": distances}, graph_dataset=ds.metadata["name"], @@ -139,12 +133,9 @@ def add_resultset(result_data_dictionary, **kwargs): edge_attr="weight", create_using=nx.DiGraph(), ) - nx_paths_datatypeconv = nx.single_source_dijkstra_path_length(Gnx, source) - """test_sssp_results[ - "nx_paths,data_type_conversion,{}".format(ds) - ] = nx_paths_datatypeconv""" - vertices_datatypeconv = cudf.Series(nx_paths_datatypeconv.keys()) - distances_datatypeconv = cudf.Series(nx_paths_datatypeconv.values()) + golden_paths_datatypeconv = nx.single_source_dijkstra_path_length(Gnx, source) + vertices_datatypeconv = cudf.Series(golden_paths_datatypeconv.keys()) + distances_datatypeconv = cudf.Series(golden_paths_datatypeconv.values()) add_resultset( {"vertex": vertices_datatypeconv, "distance": distances_datatypeconv}, graph_dataset=ds.metadata["name"], @@ -159,14 +150,6 @@ def add_resultset(result_data_dictionary, **kwargs): Gnx = utils.generate_nx_graph_from_file( karate.get_path(), directed=dirctd, edgevals=True ) - """if dirctd: - test_sssp_results[ - "nonnative_input,nx.DiGraph,{}".format(source) - ] = cugraph.sssp(Gnx, source) - else: - test_sssp_results[ - "nonnative_input,nx.Graph,{}".format(source) - ] = cugraph.sssp(Gnx, source)""" add_resultset( cugraph.sssp(Gnx, source), graph_dataset="karate", @@ -175,11 +158,10 @@ def add_resultset(result_data_dictionary, **kwargs): source=str(source), ) -G = nx.Graph() -G.add_edge(0, 1, other=10) -G.add_edge(1, 2, other=20) -df = cugraph.sssp(G, 0, edge_attr="other") -# test_sssp_results["network_edge_attr"] = df +Gnx = nx.Graph() +Gnx.add_edge(0, 1, other=10) +Gnx.add_edge(1, 2, other=20) +df = cugraph.sssp(Gnx, 0, edge_attr="other") add_resultset(df, algo="sssp_nonnative", test="network_edge_attr") # ============================================================================= @@ -221,26 +203,8 @@ def add_resultset(result_data_dictionary, **kwargs): ) -# Generating ALL results files -"""random.seed(24) -for temp in _resultsets: - res = _resultsets[temp].get_cudf_dataframe() - # Currently, only traversal results files are generated - temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" - temp_mapping = cudf.DataFrame( - [[str(temp), temp_filename]], columns=["hashable_dict_repr", "filename"] - ) - traversal_mappings = cudf.concat( - [traversal_mappings, temp_mapping], axis=0, ignore_index=True - ) - # print(temp_filename) - # print("traversal_" + temp_filename) - res.to_csv(results_dir / temp_filename, index=False) -traversal_mappings.to_csv(results_dir / "traversal_mappings.csv", index=False)""" - - def generate_results(): - # FIXME: Currently, only traversal results files are generated + # NOTE: Currently, only traversal result files are generated random.seed(24) traversal_mappings = cudf.DataFrame( columns=[ @@ -270,7 +234,6 @@ def generate_results(): # Generating ALL results files for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() - # temp_filename = "traversal-" + str(random.getrandbits(55)) + ".csv" temp_filename = str(random.getrandbits(50)) temp_dict = dict(temp) argnames, argvals = [t for t in temp_dict.keys()], [ @@ -280,11 +243,7 @@ def generate_results(): dict_length = len(argnames) single_mapping[0] = temp_filename - # single_mapping[1] = argvals[0] - # for i in np.arange(1, dict_length): for i in np.arange(dict_length): - # single_mapping[2 * i] = argnames[i] - # single_mapping[2 * i + 1] = argvals[i] single_mapping[2 * i + 1] = argnames[i] single_mapping[2 * i + 2] = argvals[i] temp_mapping = cudf.DataFrame( diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 1b232914f22..0cf2705a920 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -53,7 +53,9 @@ def load_resultset(resultset_name, resultset_download_url): compressed_file_path = compressed_file_dir / "resultsets.tar.gz" if not compressed_file_path.exists(): # FIXME: download a tar gz from s3 bucket - raise FileNotFoundError(compressed_file_path, "zipped data not found") + raise FileNotFoundError( + compressed_file_path, "downloading from s3 not implemented" + ) # Currently, it expects to have at least resultsets.tar.gz tar = tarfile.open(str(compressed_file_path), "r:gz") tar.extractall(str(compressed_file_dir)) diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index 793063eb3ed..0dae17ed14e 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -32,8 +32,6 @@ import cugraph from cugraph.dask.common.mg_utils import get_client -# from cugraph.experimental.datasets import default_download_dir - CUPY_MATRIX_TYPES = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix] SCIPY_MATRIX_TYPES = [sp_coo_matrix, sp_csr_matrix, sp_csc_matrix] diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs.py b/python/cugraph/cugraph/tests/traversal/test_bfs.py index d4eca46ef65..c432e734f0a 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs.py @@ -90,9 +90,6 @@ def convert_output_to_cudf(input_G_or_matrix, cugraph_result): if expected_return_type is cudf.DataFrame: return cugraph_result - # elif expected_return_type is pd.DataFrame: - # return cudf.from_pandas(cugraph_result) - # A CuPy/SciPy input means the return value will be a 2-tuple of: # distance: cupy.ndarray # ndarray of shortest distances between source and vertex. diff --git a/python/cugraph/cugraph/tests/traversal/test_paths.py b/python/cugraph/cugraph/tests/traversal/test_paths.py index 7f933ec5523..d89632305b6 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths.py @@ -43,10 +43,10 @@ "shortest_path_length_1_5": 2.0, "shortest_path_length_1_3": 2.0, "shortest_path_length_1_6": 2.0, - "shortest_path_length_nx_-1_1": ValueError, - "shortest_path_length_nx_1_10": ValueError, - "shortest_path_length_nx_0_42": ValueError, - "shortest_path_length_nx_1_8": 3.4028235e38, + "shortest_path_length_-1_1": ValueError, + "shortest_path_length_1_10": ValueError, + "shortest_path_length_0_42": ValueError, + "shortest_path_length_1_8": 3.4028235e38, } @@ -129,7 +129,7 @@ def test_shortest_path_length_invalid_source(graphs): with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, -1, 1) - result = paths_test_data["shortest_path_length_nx_-1_1"] + result = paths_test_data["shortest_path_length_-1_1"] if callable(result): with pytest.raises(ValueError): raise result() @@ -146,7 +146,7 @@ def test_shortest_path_length_invalid_target(graphs): with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 1, 10) - result = paths_test_data["shortest_path_length_nx_1_10"] + result = paths_test_data["shortest_path_length_1_10"] if callable(result): with pytest.raises(ValueError): raise result() @@ -163,7 +163,7 @@ def test_shortest_path_length_invalid_vertexes(graphs): with pytest.raises(ValueError): cugraph.shortest_path_length(cugraph_G, 0, 42) - result = paths_test_data["shortest_path_length_nx_0_42"] + result = paths_test_data["shortest_path_length_0_42"] if callable(result): with pytest.raises(ValueError): raise result() @@ -184,9 +184,9 @@ def test_shortest_path_length_no_path(graphs): path_1_to_8 = cugraph.shortest_path_length(cugraph_G, 1, 8) assert path_1_to_8 == sys.float_info.max - nx_path_1_to_8 = paths_test_data["shortest_path_length_nx_1_8"] - nx_path_1_to_8 = np.float32(nx_path_1_to_8) - assert nx_path_1_to_8 in [ + golden_path_1_to_8 = paths_test_data["shortest_path_length_1_8"] + golden_path_1_to_8 = np.float32(golden_path_1_to_8) + assert golden_path_1_to_8 in [ max_float_32, path_1_to_8, ] @@ -199,7 +199,7 @@ def test_shortest_path_length_no_target(graphs, load_traversal_results): cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - nx_path_1_to_all = get_resultset( + golden_path_1_to_all = get_resultset( resultset_name="traversal", algo="shortest_path_length", graph_dataset="DISCONNECTED", @@ -207,14 +207,6 @@ def test_shortest_path_length_no_target(graphs, load_traversal_results): source="1", weight="weight", ) - """nx_path_1_to_all = get_resultset( - category="traversal", - algo="shortest_path_length", - graph_dataset="DISCONNECTED", - graph_directed=str(True), - source="1", - weight="weight", - )""" cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) # Cast networkx graph on cugraph vertex column type from str to int. @@ -222,7 +214,7 @@ def test_shortest_path_length_no_target(graphs, load_traversal_results): assert cugraph_path_1_to_all == cupy_path_1_to_all # results for vertex 8 and 9 are not returned - assert cugraph_path_1_to_all.shape[0] == len(nx_path_1_to_all) + 2 + assert cugraph_path_1_to_all.shape[0] == len(golden_path_1_to_all) + 2 for index in range(cugraph_path_1_to_all.shape[0]): vertex = cugraph_path_1_to_all["vertex"][index].item() @@ -235,7 +227,7 @@ def test_shortest_path_length_no_target(graphs, load_traversal_results): else: assert ( distance - == nx_path_1_to_all.loc[ - nx_path_1_to_all.vertex == vertex + == golden_path_1_to_all.loc[ + golden_path_1_to_all.vertex == vertex ].distance.iloc[0] ) diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp.py b/python/cugraph/cugraph/tests/traversal/test_sssp.py index 0d0f8f60769..6143b90ac0e 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp.py @@ -127,14 +127,14 @@ def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, source, edgevals=Tru return result_dict, max_val -def networkx_call(graph_file, source, load_results, edgevals=True): +def resultset_call(graph_file, source, load_results, edgevals=True): dataset_path = graph_file.get_path() dataset_name = graph_file.metadata["name"] if edgevals is False: # FIXME: no test coverage if edgevals is False, this assertion is never reached assert False - nx_paths = get_resultset( + golden_paths = get_resultset( resultset_name="traversal", algo="single_source_shortest_path_length", graph_dataset=dataset_name, @@ -142,23 +142,25 @@ def networkx_call(graph_file, source, load_results, edgevals=True): source=str(source), ) else: - # FIXME: The nx call below doesn't return accurate results as it seems to - # not support 'weights'. It matches cuGraph result only if the weight column - # is 1s. - nx_paths = get_resultset( + # FIXME: The golden results (nx) below doesn't return accurate results as it + # seems to not support 'weights'. It matches cuGraph result only if the weight + # column is 1s. + golden_paths = get_resultset( resultset_name="traversal", algo="single_source_dijkstra_path_length", graph_dataset=dataset_name, graph_directed=str(True), source=str(source), ) - nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() + golden_paths = cudf.Series( + golden_paths.distance.values, index=golden_paths.vertex + ).to_dict() G = graph_file.get_graph( create_using=cugraph.Graph(directed=True), ignore_weights=not edgevals ) - return (G, dataset_path, graph_file, source, nx_paths) + return (G, dataset_path, graph_file, source, golden_paths) # ============================================================================= @@ -189,25 +191,25 @@ def load_traversal_results(): @pytest.fixture(scope="module", params=fixture_params) -def dataset_source_nxresults(request): +def dataset_source_goldenresults(request): # request.param is a tuple of params from fixture_params. When expanded # with *, will be passed to networkx_call() as args (graph_file, source) - return networkx_call(*(request.param), load_traversal_results) + return resultset_call(*(request.param), load_traversal_results) @pytest.fixture(scope="module", params=fixture_params_single_dataset) -def single_dataset_source_nxresults(request): - return networkx_call(*(request.param), load_traversal_results) +def single_dataset_source_goldenresults(request): + return resultset_call(*(request.param), load_traversal_results) @pytest.fixture(scope="module", params=fixture_params) -def dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), load_traversal_results, edgevals=True) +def dataset_source_goldenresults_weighted(request): + return resultset_call(*(request.param), load_traversal_results, edgevals=True) @pytest.fixture(scope="module", params=fixture_params_single_dataset) -def single_dataset_source_nxresults_weighted(request): - return networkx_call(*(request.param), load_traversal_results, edgevals=True) +def single_dataset_source_goldenresults_weighted(request): + return resultset_call(*(request.param), load_traversal_results, edgevals=True) # ============================================================================= @@ -215,9 +217,9 @@ def single_dataset_source_nxresults_weighted(request): # ============================================================================= @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): +def test_sssp(gpubenchmark, dataset_source_goldenresults, cugraph_input_type): # Extract the params generated from the fixture - (G, dataset_path, _, source, nx_paths) = dataset_source_nxresults + (G, dataset_path, _, source, golden_paths) = dataset_source_goldenresults if not isinstance(cugraph_input_type, cugraph.Graph): input_G_or_matrix = utils.create_obj_from_csv( @@ -234,14 +236,14 @@ def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): # NOTE : If distance type is float64 then cu_paths[vid][0] # should be compared against np.finfo(np.float64).max) if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: + if cu_paths[vid][0] != golden_paths[vid]: err = err + 1 # check pred dist + 1 = current dist (since unweighted) pred = cu_paths[vid][1] if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: err = err + 1 else: - if vid in nx_paths.keys(): + if vid in golden_paths.keys(): err = err + 1 assert err == 0 @@ -249,8 +251,10 @@ def test_sssp(gpubenchmark, dataset_source_nxresults, cugraph_input_type): @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) -def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_input_type): - (G, _, _, source, _) = dataset_source_nxresults +def test_sssp_invalid_start( + gpubenchmark, dataset_source_goldenresults, cugraph_input_type +): + (G, _, _, source, _) = dataset_source_goldenresults el = G.view_edge_list() newval = max(el.src.max(), el.dst.max()) + 1 @@ -263,16 +267,16 @@ def test_sssp_invalid_start(gpubenchmark, dataset_source_nxresults, cugraph_inpu @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.MATRIX_INPUT_TYPES) def test_sssp_nonnative_inputs_matrix( - gpubenchmark, single_dataset_source_nxresults, cugraph_input_type + gpubenchmark, single_dataset_source_goldenresults, cugraph_input_type ): - test_sssp(gpubenchmark, single_dataset_source_nxresults, cugraph_input_type) + test_sssp(gpubenchmark, single_dataset_source_goldenresults, cugraph_input_type) # MARK @pytest.mark.sg @pytest.mark.parametrize("directed", [True, False]) -def test_sssp_nonnative_inputs_nx(single_dataset_source_nxresults, directed): - (_, _, graph_file, source, nx_paths) = single_dataset_source_nxresults +def test_sssp_nonnative_inputs_graph(single_dataset_source_goldenresults, directed): + (_, _, graph_file, source, golden_paths) = single_dataset_source_goldenresults dataset_name = graph_file.metadata["name"] result = get_resultset( resultset_name="traversal", @@ -297,14 +301,14 @@ def test_sssp_nonnative_inputs_nx(single_dataset_source_nxresults, directed): # NOTE : If distance type is float64 then cu_paths[vid][0] # should be compared against np.finfo(np.float64).max) if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: + if cu_paths[vid][0] != golden_paths[vid]: err = err + 1 # check pred dist + 1 = current dist (since unweighted) pred = cu_paths[vid][1] if vid != source and cu_paths[pred][0] + 1 != cu_paths[vid][0]: err = err + 1 else: - if vid in nx_paths.keys(): + if vid in golden_paths.keys(): err = err + 1 assert err == 0 @@ -313,10 +317,10 @@ def test_sssp_nonnative_inputs_nx(single_dataset_source_nxresults, directed): @pytest.mark.sg @pytest.mark.parametrize("cugraph_input_type", utils.CUGRAPH_DIR_INPUT_TYPES) def test_sssp_edgevals( - gpubenchmark, dataset_source_nxresults_weighted, cugraph_input_type + gpubenchmark, dataset_source_goldenresults_weighted, cugraph_input_type ): # Extract the params generated from the fixture - (G, _, _, source, nx_paths) = dataset_source_nxresults_weighted + (G, _, _, source, golden_paths) = dataset_source_goldenresults_weighted input_G_or_matrix = G cu_paths, max_val = cugraph_call( @@ -331,7 +335,7 @@ def test_sssp_edgevals( # should be compared against np.finfo(np.float64).max) distances = cugraph.sssp(G, source=vid) if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: + if cu_paths[vid][0] != golden_paths[vid]: err = err + 1 # check pred dist + edge_weight = current dist if vid != source: @@ -341,7 +345,7 @@ def test_sssp_edgevals( if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: err = err + 1 else: - if vid in nx_paths.keys(): + if vid in golden_paths.keys(): err = err + 1 assert err == 0 @@ -351,10 +355,10 @@ def test_sssp_edgevals( "cugraph_input_type", utils.NX_DIR_INPUT_TYPES + utils.MATRIX_INPUT_TYPES ) def test_sssp_edgevals_nonnative_inputs( - gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type + gpubenchmark, single_dataset_source_goldenresults_weighted, cugraph_input_type ): test_sssp_edgevals( - gpubenchmark, single_dataset_source_nxresults_weighted, cugraph_input_type + gpubenchmark, single_dataset_source_goldenresults_weighted, cugraph_input_type ) @@ -378,7 +382,7 @@ def test_sssp_data_type_conversion(graph_file, source): dist_np = df["distance"].to_numpy() pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - nx_paths = get_resultset( + golden_paths = get_resultset( resultset_name="traversal", algo="single_source_dijkstra_path_length", graph_dataset=dataset_name, @@ -386,7 +390,9 @@ def test_sssp_data_type_conversion(graph_file, source): source=str(source), test="data_type_conversion", ) - nx_paths = cudf.Series(nx_paths.distance.values, index=nx_paths.vertex).to_dict() + golden_paths = cudf.Series( + golden_paths.distance.values, index=golden_paths.vertex + ).to_dict() # Calculating mismatch err = 0 @@ -396,7 +402,7 @@ def test_sssp_data_type_conversion(graph_file, source): # should be compared against np.finfo(np.float64).max) distances = cugraph.sssp(G, source=vid) if cu_paths[vid][0] != max_val: - if cu_paths[vid][0] != nx_paths[vid]: + if cu_paths[vid][0] != golden_paths[vid]: err = err + 1 # check pred dist + edge_weight = current dist if vid != source: @@ -406,7 +412,7 @@ def test_sssp_data_type_conversion(graph_file, source): if cu_paths[pred][0] + edge_weight != cu_paths[vid][0]: err = err + 1 else: - if vid in nx_paths.keys(): + if vid in golden_paths.keys(): err = err + 1 assert err == 0 @@ -417,9 +423,6 @@ def test_sssp_networkx_edge_attr(load_traversal_results): df = get_resultset( resultset_name="traversal", algo="sssp_nonnative", test="network_edge_attr" ) - """df = get_resultset( - category="traversal", algo="sssp_nonnative", test="network_edge_attr" - )""" df = df.set_index("vertex") assert df.loc[0, "distance"] == 0 assert df.loc[1, "distance"] == 10 From 2a92f2fc227b0dcfecd39d33c300010458e172f4 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Mon, 14 Aug 2023 07:08:07 +0000 Subject: [PATCH 16/20] Addresses review suggestions --- datasets/tests/resultsets/resultsets.tar.gz | Bin 0 -> 3081 bytes python/cugraph/cugraph/testing/__init__.py | 8 +- .../cugraph/testing/generate_resultsets.py | 334 +++++++++--------- python/cugraph/cugraph/testing/resultset.py | 62 ++-- python/cugraph/cugraph/testing/utils.py | 1 + .../cugraph/tests/traversal/test_bfs.py | 47 +-- .../cugraph/tests/traversal/test_paths.py | 21 +- .../cugraph/tests/traversal/test_sssp.py | 2 +- 8 files changed, 234 insertions(+), 241 deletions(-) create mode 100644 datasets/tests/resultsets/resultsets.tar.gz diff --git a/datasets/tests/resultsets/resultsets.tar.gz b/datasets/tests/resultsets/resultsets.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..e46f6ad3421faacab1e3b05f93051af561b01001 GIT binary patch literal 3081 zcmZuzdpr|-7awvfU0jMx<}xHAJmi)sDiTwkq-AcAYOX1_uuTckTo$6)RHO^$Qp_dG zlglV1PlyAFNeapBH| zgMZ;#S(dq_c@C@PM*cait^vq~Oo#J^^&qbPa-q+;RE6U438f|7EmgY^-f*>Bo?OaoZw`jdQSpRM(X z`WyK9KNyW6EtY{9k=&dNwYn5{n@`yf2ddD&^qxAl=l(0ihsrnh z(34MqLd`?`8r%VH4dDW05Uw^~hAF1~^&s@K)w81}KFj;`ydksCu`vEF{_~66U=fRD z*kkUol&I`^!b$p-9(^8!qp%|?do;U+&T3v#?QZ+x`r3LhDW-2%gIr41RTYzX`EU3z z#)Kus+U<>Wks_{EMnEPq_V)=pzZI=kJ6mL7s@);FE=RFxylZ2qXcxFpa&KKIdSrs+ zCab*uc=o4+ecEx?@bpLfd|N~=B{T_97L$#<<=he^?|PkDC>|xWnAXbWN0@jMDr7g9 zk@PFzwDV?~i30%Le=gMQ2w!$glqfqOXQQ$WJ57_tsC(-Kr(&7p4S_ z>n@38h6mJDO=TZ&gQ1GyRmm8*eXUWtNp*vqpT6Ch62E2TLL(fT*snn&h74zYxcFp6 zlN$W9R>DpkA3$`^)$lv!Q~H__2>EpQmAGyTiyMG~O^~;JFMHDwyS>uE`~xGo?n7dI zoIJWf;YzuxSdP0?vsn3zfPNkn+nfQ1y-tH}eK|;vAn?^6`s{4V#wlS%F(F(qgjTV0 zownCWrPX%ex7OPzO!??#gm?ekO4U;Zk?TXsl~t-yiBnzOkP&Op40$9N!hOZk&!tu+ ze^(jDE&KDbmVx*?a2dY})}So|(W%N+j;*+w{8S)XV<9MJfzr{Pe1N`qDfCo2KW&$= zW=@IUMVw9rc)tqX34a3{4}BU?XQ$NNoX9}}qo}wz(y)Gar?5vcHe}>PDPUSqw_L!m zyoI5}G2hT&ILAEd=V80^f86Xl4rtlevNW_KoHK7~ZCY&YJMuSsO4N9okB_jvq2hJ# zp2GBE@dhWv-jmh4eANt8(uz7ik|Mv|yuD<3>DUiTNB^}qiDPp)-*~;nV{M!O^9Ike zWLVH2%{T2g>l8;iDP)+k|EJ&cET8E5ypf$)&zRg@oFZya-{)WnZ(5Uz7vwK7gF>Z% z2CtI>vnW)fD>2U}F2Hfra!yFQmh>!aIXZPA=XFbCt4b%lJjF0pRVc=)S}~H`nxx9T zcI0HCr#UxE36&E2@Lbq;b8dd2QLLiZd!*fi=k2Y<&#zC6M$cl>Q1X5IuZ5eS4+q1F z3#AWy(d=uH&w9n_^>}OOxU&ikEyx?#M)>WUpR5&@A**=5&^$7Hu44aA_cFB&sAymT z8=hJCw10f|m2b?6Cvco^W=gv3yX_ujnj26J;rQKpZlCv5TI4=Psy&rZ&hM6NB6W>8 zJ)=BwsqBfyBt0SsZa`mhmV6B^IWmbYEB(CCYV(57#ZSnHArw6(HZO0=FTqe)Tg*y> z8*XQBnpJ|t9LVf0)Nn&$t(2)6N|$nD9bJ}6OtWZ6Odj_LI{{Ng4fMH{(Wpd}Id#S9 z;sGa&k^}0jl*xo0CDhWR{aB^RhN4#buTe*}3-@Um7F;8NUIsfj>o9(g@GBQ>6!!tM zz)#sd<$m8lpO>8-N+umH=Y}`keGb+yH)QoS=T#H=YLYLm=yCpmt>e_v$>B%B9<dKla zl2`ou54l_!6kqR}QMzFb1mN8|97AIAhMQMIVE)r0H- zAX!aD?Fefeb>Xz^=EOhw2FS%nYnJw}QLVcC_024=58+?73l$)POFL)6@3`ndLKh#M zfY)Mf8X*xwVY{yUdj?@QhiWJTIJMkz4mH^>aQ31HptR3?blt zV$z|#6WQTS1i;Su;ZR9^hU~|@UAnxum2uxhlnFjqF$`HN-G=2hk4%Yq4o}J(YACwkc7p%#4fx3+rh7u{bSYtl;oBW>!bV8RznabJFl&4Eo_xf`n-3|y6fo|6PMCGhTTGJ zv$o|qKh(N&=T7!Gyw}`t#~wnHkKI21*==gfFY`)+j;Cd!4(T<0Jef&&7@_nFiSds zYrzbCC6-?^*n9##11qi+c;t;reymy_hJz>?M0P4iQhO5iPF z7i}^9XkN_3k@-@#zAGAQav^_X*C8x!#jWwy?@!hc%8D~bg0bFcx-F>~CndX13sq-i z72`}L7*llG9!5DnRW4}>PwWv5)fvTPq%^xdG_`Fs2_5@TXXo37`|w;mS$O7BS<{=v^pu(S)tb0UxcX>lKa6=Cdb}VAtN$f z4eAv6L+!N59Vxa}*HxVjAF2J_;_$JG)XzEMdi(nlBGc6wcH&GU8YS$dO%Kk;{Rv?S zHH%mQH$<5%kTs`O=0%Dclhd@Zxk~pwc*^T8fAYs4T9@}Kg#buUTQKC3=F!g6HwP{j zUpSszE8q~=H{#R>9u9&bX^-bvHt|1)*$y1@rVcs{*)-+F!a3jH0Z**nE$ zZq20h_f3sedKdV*>lUwud9d}J#zAT`Fq-1+F16+(Hj&%?a@Xvcar!sG<`@_0Ocg%% zjz(YEwCCmxNNB~bKwD_l10kEM!NFeVMd&zln89*a7@G61X*dIGtr@!UX8<`qP2aoe zFqQ&T{|84mwH9EG3(Vi3cl%pFWvX!4QGG`-&pNN^NelS Date: Mon, 14 Aug 2023 21:39:48 +0000 Subject: [PATCH 17/20] change pathing to pass CI --- .../tests/{resultsets => }/resultsets.tar.gz | Bin .../cugraph/testing/generate_resultsets.py | 3 +++ python/cugraph/cugraph/testing/resultset.py | 17 ++++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) rename datasets/tests/{resultsets => }/resultsets.tar.gz (100%) diff --git a/datasets/tests/resultsets/resultsets.tar.gz b/datasets/tests/resultsets.tar.gz similarity index 100% rename from datasets/tests/resultsets/resultsets.tar.gz rename to datasets/tests/resultsets.tar.gz diff --git a/python/cugraph/cugraph/testing/generate_resultsets.py b/python/cugraph/cugraph/testing/generate_resultsets.py index 4820f939d56..2aee7285044 100644 --- a/python/cugraph/cugraph/testing/generate_resultsets.py +++ b/python/cugraph/cugraph/testing/generate_resultsets.py @@ -225,6 +225,9 @@ def add_resultset(result_data_dictionary, **kwargs): ] ) # Generating ALL results files + if not utils.RAPIDS_RESULTSET_ROOT_DIR_PATH.exists(): + utils.RAPIDS_RESULTSET_ROOT_DIR_PATH.mkdir(parents=True, exist_ok=True) + for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() temp_filename = str(random.getrandbits(50)) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index f8d731250b9..28b0a456b16 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -12,7 +12,8 @@ # limitations under the License. import tarfile -import urllib.request + +# import urllib.request import cudf from cugraph.testing import RAPIDS_DATASET_ROOT_DIR_PATH, RAPIDS_RESULTSET_ROOT_DIR_PATH @@ -56,13 +57,15 @@ def load_resultset(resultset_name, resultset_download_url): resultset_name + "_mappings.csv" ) if not mapping_file_path.exists(): - # Downloads a tar gz from s3 bucket, then unpacks the zipped results files + # Downloads a tar gz from s3 bucket, then unpacks the results files compressed_file_dir = RAPIDS_DATASET_ROOT_DIR_PATH / "tests" - compressed_file_path = compressed_file_dir / "resultsets" / "resultsets.tar.gz" - if not compressed_file_path.exists(): - # FIXME: untested until resultsets.tar.gz is uploaded to s3 bucket - urllib.request.urlretrieve(resultset_download_url, compressed_file_dir) - tar = tarfile.open(str(RAPIDS_RESULTSET_ROOT_DIR_PATH), "r:gz") + compressed_file_path = compressed_file_dir / "resultsets.tar.gz" + if not RAPIDS_RESULTSET_ROOT_DIR_PATH.exists(): + RAPIDS_RESULTSET_ROOT_DIR_PATH.mkdir(parents=True, exist_ok=True) + # FIXME: untested until resultsets.tar.gz is uploaded to s3 bucket + # if not compressed_file_path.exists(): + # urllib.request.urlretrieve(resultset_download_url, compressed_file_path) + tar = tarfile.open(str(compressed_file_path), "r:gz") tar.extractall(str(RAPIDS_RESULTSET_ROOT_DIR_PATH)) tar.close() From 0902b8b1ff13165b576afdae9b91d95af07b7e97 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Tue, 15 Aug 2023 21:04:58 +0000 Subject: [PATCH 18/20] Uncommented s3 download block --- datasets/tests/resultsets.tar.gz | Bin 3081 -> 0 bytes python/cugraph/cugraph/testing/resultset.py | 7 +++---- .../cugraph/cugraph/tests/traversal/test_bfs.py | 4 +++- .../cugraph/tests/traversal/test_paths.py | 11 ++++++++--- .../cugraph/cugraph/tests/traversal/test_sssp.py | 14 ++++++++------ 5 files changed, 22 insertions(+), 14 deletions(-) delete mode 100644 datasets/tests/resultsets.tar.gz diff --git a/datasets/tests/resultsets.tar.gz b/datasets/tests/resultsets.tar.gz deleted file mode 100644 index e46f6ad3421faacab1e3b05f93051af561b01001..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3081 zcmZuzdpr|-7awvfU0jMx<}xHAJmi)sDiTwkq-AcAYOX1_uuTckTo$6)RHO^$Qp_dG zlglV1PlyAFNeapBH| zgMZ;#S(dq_c@C@PM*cait^vq~Oo#J^^&qbPa-q+;RE6U438f|7EmgY^-f*>Bo?OaoZw`jdQSpRM(X z`WyK9KNyW6EtY{9k=&dNwYn5{n@`yf2ddD&^qxAl=l(0ihsrnh z(34MqLd`?`8r%VH4dDW05Uw^~hAF1~^&s@K)w81}KFj;`ydksCu`vEF{_~66U=fRD z*kkUol&I`^!b$p-9(^8!qp%|?do;U+&T3v#?QZ+x`r3LhDW-2%gIr41RTYzX`EU3z z#)Kus+U<>Wks_{EMnEPq_V)=pzZI=kJ6mL7s@);FE=RFxylZ2qXcxFpa&KKIdSrs+ zCab*uc=o4+ecEx?@bpLfd|N~=B{T_97L$#<<=he^?|PkDC>|xWnAXbWN0@jMDr7g9 zk@PFzwDV?~i30%Le=gMQ2w!$glqfqOXQQ$WJ57_tsC(-Kr(&7p4S_ z>n@38h6mJDO=TZ&gQ1GyRmm8*eXUWtNp*vqpT6Ch62E2TLL(fT*snn&h74zYxcFp6 zlN$W9R>DpkA3$`^)$lv!Q~H__2>EpQmAGyTiyMG~O^~;JFMHDwyS>uE`~xGo?n7dI zoIJWf;YzuxSdP0?vsn3zfPNkn+nfQ1y-tH}eK|;vAn?^6`s{4V#wlS%F(F(qgjTV0 zownCWrPX%ex7OPzO!??#gm?ekO4U;Zk?TXsl~t-yiBnzOkP&Op40$9N!hOZk&!tu+ ze^(jDE&KDbmVx*?a2dY})}So|(W%N+j;*+w{8S)XV<9MJfzr{Pe1N`qDfCo2KW&$= zW=@IUMVw9rc)tqX34a3{4}BU?XQ$NNoX9}}qo}wz(y)Gar?5vcHe}>PDPUSqw_L!m zyoI5}G2hT&ILAEd=V80^f86Xl4rtlevNW_KoHK7~ZCY&YJMuSsO4N9okB_jvq2hJ# zp2GBE@dhWv-jmh4eANt8(uz7ik|Mv|yuD<3>DUiTNB^}qiDPp)-*~;nV{M!O^9Ike zWLVH2%{T2g>l8;iDP)+k|EJ&cET8E5ypf$)&zRg@oFZya-{)WnZ(5Uz7vwK7gF>Z% z2CtI>vnW)fD>2U}F2Hfra!yFQmh>!aIXZPA=XFbCt4b%lJjF0pRVc=)S}~H`nxx9T zcI0HCr#UxE36&E2@Lbq;b8dd2QLLiZd!*fi=k2Y<&#zC6M$cl>Q1X5IuZ5eS4+q1F z3#AWy(d=uH&w9n_^>}OOxU&ikEyx?#M)>WUpR5&@A**=5&^$7Hu44aA_cFB&sAymT z8=hJCw10f|m2b?6Cvco^W=gv3yX_ujnj26J;rQKpZlCv5TI4=Psy&rZ&hM6NB6W>8 zJ)=BwsqBfyBt0SsZa`mhmV6B^IWmbYEB(CCYV(57#ZSnHArw6(HZO0=FTqe)Tg*y> z8*XQBnpJ|t9LVf0)Nn&$t(2)6N|$nD9bJ}6OtWZ6Odj_LI{{Ng4fMH{(Wpd}Id#S9 z;sGa&k^}0jl*xo0CDhWR{aB^RhN4#buTe*}3-@Um7F;8NUIsfj>o9(g@GBQ>6!!tM zz)#sd<$m8lpO>8-N+umH=Y}`keGb+yH)QoS=T#H=YLYLm=yCpmt>e_v$>B%B9<dKla zl2`ou54l_!6kqR}QMzFb1mN8|97AIAhMQMIVE)r0H- zAX!aD?Fefeb>Xz^=EOhw2FS%nYnJw}QLVcC_024=58+?73l$)POFL)6@3`ndLKh#M zfY)Mf8X*xwVY{yUdj?@QhiWJTIJMkz4mH^>aQ31HptR3?blt zV$z|#6WQTS1i;Su;ZR9^hU~|@UAnxum2uxhlnFjqF$`HN-G=2hk4%Yq4o}J(YACwkc7p%#4fx3+rh7u{bSYtl;oBW>!bV8RznabJFl&4Eo_xf`n-3|y6fo|6PMCGhTTGJ zv$o|qKh(N&=T7!Gyw}`t#~wnHkKI21*==gfFY`)+j;Cd!4(T<0Jef&&7@_nFiSds zYrzbCC6-?^*n9##11qi+c;t;reymy_hJz>?M0P4iQhO5iPF z7i}^9XkN_3k@-@#zAGAQav^_X*C8x!#jWwy?@!hc%8D~bg0bFcx-F>~CndX13sq-i z72`}L7*llG9!5DnRW4}>PwWv5)fvTPq%^xdG_`Fs2_5@TXXo37`|w;mS$O7BS<{=v^pu(S)tb0UxcX>lKa6=Cdb}VAtN$f z4eAv6L+!N59Vxa}*HxVjAF2J_;_$JG)XzEMdi(nlBGc6wcH&GU8YS$dO%Kk;{Rv?S zHH%mQH$<5%kTs`O=0%Dclhd@Zxk~pwc*^T8fAYs4T9@}Kg#buUTQKC3=F!g6HwP{j zUpSszE8q~=H{#R>9u9&bX^-bvHt|1)*$y1@rVcs{*)-+F!a3jH0Z**nE$ zZq20h_f3sedKdV*>lUwud9d}J#zAT`Fq-1+F16+(Hj&%?a@Xvcar!sG<`@_0Ocg%% zjz(YEwCCmxNNB~bKwD_l10kEM!NFeVMd&zln89*a7@G61X*dIGtr@!UX8<`qP2aoe zFqQ&T{|84mwH9EG3(Vi3cl%pFWvX!4QGG`-&pNN^NelS Date: Fri, 18 Aug 2023 20:12:40 +0000 Subject: [PATCH 19/20] Removed Resultset env var --- python/cugraph/cugraph/testing/__init__.py | 1 - .../cugraph/testing/generate_resultsets.py | 6 +++--- python/cugraph/cugraph/testing/resultset.py | 15 +++++++-------- python/cugraph/cugraph/testing/utils.py | 1 - 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 79dfcbe6525..38167e78726 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -14,7 +14,6 @@ from cugraph.testing.utils import ( RAPIDS_DATASET_ROOT_DIR_PATH, RAPIDS_DATASET_ROOT_DIR, - RAPIDS_RESULTSET_ROOT_DIR_PATH, ) from cugraph.testing.resultset import Resultset, load_resultset, get_resultset from cugraph.datasets import ( diff --git a/python/cugraph/cugraph/testing/generate_resultsets.py b/python/cugraph/cugraph/testing/generate_resultsets.py index 2aee7285044..4f77ad3a1d0 100644 --- a/python/cugraph/cugraph/testing/generate_resultsets.py +++ b/python/cugraph/cugraph/testing/generate_resultsets.py @@ -23,7 +23,7 @@ from cugraph.testing import utils, Resultset, SMALL_DATASETS -_results_dir = utils.RAPIDS_RESULTSET_ROOT_DIR_PATH +_results_dir = utils.RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" _resultsets = {} @@ -225,8 +225,8 @@ def add_resultset(result_data_dictionary, **kwargs): ] ) # Generating ALL results files - if not utils.RAPIDS_RESULTSET_ROOT_DIR_PATH.exists(): - utils.RAPIDS_RESULTSET_ROOT_DIR_PATH.mkdir(parents=True, exist_ok=True) + if not _results_dir.exists(): + _results_dir.mkdir(parents=True, exist_ok=True) for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 22e39daee77..faff34e43ba 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -16,7 +16,7 @@ import urllib.request import cudf -from cugraph.testing import RAPIDS_DATASET_ROOT_DIR_PATH, RAPIDS_RESULTSET_ROOT_DIR_PATH +from cugraph.testing import RAPIDS_DATASET_ROOT_DIR_PATH class Resultset: @@ -43,6 +43,7 @@ def get_cudf_dataframe(self): _resultsets = {} +_results_dir_path = RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" def load_resultset(resultset_name, resultset_download_url): @@ -53,19 +54,17 @@ def load_resultset(resultset_name, resultset_download_url): _results_dir, use resultset_download_url to download a file to install/unpack/etc. to _results_dir first. """ - mapping_file_path = RAPIDS_RESULTSET_ROOT_DIR_PATH / ( - resultset_name + "_mappings.csv" - ) + mapping_file_path = _results_dir_path / (resultset_name + "_mappings.csv") if not mapping_file_path.exists(): # Downloads a tar gz from s3 bucket, then unpacks the results files compressed_file_dir = RAPIDS_DATASET_ROOT_DIR_PATH / "tests" compressed_file_path = compressed_file_dir / "resultsets.tar.gz" - if not RAPIDS_RESULTSET_ROOT_DIR_PATH.exists(): - RAPIDS_RESULTSET_ROOT_DIR_PATH.mkdir(parents=True, exist_ok=True) + if not _results_dir_path.exists(): + _results_dir_path.mkdir(parents=True, exist_ok=True) if not compressed_file_path.exists(): urllib.request.urlretrieve(resultset_download_url, compressed_file_path) tar = tarfile.open(str(compressed_file_path), "r:gz") - tar.extractall(str(RAPIDS_RESULTSET_ROOT_DIR_PATH)) + tar.extractall(str(_results_dir_path)) tar.close() # FIXME: This assumes separator is " ", but should this be configurable? @@ -131,5 +130,5 @@ def get_resultset(resultset_name, **kwargs): if uuid is None: raise KeyError(f"results for {arg_dict} not found") - results_filename = RAPIDS_RESULTSET_ROOT_DIR_PATH / (uuid + ".csv") + results_filename = _results_dir_path / (uuid + ".csv") return cudf.read_csv(results_filename) diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index c3befbfcc26..6d58076e6fe 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -40,7 +40,6 @@ "RAPIDS_DATASET_ROOT_DIR", os.path.join(os.path.dirname(__file__), "../datasets") ) RAPIDS_DATASET_ROOT_DIR_PATH = Path(RAPIDS_DATASET_ROOT_DIR) -RAPIDS_RESULTSET_ROOT_DIR_PATH = RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" # # Datasets From 3ab132d9ba1f688d03a6ec83f08e74c73c7af436 Mon Sep 17 00:00:00 2001 From: Dylan Chima-Sanchez Date: Mon, 21 Aug 2023 22:12:58 +0000 Subject: [PATCH 20/20] Removed duplicate constants and fixed imports --- python/cugraph/cugraph/testing/__init__.py | 7 ++++++- .../cugraph/testing/generate_resultsets.py | 11 +++++------ python/cugraph/cugraph/testing/resultset.py | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 38167e78726..bde398aadbd 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -15,7 +15,12 @@ RAPIDS_DATASET_ROOT_DIR_PATH, RAPIDS_DATASET_ROOT_DIR, ) -from cugraph.testing.resultset import Resultset, load_resultset, get_resultset +from cugraph.testing.resultset import ( + Resultset, + load_resultset, + get_resultset, + results_dir_path, +) from cugraph.datasets import ( cyber, dolphins, diff --git a/python/cugraph/cugraph/testing/generate_resultsets.py b/python/cugraph/cugraph/testing/generate_resultsets.py index 4f77ad3a1d0..9724aca32dc 100644 --- a/python/cugraph/cugraph/testing/generate_resultsets.py +++ b/python/cugraph/cugraph/testing/generate_resultsets.py @@ -20,10 +20,9 @@ import cudf import cugraph from cugraph.datasets import dolphins, netscience, karate_disjoint, karate -from cugraph.testing import utils, Resultset, SMALL_DATASETS +from cugraph.testing import utils, Resultset, SMALL_DATASETS, results_dir_path -_results_dir = utils.RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" _resultsets = {} @@ -225,8 +224,8 @@ def add_resultset(result_data_dictionary, **kwargs): ] ) # Generating ALL results files - if not _results_dir.exists(): - _results_dir.mkdir(parents=True, exist_ok=True) + if not results_dir_path.exists(): + results_dir_path.mkdir(parents=True, exist_ok=True) for temp in _resultsets: res = _resultsets[temp].get_cudf_dataframe() @@ -271,7 +270,7 @@ def add_resultset(result_data_dictionary, **kwargs): traversal_mappings = cudf.concat( [traversal_mappings, temp_mapping], axis=0, ignore_index=True ) - res.to_csv(_results_dir / (temp_filename + ".csv"), index=False) + res.to_csv(results_dir_path / (temp_filename + ".csv"), index=False) traversal_mappings.to_csv( - _results_dir / "traversal_mappings.csv", index=False, sep=" " + results_dir_path / "traversal_mappings.csv", index=False, sep=" " ) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index faff34e43ba..490e3a7c4ff 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -16,7 +16,10 @@ import urllib.request import cudf -from cugraph.testing import RAPIDS_DATASET_ROOT_DIR_PATH +from cugraph.testing import utils + + +results_dir_path = utils.RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" class Resultset: @@ -43,7 +46,6 @@ def get_cudf_dataframe(self): _resultsets = {} -_results_dir_path = RAPIDS_DATASET_ROOT_DIR_PATH / "tests" / "resultsets" def load_resultset(resultset_name, resultset_download_url): @@ -54,17 +56,17 @@ def load_resultset(resultset_name, resultset_download_url): _results_dir, use resultset_download_url to download a file to install/unpack/etc. to _results_dir first. """ - mapping_file_path = _results_dir_path / (resultset_name + "_mappings.csv") + mapping_file_path = results_dir_path / (resultset_name + "_mappings.csv") if not mapping_file_path.exists(): # Downloads a tar gz from s3 bucket, then unpacks the results files - compressed_file_dir = RAPIDS_DATASET_ROOT_DIR_PATH / "tests" + compressed_file_dir = utils.RAPIDS_DATASET_ROOT_DIR_PATH / "tests" compressed_file_path = compressed_file_dir / "resultsets.tar.gz" - if not _results_dir_path.exists(): - _results_dir_path.mkdir(parents=True, exist_ok=True) + if not results_dir_path.exists(): + results_dir_path.mkdir(parents=True, exist_ok=True) if not compressed_file_path.exists(): urllib.request.urlretrieve(resultset_download_url, compressed_file_path) tar = tarfile.open(str(compressed_file_path), "r:gz") - tar.extractall(str(_results_dir_path)) + tar.extractall(str(results_dir_path)) tar.close() # FIXME: This assumes separator is " ", but should this be configurable? @@ -130,5 +132,5 @@ def get_resultset(resultset_name, **kwargs): if uuid is None: raise KeyError(f"results for {arg_dict} not found") - results_filename = _results_dir_path / (uuid + ".csv") + results_filename = results_dir_path / (uuid + ".csv") return cudf.read_csv(results_filename)