Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch 22.06 MNMG bug work and support for Undirected Graphs #2215

Merged
merged 22 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e9b1c18
added check and test for directed graph
acostadon Apr 7, 2022
c373602
corrected error text
acostadon Apr 7, 2022
5ba7553
fix style problems
acostadon Apr 7, 2022
f4383f0
Merge remote-tracking branch 'upstream/branch-22.06' into branch-22.0…
acostadon Apr 8, 2022
bd7c1ac
removed the check for directed graph only added test to bfs
acostadon Apr 8, 2022
80a8263
fixed style issue
acostadon Apr 8, 2022
bf3cd44
removed print line
acostadon Apr 8, 2022
252ad49
corrected copyright
acostadon Apr 8, 2022
558306e
fixed copyright
acostadon Apr 8, 2022
c685550
Merge remote-tracking branch 'upstream/branch-22.06' into branch-22.0…
acostadon Apr 15, 2022
d07c375
removed gc call from test
acostadon Apr 18, 2022
4d39079
Merge remote-tracking branch 'upstream/branch-22.06' into branch-22.0…
acostadon Apr 20, 2022
51f55b4
responded to review comments
acostadon Apr 20, 2022
e229df4
Merge remote-tracking branch 'upstream/branch-22.06' into branch-22.0…
acostadon Apr 21, 2022
152ebdb
Added parameterization for directed/undirected graphs
acostadon Apr 21, 2022
8cea2bd
fixed style check problem
acostadon Apr 24, 2022
55b7a5d
removed digraph specific comments and created undirected test for lou…
acostadon Apr 25, 2022
134b70a
Merge remote-tracking branch 'upstream/branch-22.06' into branch-22.0…
acostadon Apr 27, 2022
eff8a0c
corrected a typo
acostadon Apr 27, 2022
827f6bd
fixed test to use digraph and graph instead of directed param per com…
acostadon May 2, 2022
a67e9bd
removed FIXME, changed test name per comments
acostadon May 2, 2022
5952991
added comment to explain that the test will always throw ValueError w…
acostadon May 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/cugraph/cugraph/dask/traversal/bfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def bfs(input_graph,

Parameters
----------
input_graph : directed cugraph.Graph
input_graph : cugraph.Graph
cuGraph graph instance, should contain the connectivity information
as dask cudf edge list dataframe(edge weights are not used for this
algorithm). Undirected Graph not currently supported.
algorithm).

start : Integer
Specify starting vertex for breadth-first search; this function
Expand Down
6 changes: 2 additions & 4 deletions python/cugraph/cugraph/link_prediction/jaccard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# limitations under the License.

import cudf
from cugraph.structure.graph_classes import Graph
from cugraph.link_prediction import jaccard_wrapper
from cugraph.utilities import (ensure_cugraph_obj_for_nx,
df_edge_score_to_dictionary,
Expand Down Expand Up @@ -108,9 +107,8 @@ def jaccard(input_graph, vertex_pair=None):
>>> df = cugraph.jaccard(G)

"""
if type(input_graph) is not Graph:
raise TypeError("input graph must a Graph")

if input_graph.is_directed():
raise TypeError("Input must an undirected Graph.")
acostadon marked this conversation as resolved.
Show resolved Hide resolved
if type(vertex_pair) == cudf.DataFrame:
vertex_pair = renumber_vertex_pair(input_graph, vertex_pair)
elif vertex_pair is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ def __from_edgelist(
):
if not isinstance(input_ddf, dask_cudf.DataFrame):
raise TypeError("input should be a dask_cudf dataFrame")
if self.properties.directed is False:
raise TypeError("Undirected distributed graph not supported")
acostadon marked this conversation as resolved.
Show resolved Hide resolved

s_col = source
d_col = destination
Expand Down
67 changes: 65 additions & 2 deletions python/cugraph/cugraph/tests/dask/test_mg_bfs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
# Copyright (c) 2020-2022, 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
Expand All @@ -25,7 +25,6 @@
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
def test_dask_bfs(dask_client):
gc.collect()

input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH /
"netscience.csv").as_posix()
Expand Down Expand Up @@ -85,6 +84,70 @@ def modify_dataset(df):
assert err == 0


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
def test_dask_bfs_undirected(dask_client):
gc.collect()
acostadon marked this conversation as resolved.
Show resolved Hide resolved
acostadon marked this conversation as resolved.
Show resolved Hide resolved

input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH /
"netscience.csv").as_posix()

print(f"dataset={input_data_path}")
chunksize = dcg.get_chunksize(input_data_path)

ddf = dask_cudf.read_csv(
input_data_path,
chunksize=chunksize,
delimiter=" ",
names=["src", "dst", "value"],
dtype=["int32", "int32", "float32"],
)

def modify_dataset(df):
temp_df = cudf.DataFrame()
temp_df['src'] = df['src']+1000
temp_df['dst'] = df['dst']+1000
temp_df['value'] = df['value']
return cudf.concat([df, temp_df])

meta = ddf._meta
ddf = ddf.map_partitions(modify_dataset, meta=meta)

df = cudf.read_csv(
input_data_path,
delimiter=" ",
names=["src", "dst", "value"],
dtype=["int32", "int32", "float32"],
)

df = modify_dataset(df)

acostadon marked this conversation as resolved.
Show resolved Hide resolved
g = cugraph.Graph(directed=False)
acostadon marked this conversation as resolved.
Show resolved Hide resolved
g.from_cudf_edgelist(df, "src", "dst")

dg = cugraph.Graph(directed=False)
dg.from_dask_cudf_edgelist(ddf, "src", "dst")
expected_dist = cugraph.bfs(g, [0, 1000])
result_dist = dcg.bfs(dg, [0, 1000])
result_dist = result_dist.compute()

compare_dist = expected_dist.merge(
result_dist, on="vertex", suffixes=["_local", "_dask"]
)

err = 0

for i in range(len(compare_dist)):
if (
compare_dist["distance_local"].iloc[i]
!= compare_dist["distance_dask"].iloc[i]
):
err = err + 1
assert err == 0
assert not dg.is_directed()


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
Expand Down
21 changes: 20 additions & 1 deletion python/cugraph/cugraph/tests/test_jaccard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
# Copyright (c) 2020-2022, 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
Expand Down Expand Up @@ -155,6 +155,25 @@ def test_jaccard(read_csv, gpubenchmark):
assert err == 0


def test_directed_graph_check(read_csv):
M, _ = read_csv

cu_M = cudf.DataFrame()
cu_M["src_0"] = cudf.Series(M["0"])
cu_M["dst_0"] = cudf.Series(M["1"])
cu_M["src_1"] = cu_M["src_0"] + 1000
cu_M["dst_1"] = cu_M["dst_0"] + 1000
G1 = cugraph.Graph(directed=True)
G1.from_cudf_edgelist(cu_M, source=["src_0", "src_1"],
destination=["dst_0", "dst_1"])

vertex_pair = cu_M[["src_0", "src_1", "dst_0", "dst_1"]]
vertex_pair = vertex_pair[:5]
with pytest.raises(TypeError):
acostadon marked this conversation as resolved.
Show resolved Hide resolved
df_res = cugraph.jaccard(G1, vertex_pair)
print(df_res)
acostadon marked this conversation as resolved.
Show resolved Hide resolved


def test_nx_jaccard_time(read_csv, gpubenchmark):

M, _ = read_csv
Expand Down