コード例 #1
0
 public void RP_RPA(CNodoVertice cnv)
 {
     cnv.getVertice().setVisitado(true);
     foreach (CNodoVertice w in cnv.getRelaciones())
     {
         if (w.getVertice().getVisitado() != true)
         {
             RP_RPA(w);
         }
     }
     cnv.getVertice().setBajo(minimo(cnv.getVertice().getNumero(), getZde(cnv), getYde(cnv)));
 }
コード例 #2
0
        } //Construye la matriz a partir de la lista de adyacencia del grafo

        public bool estaEnListaRelaciones(CNodoVertice nodo, CNodoVertice relacion)
        {
            bool encontrado = false;

            foreach (CNodoVertice cnv in nodo.getRelaciones())
            {
                if (relacion.getVertice().getId() == cnv.getVertice().getId())
                {
                    encontrado = true;
                    break;
                }
            }
            return(encontrado);
        } //Verifica que existe relacion en lista de adyacencia
コード例 #3
0
 public void RP_R(CNodoVertice cnv, ref int ndes)
 {
     cnv.getVertice().setVisitado(true);
     cnv.getVertice().setNumero(++num);
     foreach (CNodoVertice w in cnv.getRelaciones())
     {
         if (w.getVertice().getVisitado() != true)
         {
             int nd = 0;
             RP_R(w, ref nd);
             descendientes[G.getListaAdyacencia().IndexOf(w)] = nd;
             ndes += nd + 1;
             enlistaArcosArbol(cnv.getVertice(), w.getVertice());
         }
     }
 }
コード例 #4
0
        public void CF_R(CNodoVertice cnv, ref List <int> ar, int vuelta)
        {
            cnv.getVertice().setVisitado(true);

            foreach (CNodoVertice w in cnv.getRelaciones())
            {
                if (w.getVertice().getVisitado() != true)
                {
                    ar.Add(w.getVertice().getId());
                    CF_R(w, ref ar, vuelta);
                }
            }

            if (vuelta == 1)
            {
                cnv.getVertice().setNumero(++num);
            }
            else
            {
                cnv.getVertice().setNumero(++num2);
            }
        }
コード例 #5
0
        //Recorrido en Amplitud
        public void recorridoEnAmplitud(CNodoVertice vert_ini)
        {
            vert_ini.getVertice().setVisitado(true);
            List <CNodoVertice> Vp = construyeLAdyPrima(G.getListaAdyacencia(), vert_ini);
            List <CNodoVertice> Q  = new List <CNodoVertice>();

            Q.Add(vert_ini);

            while (Vp.Count != 0)
            {
                CNodoVertice u = Q[0];
                Q.RemoveAt(0);
                foreach (CNodoVertice w in u.getRelaciones())
                {
                    if (!w.getVertice().getVisitado())
                    {
                        w.getVertice().setVisitado(true);
                        Q.Add(w);
                        enlistaArcosArbol(u.getVertice(), w.getVertice());
                        Vp.Remove(w);
                    }
                }
            }
        }