if not unvisited:
    break
candidates = [node for node in list(unvisited.items()) if node[1]]
current, currentDistance = sorted(candidates, key=lambda x: x[1])[0]
print(visited)
Dijkstra's algorithm in python