Codigo Java
Codigo Java
Codigo Java
/*File: Grafo.java
*Descripcin: Grafo Dirigido implementado con matrices de adyacencia.
*Las aristas no van a tener peso, por lo tanto la matriz es binaria,
*un valor de 1 indica que existe una arista entre dos vertices, y un valor
*de cero indica que no existe una arista entre los vertices.*/
import
import
import
import
java.lang.ArrayIndexOutOfBoundsException;
java.lang.UnsupportedOperationException;
java.lang.RuntimeException;
java.util.Scanner;
System.out.print("
");
for (int i = 0; i < MAX_VERTICES; i++) {
System.out.printf("%3d ",nodos[i]);
}
System.out.println();
for (int i = 0; i < MAX_VERTICES; i++) {
// System.out.println("Ingrese los Nodos.");
System.out.printf(" %3d", nodos[i]);
for (int j = 0; j < MAX_VERTICES; j++) {
System.out.printf(" %3d", grafo[i][j]);
}
System.out.println();
}
}
}