예제 #1
0
 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);
         }
     }
 }
예제 #2
0
 public bool HasNext()
 {
     return(!copy.IsEmpty());
 }