I Need help with Dijkstras

def modified_dijkstras(graph, start, target):
  print("Starting Dijkstra's algorithm!")
  count = 0
  paths_and_distances = {}
  for vertex in graph:
    paths_and_distances[vertex] = [inf, [start.name]]

Just trying to clarify, does paths_and_distances[vertex] = [inf, [start.name]] link every vertex to start?


It creates a dictionary called paths_and_distances whose keys are all the vertexes, and in which each value is identical: a list whose first element is inf and whose second element is a one-element list consisting of start.name.


What is the purpose of start.name?

1 Like

It’s just an initial value for the path, which will become longer as the algorithm unfolds.

1 Like