let' verify this table with our graph from the graphwe know that the shortest distance from to is we will need to go through to get to node according to the tablethe shortest distance from the source column for node is the value this is true it is also tells us that to get to node fwe need to visit node eand from enode awhich is our starting node this is actually the shortest path we begin the program for finding the shortest distance by representing the table that enables us to track the changes in our graph for the given diagram we usedhere is dictionary representation of the tabletable dict(table ' '[ none]' '[float("inf")none]' '[float("inf")none]' '[float("inf")none]' '[float("inf")none]' '[float("inf")none]the initial state of the table uses float("inf"to represent infinity each key in the dictionary maps to list at the first index of the list is stored the shortest distance from the source at the second index is the stored the previous nodedistance previous_node infinity float('inf'to avoid the use of magic numberswe use the preceding constants the shortest path column' index is referenced by distance the previous node column' index is referenced by previous_node now all is set for the main function it will take the graphrepresented by the adjacency listthe tableand the starting node as parametersdef find_shortest_path(graphtableorigin)visited_nodes [current_node origin starting_node origin we keep the list of visited nodes in the listvisited_nodes the current_node and starting_node variables will both point to the node in the graph we choose to make our starting node the origin value is the reference point for all other nodes with respect to finding the shortest path