Skip to content

Commit

Permalink
Show explicit error message for SSSP run over a graph with no edge we…
Browse files Browse the repository at this point in the history
…ight (#2929)

Fixes #1878

Signed-off-by: wang <jiede.wl@alibaba-inc.com>
  • Loading branch information
doudoubobo committed Jun 27, 2023
1 parent 50c7a1e commit ae8d96c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/graphscope/analytical/app/sssp.py
Expand Up @@ -19,6 +19,8 @@
from graphscope.framework.app import AppAssets
from graphscope.framework.app import not_compatible_for
from graphscope.framework.app import project_to_simple
from graphscope.framework.graph import GraphDAGNode
from graphscope.proto import graph_def_pb2

__all__ = [
"sssp",
Expand Down Expand Up @@ -59,4 +61,15 @@ def sssp(graph, src=0, weight=None):
>>> c = graphscope.sssp(pg, src=6)
>>> sess.close()
"""
if not isinstance(graph, GraphDAGNode):
if graph.schema.edata_type == graph_def_pb2.NULLVALUE:
raise RuntimeError(
"The edge data is empty, and the edge data type should be integers or "
"floating point numbers to run SSSP. Suggest to use bfs() algorithm."
)
if graph.schema.edata_type == graph_def_pb2.STRING:
raise RuntimeError(
"The edge data type is string, and the edge data type should be "
"integers or floating point numbers to run SSSP."
)
return AppAssets(algo="sssp", context="vertex_data")(graph, src)

0 comments on commit ae8d96c

Please sign in to comment.