Beispiel #1
0
        private void caminhoMínimoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (destino.Text == "")
            {
                MessageBox.Show("Favor escrever o rótulo do vértice de destino na caixa de texto: ", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                int fim = -1;
                for (int i = 0; i < g.getN(); i++)
                {
                    if (destino.Text == g.getVertice(i).getRotulo())
                    {
                        fim = i;
                    }
                }
                if (fim != -1)
                {
                    int     inicio = 0;
                    Vertice v      = g.getVerticeMarcado();
                    if (v != null)
                    {
                        inicio = v.getNum();
                    }

                    int custoTotal = g.caminhoMinimo(inicio, fim);
                    MessageBox.Show("O custo do menor caminho é de: " + custoTotal, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Favor escrever um rótulo válido! ", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        public void clicouVertice(Vertice v)
        {
            if (v.getMarcado())
            {
                v.desmarcar();
                vMarcado = null;
            }
            else
            {
                v.marcar();
                if (vMarcado != null)
                {
                    int peso;

                    if (getPesosAleatorios())
                    {
                        peso = (int)(randNum.Next(1, 100));
                    }
                    else
                    {
                        peso = 1;
                    }

                    Aresta a = new Aresta(peso, Color.Black, this); // cria a nova aresta
                    if (matAdj[vMarcado.getNum(), v.getNum()] == null)
                    {
                        matAdj[vMarcado.getNum(), v.getNum()] = matAdj[v.getNum(), vMarcado.getNum()] = a;
                        vMarcado.desmarcar();
                        vMarcado = v;
                    }
                    else
                    {
                        a = null;
                        v.desmarcar();
                    }
                }
                else
                {
                    vMarcado = v;
                }
            }
            Refresh();
        }
Beispiel #3
0
        private void larguraToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Vertice v = g.getVerticeMarcado();

            if (v == null)
            {
                MessageBox.Show("Escolha a Raiz da busca", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                g.largura(v.getNum());
            }
        }
Beispiel #4
0
        // LARGURA
        private void larguraToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Vertice vertice = g.getVerticeMarcado();

            if (vertice != null)
            {
                g.largura(vertice.getNum());
            }
            else
            {
                MessageBox.Show("Selecione um Vertice", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #5
0
        private void númeroCromáticoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int     inicio = 0;
            Vertice v      = g.getVerticeMarcado();

            if (v != null)
            {
                inicio = v.getNum();
            }


            int custoTotal = g.numeroCromatico(inicio);

            MessageBox.Show("X(G) é  igual a: " + custoTotal, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #6
0
        private void árvoreGeradoraMínimaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int     inicio = 0;
            Vertice v      = g.getVerticeMarcado();

            if (v != null)
            {
                inicio = v.getNum();
            }


            int custoTotal = g.AGM(inicio);

            MessageBox.Show("Custo total de: " + custoTotal, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #7
0
        private void larguraToolStripMenuItem_Click(object sender, EventArgs e)
        {
            g.clear();
            Vertice v = g.getVerticeMarcado();

            if (v != null)
            {
                g.largura(v.getNum());
                MessageBox.Show("Concluido com sucesso!", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Nenhum vértice marcado!", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #8
0
        private void éÁrvoreToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int     inicio = 0;
            Vertice v      = g.getVerticeMarcado();

            if (v != null)
            {
                inicio = v.getNum();
            }

            if (g.IsArvore(inicio) == true)
            {
                MessageBox.Show("É uma árvore", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Não é uma árvore", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }