Exemplo n.º 1
0
        public void draw(TSPSolution sol, bool clear = true)
        {
            draw(sol.inp, clear);
            int j = 0, previous = 0;

            for (int i = 0; i < sol.inp.nodesCount; i++)
            {
                TSPPoint first = sol.inp.getPoint(j), second = sol.inp.getPoint(sol.getSuccessor(j, previous));
                Pen      pen = Pens.BlueViolet;
                for (int k = 0; k < sol.inp.nodesCount; k++)
                {
                    if (Edge.isCrossing(first, second, sol.inp.getPoint(k), sol.inp.getPoint(sol.getSuccessor(k))) &&
                        Edge.isCrossing(sol.inp.getPoint(k), sol.inp.getPoint(sol.getSuccessor(k)), first, second))
                    {
                        pen = Pens.Red;
                        break;
                    }
                }
                //TODO vybarvit cervene ty co se krizi - hotovo
                g.DrawLine(pen, (float)(first.x * xStretch + nodeSize / 2), (float)(first.y * yStretch + nodeSize / 2),
                           (float)(second.x * xStretch + nodeSize / 2), (float)(second.y * yStretch + nodeSize / 2));
                int pom = j;
                j        = sol.getSuccessor(j, previous);
                previous = pom;
            }
            screen.Refresh();
        }
Exemplo n.º 2
0
 public PermutationStandard(TSPSolution sol) : this(sol.inp)
 {
     perm[0] = 0;
     perm[1] = sol.getSuccessor(perm[0]);
     for (int i = 1; i < size - 1; i++)
     {
         perm[i + 1] = sol.getSuccessor(perm[i], perm[i - 1]);
     }
 }