Exemplo n.º 1
0
        public Dijstra(GridWorld G, int s)
        {
            world  = G;
            this.s = s;
            int V = G.VertexCount;

            marked = new bool[V];
            edgeTo = new DirectedWeightedEdge[V];
            cost   = new double[V];

            for (var i = 0; i < V; ++i)
            {
                cost[i] = double.MaxValue;
            }

            cost[s] = 0;

            pq = new IndexMinPQ <double>(V);


            pq.Insert(s, 0);

            while (!pq.IsEmpty)
            {
                var v = pq.DelMin();
                marked[v] = true;
                foreach (var e in G.Adj(v))
                {
                    Relax(G, e);
                }
            }
        }
Exemplo n.º 2
0
 public bool MoveNext()
 {
     if (current.IsEmpty)
     {
         return(false);
     }
     value = current.MinKey();
     current.DelMin();
     return(true);
 }