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
properly catch exceptions in Dijkstra_Boost #29781
Labels
Milestone
Comments
comment:1
The diff, ignoring whitespace change, is just --- a/src/sage/graphs/base/boost_graph.pyx
+++ b/src/sage/graphs/base/boost_graph.pyx
@@ -977,6 +977,7 @@ cpdef shortest_paths(g, start, weight_function=None, algorithm=None):
raise ValueError("the graph contains a negative cycle")
elif algorithm in ['Dijkstra', 'Dijkstra_Boost']:
+ try:
if g.is_directed():
boost_weighted_graph_from_sage_graph(&g_boost_dir, g, v_to_int, weight_function)
vi = v_to_int[start]
@@ -991,6 +992,8 @@ cpdef shortest_paths(g, start, weight_function=None, algorithm=None):
sig_off()
if not result.distances.size():
raise RuntimeError("Dijkstra algorithm does not work with negative weights, use Bellman-Ford instead")
+ except RuntimeError:
+ raise RuntimeError("Dijkstra algorithm does not work with negative weights, use Bellman-Ford instead")
else:
raise ValueError(f"unknown algorithm {algorithm!r}") |
comment:2
LGTM. I added a note in #29657 since the usage of weights must be strengthen in |
Reviewer: David Coudert |
comment:3
LGTM |
Changed branch from u/dimpase/graphs/dijkstraboost to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
with a recent Boost (1.73 on Gentoo) I see doctest errors like
we fix these by using proper try/catch block.
CC: @dcoudert @antonio-rojas @kiwifb
Component: graph theory
Author: Dima Pasechnik
Branch/Commit:
746982b
Reviewer: David Coudert
Issue created by migration from https://trac.sagemath.org/ticket/29781
The text was updated successfully, but these errors were encountered: