Exemplo n.º 1
0
 // run Prim's algorithm in graph G, starting from vertex s
 private void Prim(EdgeWeightedGraph G, int s)
 {
     distTo[s] = 0.0;
     pq.Insert(s, distTo[s]);
     while (!pq.IsEmpty())
     {
         pq.DelMin(out int v, out double dist);
         Scan(G, v);
     }
 }
Exemplo n.º 2
0
            public HeapIterator(Comparer <Key> Comparer, int Size, int N, int[] indexes, Key[] keys)
            {
                this.Comparer = Comparer;
                this.Size     = Size;
                this.N        = N;
                this.Keys     = keys;

                if (Comparer == null)
                {
                    copy = new IndexMinPQ <Key>(Size, Comparer);
                }
                else
                {
                    copy = new IndexMinPQ <Key>(Size, Comparer);
                }
                for (int i = 0; i <= N; i++)
                {
                    copy.Insert(indexes[i], this.Keys[i]);
                }
            }