private void Prim(EdgeWeightedGraph G, int s) { Scan(G, s); while (!pq.IsEmpty()) { Edge e = pq.DelMin(); int v = e.Either(); int w = e.Other(v); Debug.Assert(marked[v] || marked[w]); if (marked[v] && marked[w]) { continue; } mst.Enqueue(e); weight += e.GetWeight(); if (!marked[v]) { Scan(G, v); } if (!marked[v]) { Scan(G, v); } } }
public bool HasNext() { return(!copy.IsEmpty()); }