Beispiel #1
0
        public Search_AStar(SparseGraph <TNode, TEdge> Graph, IHeuristic <SparseGraph <TNode, TEdge> > Heuristic, int Source, int Target)
        {
            this.Graph     = Graph;
            this.bFound    = false;
            this.Heuristic = Heuristic;

            SourceNodeIndex = Source;
            TargetNodeIndex = Target;

            int ActiveNodeCount = Graph.ActiveNodeCount();
            int NodeCount       = Graph.NodeCount();

            ShortestPathTree = new List <TEdge>(NodeCount);
            SearchFrontier   = new List <TEdge>(NodeCount);
            CostToThisNode   = new List <double>(NodeCount);
            GCosts           = new List <double>(NodeCount);
            FCosts           = new List <double>(NodeCount);

            // not sure i need to initialize these...nt);
            for (int i = 0; i < NodeCount; i++)
            {
                ShortestPathTree.Insert(i, null);
                SearchFrontier.Insert(i, null);
                CostToThisNode.Insert(i, 0);
                FCosts.Insert(i, 0);
                GCosts.Insert(i, 0);
            }

            TimeSlicedQ = new IndexedPriorityQueueLow <double>(FCosts, Graph.NodeCount());
            TimeSlicedQ.Insert(SourceNodeIndex);
        }
Beispiel #2
0
        public GraphSearchDijkstra(SparseGraph <GraphNode, GraphEdge> Graph, int Source, int Target)
        {
            this.Graph  = Graph;
            this.bFound = false;

            SourceNodeIndex = Source;
            TargetNodeIndex = Target;

            int ActiveNodeCount = Graph.ActiveNodeCount();
            int NodeCount       = Graph.NodeCount();

            ShortestPathTree = new List <GraphEdge>(NodeCount);
            SearchFrontier   = new List <GraphEdge>(NodeCount);
            CostToThisNode   = new List <double>(ActiveNodeCount);

            for (int i = 0; i < NodeCount; i++)
            {
                ShortestPathTree.Insert(i, null);
                SearchFrontier.Insert(i, null);
                CostToThisNode.Insert(i, 0);
            }
        }