Exemplo n.º 1
0
        void visit(DoThi g, int i, int index)
        {
            int[] q       = new int[100];
            int   q_index = 0;
            int   q_count = 1;

            q[0]       = i;
            visited[i] = index;
            while (q_index < q_count)
            {
                int x = q[q_index];
                q_index++;
                //	cout << g.iMaTran[1][2] << endl;
                //cout << i <<endl;
                for (int j = 0; j < g.iSoDinh; j++)
                {
                    if ((visited[j] == 0) && (g.iMaTran[x, j] != int.MinValue))
                    {
                        //cout << j <<endl;
                        q[q_count] = j;
                        q_count++;
                        visited[j] = index;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public bool KiemTraDonDoThiDonVoHuong(DoThi dt)
 {
     if (kiemTraMaTranKeVoHuong(dt) == true && kiemTraMaTranKeVoHuongHopLe(dt) == true)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 public bool xetLienThong(DoThi g)
 {
     LienThong(g);
     if (nSoMienLienThong == 1)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 bool kiemTraMaTranKeVoHuongHopLe(DoThi dt)
 {
     for (int i = 0; i < dt.iSodinh; i++)
     {
         if (dt.iMaTran[i, i] != int.MinValue)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 5
0
 bool kiemTraMaTranKeVoHuong(DoThi dt)
 {
     for (int i = 0; i < dt.iSodinh; i++)
     {
         for (int j = i + 1; j < dt.iSodinh; j++)
         {
             if (dt.iMaTran[i, j] != dt.iMaTran[j, i])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 6
0
 private void HienThiDoThi()
 {
     try
     {
         DoThi dt = listDoThi[index];
         panelMain.Controls.Clear();
         FrmVeDoThi ve = new FrmVeDoThi(dt);
         ve.TopLevel = false;
         ve.Dock     = DockStyle.Fill;
         panelMain.Controls.Add(ve);
         ve.Show();
         //if (index == listDoThi.Count - 1) timer.Stop();
     }
     catch
     {
     }
 }
Exemplo n.º 7
0
 void LienThong(DoThi g)
 {
     for (int i = 0; i < g.iSoDinh; i++)
     {
         visited[i] = 0;
     }
     nSoMienLienThong = 0;
     for (int i = 0; i < g.iSoDinh; i++)
     {
         if (visited[i] == 0)
         {
             //	cout << i << endl;
             nSoMienLienThong++;
             visit(g, i, nSoMienLienThong);
         }
     }
 }
Exemplo n.º 8
0
 public string[] xuatMienLienThong(DoThi g)
 {
     LienThong(g);
     string[] thanhphanlienthong = new string[nSoMienLienThong + 1];
     //thanhphanlienthong[0] = nSoMienLienThong.ToString();
     for (int i = 1; i <= nSoMienLienThong; i++)
     {
         //cout << "Mien lien thong thu " << i << ": ";
         thanhphanlienthong[0] = nSoMienLienThong.ToString();
         for (int j = 0; j < g.iSoDinh; j++)
         {
             if (visited[j] == i)
             {
                 thanhphanlienthong[i] += j.ToString() + " ";
             }
         }
     }
     return(thanhphanlienthong);
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            List <Point> points = TspFileReader.ReadTspFile(@"C:\Users\QuocVinh\Downloads\Compressed\asc\asc\test\demo.tsp");

            DoThi           dothi                      = new DoThi(points, true);
            GreedyAlgorithm greedyAlgorithm            = new GreedyAlgorithm(dothi);
            double          greedyShortestTourDistance = greedyAlgorithm.Run();

            Parameters parameters = new Parameters()
            {
                T0 = (1.0 / (dothi.Dimensions * greedyShortestTourDistance))
            };

            parameters.Show();

            Solver        solver  = new Solver(parameters, dothi);
            List <double> results = solver.RunACS();

            Console.ReadLine();
        }
Exemplo n.º 10
0
 public FrmVeDoThi(DoThi dt)
 {
     InitializeComponent();
     dothi = dt;
 }