Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Created August 24, 2021 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quantra-go-algo/bd06baec7ff72eac0be663b3a11ec5c3 to your computer and use it in GitHub Desktop.
Save quantra-go-algo/bd06baec7ff72eac0be663b3a11ec5c3 to your computer and use it in GitHub Desktop.
Nodes list Dijkstra's algorithm
A, B, C, D, E = nodes = list("ABCDE")
graph = Graph()
graph.add_edge(A, B, 6)
graph.add_edge(A, E, 10)
graph.add_edge(B, C, 1)
graph.add_edge(C, D, 1)
graph.add_edge(D, E, 4)
dijkstra = DijkstraSPF(graph, A)
print("\nShortest path:")
print(" -> ".join(dijkstra.get_path(E)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment