[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-10-25 16:01:29 +00:00
parent da0717b9ae
commit 18319a8733

View File

@ -2,6 +2,7 @@ from collections import deque
import heapq import heapq
import sys import sys
# First implementation of johnson algorithm # First implementation of johnson algorithm
class JohnsonGraph: class JohnsonGraph:
def __init__(self): def __init__(self):
@ -52,7 +53,6 @@ class JohnsonGraph:
# perform the johnson algorithm to handle the negative weights that could not be handled by either the dijkstra # perform the johnson algorithm to handle the negative weights that could not be handled by either the dijkstra
# or the bellman ford algorithm efficiently # or the bellman ford algorithm efficiently
def johnson_algo(self): def johnson_algo(self):
self.add_vertices("#") self.add_vertices("#")
for v in self.graph: for v in self.graph:
if v != "#": if v != "#":
@ -79,6 +79,7 @@ class JohnsonGraph:
distances.append(new_dist) distances.append(new_dist)
return distances return distances
g = JohnsonGraph() g = JohnsonGraph()
# this a complete connected graph # this a complete connected graph
g.add_vertices("A") g.add_vertices("A")