Exemple #1
0
        private List <T> obtenerHijos(T nombre)
        {
            List <T>           hijos    = new List <T>();
            List <Arista <T> > borradas = new List <Arista <T> >();

            for (int i = 0; i < aristasMST.Count; i++)
            {
                Arista <T> arista = aristasMST[i];
                if (arista.Origen.Info.Equals(nombre) || arista.Destino.Info.Equals(nombre))
                {
                    if (arista.Origen.Info.Equals(nombre))
                    {
                        hijos.Add(arista.Destino.Info);
                    }
                    else
                    {
                        hijos.Add(arista.Origen.Info);
                    }
                    aristasMST.RemoveAt(i);
                }
            }
            //while(borradas.Count > 0)
            //{
            //    aristasMST.Remove(borradas[0]);
            //  }
            return(hijos);
        }
Exemple #2
0
 private void iniciarListaAristas()
 {
     aristas = new List <Arista <Ciudad> >();                                      //1
     for (int i = 0; i < grafo.GetLongLength(0) - 1; i++)                          //2
     {
         for (int j = i + 1; j < grafo.GetLongLength(1); j++)                      //3
         {
             Ciudad          inicio      = (Ciudad)CiuadadesGrafo[i];              //4
             Ciudad          fin         = (Ciudad)CiuadadesGrafo[j];              //5
             double          peso        = grafo[i, j];                            //6
             Arista <Ciudad> nuevaArista = new Arista <Ciudad>(inicio, fin, peso); //7
             aristas.Add(nuevaArista);                                             //8
         }
     }
 }
Exemple #3
0
 public int CompareTo(Arista <T> other)
 {
     return(distancia - other.distancia);
 }