diff --git a/algorithms/graphs/prim.cpp b/algorithms/graphs/prim.cpp index b07e36d4..3d4752a3 100644 --- a/algorithms/graphs/prim.cpp +++ b/algorithms/graphs/prim.cpp @@ -14,7 +14,7 @@ ll prim(vi s = vi(1, 0)) { } ll mstcost = 0; - while (ingraphcnt < N) { + while (ingraphcnt < N and !pq.empty()) { ll w; int v;