the statement set(adjacent_nodesdifference(set(visited_nodes)returns the nodes that have not been visited the loop iterates over this list of unvisited nodesdistance_from_starting_node get_shortest_distance(tablevertexthe helper method get_shortest_distance(tablevertexwill return the value stored in the shortest distance column of our table using one of the unvisited nodes referenced by vertexif distance_from_starting_node =infinity and current_node =starting_nodetotal_distance get_distance(graphvertexcurrent_nodewhen we are examining the adjacent nodes of the starting nodedistance_from_starting_node =infinity and current_node =starting_node will evaluate to truein which case we only have to get the distance between the starting node and vertex by referencing the graphtotal_distance get_distance(graphvertexcurrent_nodethe get_distance method is another helper method we use to obtain the value (distanceof the edge between vertex and current_node if the condition failsthen we assign total_distance the sum of the distance from the starting node to current_node and the distance between current_node and vertex once we have our total distancewe need to check whether this total_distance is less than the existing data in the shortest distance column in our table if it is lessthen we use the two helper methods to update that rowif total_distance distance_from_starting_nodeset_shortest_distance(tablevertextotal_distanceset_previous_node(tablevertexcurrent_nodeat this pointwe add the current_node to the list of visited nodesvisited_nodes append(current_nodeif all nodes have been visitedthen we must exit the while loop to check whether all the nodes have been visitedwe compare the length of the visited_nodes list to the number of keys in our table if they have become equalwe simply exit the while loop the helper methodget_next_nodeis used to fetch the next node to visit it is this method that helps us find the minimum value in the shortest distance column from the starting nodes using our table