@@ -23,8 +23,8 @@ def add_edge(self, u, v, w) -> None:
23
23
24
24
# perform a dijkstra algorithm on a directed graph
25
25
def dijkstra (self , s ) -> dict :
26
- distances = {vertex : sys .maxsize - 1 for vertex in self .graph }
27
- pq = [(0 ,s )]
26
+ distances = {vertex : sys .maxsize - 1 for vertex in self .graph }
27
+ pq = [(0 , s )]
28
28
distances [s ] = 0
29
29
while pq :
30
30
weight , v = heapq .heappop (pq )
@@ -38,9 +38,9 @@ def dijkstra(self, s) -> dict:
38
38
heapq .heappush (pq , (distances [node ], node ))
39
39
return distances
40
40
41
- #carry out the bellman ford algorithm for a node and estimate its distance vector
42
- def bellman_ford (self , s ) -> dict :
43
- distances = {vertex : sys .maxsize - 1 for vertex in self .graph }
41
+ # carry out the bellman ford algorithm for a node and estimate its distance vector
42
+ def bellman_ford (self , s ) -> dict :
43
+ distances = {vertex : sys .maxsize - 1 for vertex in self .graph }
44
44
distances [s ] = 0
45
45
46
46
for u in self .graph :
@@ -52,7 +52,7 @@ def bellman_ford(self, s) -> dict:
52
52
53
53
# perform the johnson algorithm to handle the negative weights that
54
54
# could not be handled by either the dijkstra
55
- #or the bellman ford algorithm efficiently
55
+ # or the bellman ford algorithm efficiently
56
56
def johnson_algo (self ) -> dict :
57
57
self .add_vertices ("#" )
58
58
for v in self .graph :
0 commit comments