From 04625297fd84c8c89012d22cfdf8e2af4eaea94f Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Sat, 28 Sep 2024 08:35:07 -0700 Subject: [PATCH] update error reporting --- .../simpleDistributedGraph.py | 35 +++++++++++------- .../graph_implementation/simpleGraph.py | 37 +++++++++++-------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py b/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py index a501ca94cc9..c539c3e975f 100644 --- a/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py +++ b/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py @@ -191,22 +191,29 @@ def __from_edgelist( "The edgelist can only be symmetrized for undirected graphs." ) - if symmetrize or symmetrize is None: - unsupported = False - if edge_id is not None or edge_type is not None: - unsupported = True - if isinstance(edge_attr, list): - if len(edge_attr) > 1: - unsupported = True - if unsupported: + if self.properties.directed: + if symmetrize: raise ValueError( - "Edge list containing Edge Ids or Types can't be symmetrized. " - "If the edges are already symmetric, set the 'symmetrize' " - "flag to False" + "The edgelist can only be symmetrized for undirected graphs." ) - if symmetrize is None: - # default behavior - symmetrize = not self.properties.directed + else: + if symmetrize or symmetrize is None: + unsupported = False + if edge_id is not None or edge_type is not None: + unsupported = True + if isinstance(edge_attr, list): + if len(edge_attr) > 1: + unsupported = True + if unsupported: + raise ValueError( + "Edge list containing Edge Ids or Types can't be symmetrized. " + "If the edges are already symmetric, set the 'symmetrize' " + "flag to False" + ) + + if symmetrize is None: + # default behavior + symmetrize = not self.properties.directed s_col = source d_col = destination diff --git a/python/cugraph/cugraph/structure/graph_implementation/simpleGraph.py b/python/cugraph/cugraph/structure/graph_implementation/simpleGraph.py index 05168d2cbf5..053083b3852 100644 --- a/python/cugraph/cugraph/structure/graph_implementation/simpleGraph.py +++ b/python/cugraph/cugraph/structure/graph_implementation/simpleGraph.py @@ -148,23 +148,30 @@ def __from_edgelist( raise ValueError( "The edgelist can only be symmetrized for undirected graphs." ) - - if symmetrize or symmetrize is None: - unsupported = False - if edge_id is not None or edge_type is not None: - unsupported = True - if isinstance(edge_attr, list): - if len(edge_attr) > 1: - unsupported = True - if unsupported: + + if self.properties.directed: + if symmetrize: raise ValueError( - "Edge list containing Edge Ids or Types can't be symmetrized. " - "If the edges are already symmetric, set the 'symmetrize' " - "flag to False" + "The edgelist can only be symmetrized for undirected graphs." ) - if symmetrize is None: - # default behavior - symmetrize = not self.properties.directed + else: + if symmetrize or symmetrize is None: + unsupported = False + if edge_id is not None or edge_type is not None: + unsupported = True + if isinstance(edge_attr, list): + if len(edge_attr) > 1: + unsupported = True + if unsupported: + raise ValueError( + "Edge list containing Edge Ids or Types can't be symmetrized. " + "If the edges are already symmetric, set the 'symmetrize' " + "flag to False" + ) + + if symmetrize is None: + # default behavior + symmetrize = not self.properties.directed # Verify column names present in input DataFrame s_col = source