Created
August 24, 2021 10:53
-
-
Save quantra-go-algo/bd06baec7ff72eac0be663b3a11ec5c3 to your computer and use it in GitHub Desktop.
Nodes list Dijkstra's algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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