Skip to content

Commit b8c6bea

Browse files
committed
Merge branch 'joel_graph' of https://github.com/joelkurien/Python into joel_graph
2 parents f80afa3 + 4982ff0 commit b8c6bea

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

graphs/johnson_graph.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def add_edge(self, u, v, w) -> None:
2323

2424
# perform a dijkstra algorithm on a directed graph
2525
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)]
2828
distances[s] = 0
2929
while pq:
3030
weight, v = heapq.heappop(pq)
@@ -38,9 +38,9 @@ def dijkstra(self, s) -> dict:
3838
heapq.heappush(pq, (distances[node], node))
3939
return distances
4040

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}
4444
distances[s] = 0
4545

4646
for u in self.graph:
@@ -52,7 +52,7 @@ def bellman_ford(self, s) -> dict:
5252

5353
# perform the johnson algorithm to handle the negative weights that
5454
# could not be handled by either the dijkstra
55-
#or the bellman ford algorithm efficiently
55+
# or the bellman ford algorithm efficiently
5656
def johnson_algo(self) -> dict:
5757
self.add_vertices("#")
5858
for v in self.graph:

0 commit comments

Comments
 (0)