From 867f412d0de118192a0271f8ac0eda99b0967fc0 Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Thu, 10 Oct 2024 17:06:51 -0700 Subject: [PATCH 1/4] fix typo --- cpp/src/c_api/graph_sg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/c_api/graph_sg.cpp b/cpp/src/c_api/graph_sg.cpp index f6ea8e4142e..ccb6d086dde 100644 --- a/cpp/src/c_api/graph_sg.cpp +++ b/cpp/src/c_api/graph_sg.cpp @@ -793,7 +793,7 @@ cugraph_error_code_t cugraph_graph_create_sg_from_csr( p_edge_ids, p_edge_type_ids, renumber, - FALSE, // symmetrize + symmetrize, do_expensive_check); try { From d1014fc0fadb601aad07e4550c378b8d8c88a23a Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Mon, 14 Oct 2024 10:06:04 -0700 Subject: [PATCH 2/4] add tests --- .../cugraph/tests/structure/test_graph.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/python/cugraph/cugraph/tests/structure/test_graph.py b/python/cugraph/cugraph/tests/structure/test_graph.py index 48a0b257b12..d86a3145e88 100644 --- a/python/cugraph/cugraph/tests/structure/test_graph.py +++ b/python/cugraph/cugraph/tests/structure/test_graph.py @@ -26,6 +26,7 @@ from cudf.testing import assert_series_equal from cudf.testing.testing import assert_frame_equal from cugraph.structure.symmetrize import symmetrize +from cugraph.datasets import karate_asymmetric # MG import dask_cudf @@ -204,6 +205,31 @@ def test_add_adj_list_to_edge_list(graph_file): compare_series(destinations_cu, destinations_exp) +@pytest.mark.sg +def test_create_undirected_graph_from_asymmetric_adj_list(): + # karate_asymmetric.get_path() + Mnx = utils.read_csv_for_nx(karate_asymmetric.get_path()) + N = max(max(Mnx["0"]), max(Mnx["1"])) + 1 + Mcsr = scipy.sparse.csr_matrix((Mnx.weight, (Mnx["0"], Mnx["1"])), shape=(N, N)) + + offsets = cudf.Series(Mcsr.indptr) + indices = cudf.Series(Mcsr.indices) + + G = cugraph.Graph(directed=False) + + with pytest.raises(Exception): + # Ifan undirected graph is created with 'symmetrize' set to False, the + # edgelist provided by the user must be symmetric. + G.from_cudf_adjlist(offsets, indices, None, symmetrize=False) + + G = cugraph.Graph(directed=False) + G.from_cudf_adjlist(offsets, indices, None, symmetrize=True) + + # FIXME: Once 'decompress_to_edgelist' is exposed to the + # python API, ensure that the derived edgelist is symmetric + # if symmetrize = True. + + # Test @pytest.mark.sg @pytest.mark.parametrize("graph_file", utils.DATASETS) From 507deeb5f71824a0453fbfc389d9f2fa24cc8d82 Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Mon, 14 Oct 2024 10:07:31 -0700 Subject: [PATCH 3/4] fix style --- python/cugraph/cugraph/tests/structure/test_graph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cugraph/cugraph/tests/structure/test_graph.py b/python/cugraph/cugraph/tests/structure/test_graph.py index d86a3145e88..52723655d25 100644 --- a/python/cugraph/cugraph/tests/structure/test_graph.py +++ b/python/cugraph/cugraph/tests/structure/test_graph.py @@ -221,11 +221,11 @@ def test_create_undirected_graph_from_asymmetric_adj_list(): # Ifan undirected graph is created with 'symmetrize' set to False, the # edgelist provided by the user must be symmetric. G.from_cudf_adjlist(offsets, indices, None, symmetrize=False) - + G = cugraph.Graph(directed=False) G.from_cudf_adjlist(offsets, indices, None, symmetrize=True) - # FIXME: Once 'decompress_to_edgelist' is exposed to the + # FIXME: Once 'decompress_to_edgelist' is exposed to the # python API, ensure that the derived edgelist is symmetric # if symmetrize = True. From 43cc8e6d486ae99a115335ac088b3aa9fc37016a Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Mon, 21 Oct 2024 09:48:41 -0700 Subject: [PATCH 4/4] add assertion and fixme --- python/cugraph/cugraph/tests/structure/test_graph.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/cugraph/cugraph/tests/structure/test_graph.py b/python/cugraph/cugraph/tests/structure/test_graph.py index 52723655d25..b3e517100e1 100644 --- a/python/cugraph/cugraph/tests/structure/test_graph.py +++ b/python/cugraph/cugraph/tests/structure/test_graph.py @@ -225,6 +225,12 @@ def test_create_undirected_graph_from_asymmetric_adj_list(): G = cugraph.Graph(directed=False) G.from_cudf_adjlist(offsets, indices, None, symmetrize=True) + # FIXME: Since we have no mechanism to access the symmetrized edgelist + # from the graph_view_t, assert that the edgelist size is unchanged. Once + # exposing 'decompress_to_edgelist', ensure that + # G.number_of_edges() == 2 * karate_asymmetric.get_edgelist()? + assert G.number_of_edges() == len(karate_asymmetric.get_edgelist()) + # FIXME: Once 'decompress_to_edgelist' is exposed to the # python API, ensure that the derived edgelist is symmetric # if symmetrize = True.