Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
better code
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat1433 committed Mar 14, 2019
1 parent f0f203d commit f98ba96
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sage/graphs/base/c_graph.pyx
Expand Up @@ -2247,9 +2247,12 @@ cdef class CGraphBackend(GenericGraphBackend):
if w not in dist_current:
v_obj = self.vertex_label(v)
w_obj = self.vertex_label(w)
edge_label = weight_function((v_obj, w_obj, self.get_edge_label(v_obj, w_obj))) if side == 1 else weight_function((w_obj, v_obj, self.get_edge_label(w_obj, v_obj)))
if type(edge_label) == list:
edge_label = min(edge_label)
if side == -1:
v_obj, w_obj = w_obj, v_obj
if self._multiple_edges:
edge_label = min(weight_function((v_obj, w_obj, l)) for l in self.get_edge_label(v_obj, w_obj))
else:
edge_label = weight_function((v_obj, w_obj, self.get_edge_label(v_obj, w_obj)))
if edge_label < 0:
raise ValueError("the graph contains an edge with negative weight")
pq.push(((-(distance + edge_label), side), (v, w)))
Expand Down

0 comments on commit f98ba96

Please sign in to comment.