Пример #1
0
 public void initCitiesRandom()
 {
     // inits randomly in a square 1 on each side in the positive, positive quadrant
     for (int i=0; i<N; i++)
     {
         cities[i] = new City();
     }
 }
Пример #2
0
 protected void drawEdge(int from, int to, Graphics g,  int xOffset, int yOffset, int scale, City[] cities)
 {
     int size=8;
     Pen pen = new Pen(Color.Red);
     g.DrawLine(pen, (int) (cities[to].X * scale) + xOffset,
         (int) (cities[to].Y  * scale) + yOffset,
         (int) (cities[from].X * scale) + xOffset,
         (int) (cities[from].Y * scale) + yOffset);
     Color c;
     if (linearDisplayType)
     {
         c = getColor(tsp.getActivation(cities[to].Number, cities[to].Stop) * 256/colorRes, 256);
     }
     else
     {
         c = getColorLog(tsp.getActivation(cities[to].Number, cities[to].Stop));
     }
     Brush b = new SolidBrush(c);
     g.FillEllipse(b,
         (int) (cities[from].X * scale) + xOffset - size/2,
         (int) (cities[from].Y * scale) + yOffset - size/2,
         size, size);
 }
Пример #3
0
 public void initCitiesCircle()
 {
     // inits to a circle with diameter 1, in the positive, positive quadrant
     const double radius=0.25;
     for (int i=0; i<N; i++)
     {
         double alpha = ((double)i)/N * 2 * Math.PI;
         cities[i] = new City(radius * Math.Cos(alpha) + 0.5,
                              radius * Math.Sin(alpha) + 0.5);
     }
 }
Пример #4
0
 public double distance(City c)
 {
     return Math.Sqrt(Math.Pow(x - c.x ,2) + Math.Pow(y - c.y, 2));
 }