Hi I'm doing a dijkstra algorithm but ive ended up with an infinite loop do you know how to fix this code so it will give the length of the shortest route?
def dijkstra1(successors, other_node): """ Parameters ---------- successors : a list of dictionaries, encoding the "successors list" (seen in the lectures) other_node : index (an int) of the "target" node "t" Returns ------- L[other_node] : the shortest path length from 1 to other_node """ #store in a convenient variable (n) the number of nodes |V| in the graph n = len(successors) #initialize the set S of nodes currently reached with a shortest path S = [] S.append(0) L = dict() L[0] = 0 P = dict() P[0] = '-' #the algorithm iterates until all nodes have been reached (i.e., until len(S) = |V|) while len(S) < n: return L[other_node]