Given a weighted graph and a designated vertex X, we will often need to find the path from X to each of the other vertices in the graph. Identifying a path connecting two or more nodes of a graph appears as a sub problem of many other problems of discrete optimization and has, in addition, numerous applications in the real world.
Finding the shortest path
Getting ready
In this recipe, we will find the shortest path between two points using the Dijkstra algorithm. We will also use the networkx package to represent graphs in Python.
How to do it...
Let's see how we...