code styling: add comments and fix pep8

This commit is contained in:
Marco Thomas
2022-07-27 17:58:29 +02:00
parent 68885ff560
commit 8a0a59c222
4 changed files with 49 additions and 12 deletions

View File

@@ -12,7 +12,9 @@ class Dijkstra():
self.graph = graph
self.table = {}
for vertex in graph:
self.table.update({vertex: {"distance": (9999999, 999999), "prev": None}})
self.table.update({vertex: {
"distance": (9999999, 999999),
"prev": None}})
self.table[connection[0]]["distance"] = (0, 0)
def algorithm(self, switch: str):
@@ -21,6 +23,7 @@ class Dijkstra():
print("Performing Dijkstra on the following graph...")
for vertex in self.graph:
print(f"{vertex}: {self.graph[vertex]}")
print("")
for v1 in self.graph.keys():
neighbors = self.graph[v1]
@@ -41,7 +44,7 @@ class Dijkstra():
self.table[key]["distance"] = (time, co2)
self.table[key]["prev"] = v1
print("self.table:", self.table)
print("Final Dijkstra table:", self.table)
def print_result(self, connection: tuple):
sequence = []