Пример #1
0
        bool isContain(entities.Point point)
        {
            foreach (var item in lstPoint)
            {
                if (item.x == point.x && item.y == point.y)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        void InitData()
        {
            for (int i = 0; i < this.soDinh; i++)
            {
                do
                {
                    int            x     = rnd.Next(-MAX_POSITION, MAX_POSITION);
                    int            y     = rnd.Next(-MAX_POSITION, MAX_POSITION);
                    entities.Point point = new entities.Point {
                        x = x, y = y
                    };
                    if (!isContain(point))
                    {
                        lstPoint.Add(point);
                        break;
                    }
                } while (true);
            }

            for (int i = 0; i < this.soDinh; i++)
            {
                for (int j = 0; j < this.soDinh; j++)
                {
                    this.distance[i, j] = this.VOCUNG;
                }

                this.distance[i, i] = 0;
            }

            for (int i = 0; i < this.soCanh; i++)
            {
                int s;
                int e;
                do
                {
                    s = rnd.Next(0, this.soDinh - 1);
                    e = rnd.Next(0, this.soDinh - 1);
                    if (s == e || this.distance[s, e] != this.VOCUNG || (s == this.start && e == this.end))
                    {
                        continue;
                    }

                    this.distance[s, e] = entities.Point.Distance(lstPoint[s], lstPoint[e]);
                    break;
                } while (true);
            }
        }