コード例 #1
0
ファイル: Form1.cs プロジェクト: hugomes/AG-TSP
        private void PlotLines(Population pop, Color color)
        {
            Pen penBest = new Pen(color, 4);
            int genA, genB;

            Individual best = pop.GetBest();

            for (int i = 0; i < ConfigurationGA.SizeChromosome; i++)
            {
                if (i < ConfigurationGA.SizeChromosome - 1)
                {
                    genA = best.GetGene(i);
                    genB = best.GetGene(i + 1);
                }
                else
                {
                    genA = best.GetGene(i);
                    genB = best.GetGene(0);
                }

                int[] vetA = TablePoints.GetCoordinates(genA);
                int[] vetB = TablePoints.GetCoordinates(genB);

                G.DrawLine(penBest, vetA[0], vetA[1], vetB[0], vetB[1]);
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: hugomes/AG-TSP
 private void PlotPoints()
 {
     //verificando se tem pontos na tabela
     if (TablePoints.PointCount > 0)
     {
         for (int i = 0; i < TablePoints.PointCount; i++)
         {
             Pen blackPen = new Pen(Color.Red, 3);
             //vetor de coordenadas
             int[]     coo  = TablePoints.GetCoordinates(i);
             Rectangle rect = new Rectangle(coo[0] - 5, coo[1] - 5, 10, 10);
             G.DrawEllipse(blackPen, rect);
             G.DrawString((i + 1).ToString(), new Font("Arial Black", 11), Brushes.Black, coo[0] + 3, coo[1]);
             G.DrawString("X: " + coo[0].ToString(), new Font("Arial Black", 6), Brushes.Black, coo[0] - 20, coo[1] - 25);
             G.DrawString("Y: " + coo[1].ToString(), new Font("Arial Black", 6), Brushes.Black, coo[0] - 20, coo[1] - 18);
         }
     }
 }