Join 36000+ teachers and students using TTIO.
One algorithm for finding the shortest path from a starting node to a target node in a weighted graph is Dijkstra’s algorithm. The algorithm basically creates a TREE of shortest paths from the starting vertex, the source, to all other points in the graph.
Dijkstra’s algorithm, published in 1959 and named after its creator Dutch computer scientist Edsger Dijkstra, can be applied on a weighted graph. The graph can either be directed or undirected.
Dijkstra's algorithm to find the shortest path between a and b. It picks the unvisited vertex with the lowest distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor's distance if smaller. Mark visited (set to red) when done with neighbors. (see above)
Dijkstra’s algorithm is heavily used in computer systems that need to calculate shortest paths. This includes satellite navigation systems that display the shortest or fastest route from a starting point to a chosen destination. Routers in networks often employ Dijkstra’s algorithm to find the shortest path when routing packets within networks.
www.teachyourselfpython.com