private void BtnARMporKruskal_Click(object sender, EventArgs e)
        {
            Kruskal kruskal = new Kruskal(G);

            AristasKruskal = kruskal.getCamino();
            ArbolKruskal   = new Grafo();
            List <Vertice> listaVertices;

            listaVertices = ArbolKruskal.getLv();
            TamAristasKruskal.Items.Clear();
            foreach (Vertice v in G.getLv())
            {
                Vertice copia = new Vertice(v.getX(), v.getY(), v.getR(), v.getId());
                listaVertices.Add(copia);
            }
            foreach (Arista a in AristasKruskal)
            {
                foreach (Vertice v in listaVertices)
                {
                    if (a.getVertexOrigen().getId() == v.getId())
                    {
                        Arista copia1 = new Arista(a.getVertex(), a.getPond(), a.getVertexOrigen(), a.getLinea());
                        v.getLa().Add(copia1);
                    }
                    if (a.getVertex().getId() == v.getId())
                    {
                        Arista copia2 = new Arista(a.getVertexOrigen(), a.getPond(), a.getVertex(), a.getLinea());
                        v.getLa().Add(copia2);
                    }
                }
            }
            Double Acumulado = 0;

            foreach (Arista a in AristasKruskal)
            {
                TamAristasKruskal.Items.Add(a.getVertexOrigen().getId().ToString() + " - " + a.getVertex().getId().ToString() + " Peso: " + Math.Round(a.getPond()).ToString());
                Acumulado = Acumulado + Math.Round(a.getPond());
            }
            TamAristasKruskal.Items.Add("Peso Acumulado= " + Math.Round(Acumulado).ToString());
            Graphics graphics = Graphics.FromImage(ARM);

            pictureBox1.Image = ARM;
            Pen pluma = new Pen(Color.Purple, 10);

            foreach (Arista a in AristasKruskal)
            {
                graphics.DrawLine(pluma, a.getVertexOrigen().getX(), a.getVertexOrigen().getY(), a.getVertex().getX(), a.getVertex().getY());
            }
            pictureBox1.Refresh();
            Rectangle Rectangulo = new Rectangle(0, 0, ARM.Width, ARM.Height);

            System.Drawing.Imaging.PixelFormat Format = ARM.PixelFormat;
            copia = ARM.Clone(Rectangulo, Format);
            this.lblNumeroSubgrafos.Text  = kruskal.getSubgrafos().ToString();
            this.BtnAgenteKruskal.Enabled = true;
        }
        private void BtnARMporPrim_Click(object sender, EventArgs e)
        {
            Rectangle Dimensiones = new Rectangle(0, 0, Grafo.Width, Grafo.Height);

            System.Drawing.Imaging.PixelFormat formato = Grafo.PixelFormat;
            ARM = Grafo.Clone(Dimensiones, formato);
            TamAristasPrim.Items.Clear();
            pictureBox1.Image = Grafo;
            Vertice Elegido = null;
            int     Buscado = comboBox1.SelectedIndex + 1;

            foreach (Vertice v in G.getLv())
            {
                if (Buscado == v.getId())
                {
                    Elegido = v;
                }
            }
            Prim          prim    = new Prim(Elegido, G);
            List <Arista> Aristas = prim.getAristas();

            ArbolPrim = new Grafo();
            List <Vertice> listaVertices;

            listaVertices = ArbolPrim.getLv();
            foreach (Vertice v in G.getLv())
            {
                Vertice copia = new Vertice(v.getX(), v.getY(), v.getR(), v.getId());
                listaVertices.Add(copia);
            }
            Double Peso = 0;

            foreach (Arista a in Aristas)
            {
                foreach (Vertice v in listaVertices)
                {
                    if (a.getVertexOrigen().getId() == v.getId())
                    {
                        Arista copia1 = new Arista(a.getVertex(), a.getPond(), a.getVertexOrigen(), a.getLinea());
                        v.getLa().Add(copia1);
                    }
                    if (a.getVertex().getId() == v.getId())
                    {
                        Arista copia2 = new Arista(a.getVertexOrigen(), a.getPond(), a.getVertex(), a.getLinea());
                        v.getLa().Add(copia2);
                    }
                }
                TamAristasPrim.Items.Add(a.getVertexOrigen().getId().ToString() + " - " + a.getVertex().getId().ToString() + " Peso: " + Math.Round(a.getPond()).ToString());
                Peso = Peso + a.getPond();
            }
            TamAristasPrim.Items.Add("Peso Acumulado= " + Math.Round(Peso).ToString());
            Graphics graphics = Graphics.FromImage(ARM);
            Pen      pluma    = new Pen(Color.Green, 10);

            foreach (Arista a in Aristas)
            {
                graphics.DrawLine(pluma, a.getVertexOrigen().getX(), a.getVertexOrigen().getY(), a.getVertex().getX(), a.getVertex().getY());
            }
            pictureBox1.Image = ARM;
            pictureBox1.Refresh();
            this.lblNumeroSubgrafos.Text = prim.getSubgrafos().ToString();
            this.BtnAgentePrim.Enabled   = true;
            Rectangle Rectangulo = new Rectangle(0, 0, ARM.Width, ARM.Height);

            System.Drawing.Imaging.PixelFormat Format = ARM.PixelFormat;
            copia = ARM.Clone(Rectangulo, Format);
        }