consider the following graphby inspectionthe first answer to the question of finding the shortest path between node and node that comes to mind is the edge with value or distance from the diagramit would seem that the straight path from node to would also yield the shortest route between the two nodes but the assumption that the edge connecting the two nodes is the shortest route does not always hold true this shortsighted approach of selecting the first option when solving problem is what gives the algorithm its name and class having found the supposed shortest route or distancethe algorithm continues to refine and improve its results other paths from node to node prove to be shorter than our initial pick for instancetravelling from node to node to node will incur total distance of but the route through node to efand is even shorter we will implement the shortest path algorithm with single source our result should help us determine the shortest path from the originwhich in this case is ato any other node in the graph the shortest path from node to node is through node likewisethe shortest path to is through node with total distance of in order to come up with an algorithm to help us find the shortest path in graphlet' solve the problem by hand thereafterwe will present the working solution in python in the on graphswe saw how we could represent graph with an adjacency list we will use it with slight modification to enable us capture the distance on every edge table will be used to also keep track of the shortest distance from the source in the graph to any other node python dictionary will be used to implement this table here is one such table