Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @file ConsoleApp.java
- * @brief Main del proyecto.
- */
- package apps;
- //import tests_and_samples.Cities;
- import tests_and_samples.Converter;
- import java.io.FileNotFoundException;
- import java.util.HashSet;
- import java.util.Iterator;
- import xml_RW.ReadXML;
- import xml_RW.WriteXML;
- import directedMultigraph.Edge;
- import directedMultigraph.Vertex;
- import directedMultigraph.DGraph;
- /**
- * @author Marcos De Moya
- */
- public class ConsoleApp {
- static DGraph graph;
- /**
- * @param args
- * @throws FileNotFoundException
- * @throws NullPointerException
- */
- public static void main(String[] args) throws NullPointerException, FileNotFoundException {
- graph= new DGraph();
- String XML = "cities.XML";
- Converter agent = new Converter();
- // int c = 3;
- // Cities[] pucmm= new Cities[c];
- //
- // pucmm[0]= new Cities();
- // pucmm[0].setName("Santo Domingo");
- // pucmm[0].setArea("104.44 km2");
- // pucmm[0].setPopulation("1,402,749");
- // pucmm[0].setDensity("9,200/km2");
- //
- // pucmm[1]= new Cities();
- // pucmm[1].setName("Santiago de los Caballeros");
- // pucmm[1].setArea("524.01 km2");
- // pucmm[1].setPopulation("691,262");
- // pucmm[1].setDensity("1,300/km2");
- //
- // pucmm[2]= new Cities();
- // pucmm[2].setName("La Romana");
- // pucmm[2].setArea("185.52 km2");
- // pucmm[2].setPopulation("130,426");
- // pucmm[2].setDensity("700/km2");
- //
- // for(int i= 0; i < c; i++){
- // graph.addVertex(pucmm[i]);
- // }
- //
- // graph.addEdge(graph.findVertexByID("V0"), graph.findVertexByID("V1"), (double)152.8);
- // graph.addEdge(graph.findVertexByID("V1"), graph.findVertexByID("V0"), (double)152.8);
- // graph.addEdge(graph.findVertexByID("V0"), graph.findVertexByID("V2"), (double)124.6);
- // graph.addEdge(graph.findVertexByID("V2"), graph.findVertexByID("V0"), (double)124.6);
- // graph.addEdge(graph.findVertexByID("V1"), graph.findVertexByID("V2"), (double)275.5);
- // graph.addEdge(graph.findVertexByID("V2"), graph.findVertexByID("V1"), (double)275.5);
- System.out.println("Reading file from XML....");
- ReadXML readXML = new ReadXML();
- readXML.Load(XML , agent, graph );
- System.out.println("File loaded successfully");
- HashSet<Vertex> aux= new HashSet<Vertex>();
- HashSet<Edge> auxE= new HashSet<Edge>();
- aux= graph.getVertices();
- auxE= graph.getEdges();
- System.out.println();
- System.out.println("Graph has " + aux.size() + " Vertices");
- System.out.println("Graph has " + auxE.size() + " Edges");
- System.out.println();
- Vertex v;
- Iterator<Vertex> aux2= aux.iterator();
- while(aux2.hasNext()){
- v= aux2.next();
- System.out.println(v.getID());
- System.out.println(v.data.toString());
- System.out.println();
- }
- System.out.println("Saving file to XML....");
- WriteXML writeXML = new WriteXML();
- writeXML.writeXML(XML , graph);
- System.out.println("File saved successfully");
- System.out.println();
- System.out.println("Saving graph to PNG image....");
- graph.generarImagen("GraphvizImage.png");
- System.out.println("Image saved successfully");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement