import heapq def dijkstra(u): # 시작 셋팅 D[u] = 0 q = [] heapq.heappush(q, (D[u],u)) # 정점 갯수 만큼 반복 for i in range(V): # 가중치 최솟값 찾기 min_v = 987654321 now, u = heapq.heappop(q) # 방문 처리 visit[u] = 1 # 인접한 정점 업데이터 for v in range(V): if adj[u][v] != 0 and visit[v] == 0 and D[v] > D[u] + adj[u][v]: D[v] = D[u] + adj[u][v] heapq.heappush(q, (D[v],v)) #######################################################..