Both Ends Already In
Lazy Prim. scan(v) marks v and pushes every edge from v whose other endpoint is unmarked.
scan(A);
while (!pq.isEmpty()) {
Edge e = pq.delMin();
int v = e.either(), w = e.other(v);
mst.add(e);
weight += e.weight();
if (!marked[v]) scan(v);
if (!marked[w]) scan(w);
}
Run it on the triangle A-B 1, A-C 2, B-C 3. The correct MST is 2 edges of total weight 3. What does this report?
Sign in to answer questions and track your progress
Sign In