Skip to content

Commit e76d0db

Browse files
committed
Fix algorithm
1 parent 6aa9831 commit e76d0db

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/code/python/graph/prim.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ def prim_mst(n: int, edges: list[tuple[int, int, int]]) -> list[tuple[int, int,
66
uf = UnionFind(n)
77
edges.sort()
88

9-
pq = [(w, u, v) for w, u, v in edges]
10-
11-
while pq:
12-
w, u, v = heappop(pq)
9+
while edges:
10+
w, u, v = heappop(edges)
1311

1412
if not uf.connected(u, v):
1513
uf.union(u, v)

0 commit comments

Comments
 (0)