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?

https://www.codecademy.com/paths/computer-science/tracks/cspath-graph-search-algorithms/modules/cspath-advanced-graph-search-algorithms/lessons/a-star-python/exercises/a-star-python-heuristics

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.

2 Likes

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