private void button2_Click(object sender, EventArgs e) { Form2 select = new Form2(); foreach (int item in mygrafo.vertices) { select.cm.Items.Add(item); select.cm2.Items.Add(item); } select.ShowDialog(); if (select.DialogResult == DialogResult.OK) { mygrafo.addAresta(select.a1, select.a2); toolStripLabel1.Text = "Adicionada uma aresta de:" + select.a1.ToString() + ",para:" + select.a2.ToString(); } else { toolStripLabel1.Text = "Adição de aresta cancelada"; } select.Dispose(); }
public Form1() { InitializeComponent(); //toolStrip = toolStrip1; mygrafo = new Grafo(); mygrafo.addVertice(6); mygrafo.addVertice(4); mygrafo.addVertice(5); mygrafo.addVertice(3); mygrafo.addVertice(2); mygrafo.addVertice(1); mygrafo.addVertice(8); mygrafo.addVertice(10); mygrafo.addAresta(6, 4); mygrafo.addAresta(4, 5); mygrafo.addAresta(4, 3); mygrafo.addAresta(5, 2); mygrafo.addAresta(5, 1); mygrafo.addAresta(2, 1); mygrafo.addAresta(2, 10); mygrafo.addAresta(1, 8); toolStripLabel1.Text = "Pronto para execução"; //mygrafo.addAresta(4, 3); }