Beispiel #1
0
        public List <Viajero> cargarViajerosInsercion(DataGridView tabla, ProgressBar barra, Label etiqueta, String ruta, int nlinea)
        {
            int nlin = 0;
            int nfin = nlinea + paginas[paginas.Count - 1].NlineaFinal;

            RutaViajeros = ruta;
            string       line;
            StreamReader file = new StreamReader(RutaViajeros);

            while ((line = file.ReadLine()) != null)
            {
                if (nlin == nlinea)
                {
                    for (int i = nlin; i < nfin && line != null; i++)
                    {
                        string[] datos    = line.Split('\t');
                        Viajero  v        = new Viajero(datos[0], datos[2] + " " + datos[1]);
                        string[] ciudades = datos[3].Split(',');
                        for (int j = 0; j < ciudades.Length; j++)
                        {
                            Ciudad c = buscarCiudad(ciudades[j].Split('_')[1]);

                            if (c != null)
                            {
                                v.agregarCiudad(c);
                            }
                        }
                        if (v.Grafo.Vertices.Count > 0)
                        {
                            viajerosSolucionInsercion.Add(v);
                            v.generarSolucionInsercion();
                        }
                        tabla.Invoke((MethodInvoker) delegate
                        {
                            tabla.Rows.Add(v.Codigo, v.Nombre);
                            tabla.Rows[tabla.Rows.Count - 1].Selected = true;
                            tabla.CurrentCell = tabla.Rows[tabla.Rows.Count - 1].Cells[0];
                        });
                        int porcentaje = (i * 100) / nfin;
                        barra.Invoke((MethodInvoker) delegate
                        {
                            barra.Value = porcentaje;
                        });
                        etiqueta.Invoke((MethodInvoker) delegate
                        {
                            etiqueta.Text = porcentaje + "%";
                        });
                        line = file.ReadLine();
                    }
                    break;
                }
                else
                {
                    nlin++;
                    continue;
                }
            }
            return(viajerosSolucionFuerzaBruta);
        }
Beispiel #2
0
 // el parametro es la forma en que lo va a solucionar, 1 es por el arbol de expansión mínima, 2 es por fuerza bruta y 3 es por otra solución.
 public List <Ciudad> solucionCiudadesFiltradas(int i)
 {
     if (i == 1)
     {
         return(viajeroAnonimo.generarSolucionKruskal());
     }
     else if (i == 2)
     {
         return(viajeroAnonimo.generarSolucionFuerzaBruta());
     }
     else
     {
         return(viajeroAnonimo.generarSolucionInsercion());
     }
 }