Beispiel #1
0
        public PrimMST(EdgeWeightedGraph G)
        {
            edgeTo = new Edge[G.GetVertices()];
            distTo = new double[G.GetVertices()];
            marked = new bool[G.GetVertices()];
            Comparer <double> comparer = Comparer <double> .Default;

            pq = new IndexMinPQ <double>(G.GetVertices(), comparer);
            for (int v = 0; v < G.GetVertices(); v++)
            {
                distTo[v] = Double.PositiveInfinity;
            }
        }
Beispiel #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]);
                }
            }