Example #1
0
        public ResultCollection GetResult()
        {
            ResultCollection ret = new ResultCollection();

            this.FindShortestPath();
            resultPath      = GetPath();
            ret.distanceMap = this.distanceMap;
            int[,] retMap   = Consts.Init2dArray <int>(size, 0);
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    if (map[i, j] == 1)
                    {
                        retMap[i, j] = 1;
                    }
                    if (map[i, j] == 2)
                    {
                        retMap[i, j] = 2;
                    }
                    if (map[i, j] == 3)
                    {
                        retMap[i, j] = 3;
                    }
                    if (map[i, j] == 0 && visited[i, j])
                    {
                        retMap[i, j] = 5;
                    }
                }
            }
            for (int i = 0; i < resultPath.Count; i++)
            {
                IntDouble p = resultPath[i];
                if (retMap[p.X, p.Y] == 5)
                {
                    retMap[p.X, p.Y] = 4;
                }
            }
            ret.resultMap = retMap;
            ret.inputMap  = map;
            int[,] parent = Consts.Init2dArray <int>(size, -1);
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    IntDouble parentDir = prev[i, j];
                    if (parentDir.X != -1 && parentDir.Y != -1)
                    {
                        int index = Consts.OffsetToIndex[parentDir.X - i + 1, parentDir.Y - j + 1];
                        parent[i, j] = index;
                    }
                    else
                    {
                        parent[i, j] = -1;
                    }
                }
            }
            ret.parentMap = parent;
            return(ret);
        }
Example #2
0
 public DijkstraProcessor(int[,] map, int size)
 {
     this.map           = map;
     this.size          = size;
     this.tempList      = new List <IntDouble>();
     this.tempArray     = new IntDouble[8];
     this.resultPath    = new List <IntDouble>();
     this.start         = GetStartPos();
     this.end           = GetEndPos();
     this.prev          = Consts.Init2dArray <IntDouble>(size, new IntDouble(-1, -1));
     this.flagMap_Close = Consts.Init2dArray <bool>(size, false);
     this.distanceMap   = Consts.Init2dArray <int>(size, int.MaxValue);
     this.set_Open      = new DijkstraSet_Heap(size * size, distanceMap);
     this.visited       = Consts.Init2dArray <bool>(size, false);
 }
Example #3
0
 private int[,] setIndexMap;// stores the index to heapArray for each vertexIndex, -1 if not exist
 public DijkstraSet_Heap(int maxsize, int[,] values)
 {
     this.heapArray   = new List <IntDouble>();
     this.values      = values;
     this.setIndexMap = Consts.Init2dArray <int>(maxsize, -1);
 }
Example #4
0
 private int GetH(IntDouble p)
 {
     return(Consts.GetEvaDistance_Euro(p.X, p.Y, end.X, end.Y));
 }