package grafica;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Marco2 extends JFrame {
  JPanel contentPane;
  BorderLayout borderLayout1 = new BorderLayout();

  /**Construir el marco*/
  public Marco2() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  /**Inicialización de componentes*/
  private void jbInit() throws Exception  {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Marco2.class.getResource("[Icono]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Graficas");
  }
  /**Modificado para poder salir cuando se cierra la ventana*/
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }

    grafo a = new grafo();
    /*
    a.Agrega_Vertice("A");
    a.Agrega_Vertice("B");
    a.Agrega_Vertice("C");
    a.Agrega_Vertice("D");
    a.Agrega_Vertice("E");
    a.Agrega_Vertice("F");
    a.Agrega_Vertice("G");
    a.Agrega_Vertice("H");
    a.Agrega_Vertice("I");

    a.Agrega_Arista(0, 1, 1);
    a.Agrega_Arista(0, 2, 1);
    a.Agrega_Arista(0, 3, 1);
    a.Agrega_Arista(0, 4, 1);
    a.Agrega_Arista(1, 5, 1);
    a.Agrega_Arista(3, 6, 1);
    a.Agrega_Arista(5, 7, 1);
    a.Agrega_Arista(6, 8, 1);

    a.Imprime_Lista();
    a.Imprime_MatAdj();

    a.dfs();
     */
    /*
    a.Agrega_Vertice("v1");
    a.Agrega_Vertice("v2");
    a.Agrega_Vertice("v3");
    a.Agrega_Vertice("v4");
    a.Agrega_Vertice("v5");
    a.Agrega_Vertice("v6");
    a.Agrega_Vertice("v7");

    a.Agrega_Arista(0, 1, 1);
    a.Agrega_Arista(0, 3, 1);
    a.Agrega_Arista(1, 3, 1);
    a.Agrega_Arista(1, 4, 1);
    a.Agrega_Arista(2, 0, 1);
    a.Agrega_Arista(2, 5, 1);
    a.Agrega_Arista(3, 2, 1);
    a.Agrega_Arista(3, 4, 1);
    a.Agrega_Arista(3, 5, 1);
    a.Agrega_Arista(3, 6, 1);
    a.Agrega_Arista(4, 6, 1);
    a.Agrega_Arista(6, 5, 1);

    a.Dijkstras(a.ListaVert[2]);
    */

    a.Agrega_Vertice("v1");
    a.Agrega_Vertice("v2");
    a.Agrega_Vertice("v3");
    a.Agrega_Vertice("v4");
    a.Agrega_Vertice("v5");
    a.Agrega_Vertice("v6");
    a.Agrega_Vertice("v7");

    a.Agrega_Arista(0, 1, 2);
    a.Agrega_Arista(1, 0, 2);
    a.Agrega_Arista(0, 2, 4);
    a.Agrega_Arista(2, 0, 4);
    a.Agrega_Arista(0, 3, 1);
    a.Agrega_Arista(3, 0, 1);
    a.Agrega_Arista(1, 3, 3);
    a.Agrega_Arista(3, 1, 3);
    a.Agrega_Arista(1, 4, 10);
    a.Agrega_Arista(4, 1, 10);
    a.Agrega_Arista(2, 3, 2);
    a.Agrega_Arista(3, 2, 2);
    a.Agrega_Arista(2, 5, 5);
    a.Agrega_Arista(5, 2, 5);
    a.Agrega_Arista(3, 4, 7);
    a.Agrega_Arista(4, 3, 7);
    a.Agrega_Arista(3, 5, 8);
    a.Agrega_Arista(5, 3, 8);
    a.Agrega_Arista(3, 6, 4);
    a.Agrega_Arista(6, 3, 4);
    a.Agrega_Arista(4, 6, 6);
    a.Agrega_Arista(6, 4, 6);
    a.Agrega_Arista(5, 6, 1);
    a.Agrega_Arista(6, 5, 1);

    a.Imprime_MatAdj();

    a.Prims(a.ListaVert[0]);
    a.Imprime_Lista();

  }
}