code styling: add comments and fix pep8
This commit is contained in:
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user