Advertisement
Guest User

afdgsf

a guest
Jul 26th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. /**
  2. * @file ConsoleApp.java
  3. * @brief Main del proyecto.
  4. */
  5. package apps;
  6.  
  7. //import tests_and_samples.Cities;
  8. import tests_and_samples.Converter;
  9.  
  10. import java.io.FileNotFoundException;
  11. import java.util.HashSet;
  12. import java.util.Iterator;
  13.  
  14. import xml_RW.ReadXML;
  15. import xml_RW.WriteXML;
  16. import directedMultigraph.Edge;
  17. import directedMultigraph.Vertex;
  18. import directedMultigraph.DGraph;
  19.  
  20. /**
  21. * @author Marcos De Moya
  22. */
  23. public class ConsoleApp {
  24.  
  25. static DGraph graph;
  26.  
  27. /**
  28. * @param args
  29. * @throws FileNotFoundException
  30. * @throws NullPointerException
  31. */
  32. public static void main(String[] args) throws NullPointerException, FileNotFoundException {
  33.  
  34. graph= new DGraph();
  35. String XML = "cities.XML";
  36. Converter agent = new Converter();
  37.  
  38. // int c = 3;
  39. // Cities[] pucmm= new Cities[c];
  40. //
  41. // pucmm[0]= new Cities();
  42. // pucmm[0].setName("Santo Domingo");
  43. // pucmm[0].setArea("104.44 km2");
  44. // pucmm[0].setPopulation("1,402,749");
  45. // pucmm[0].setDensity("9,200/km2");
  46. //
  47. // pucmm[1]= new Cities();
  48. // pucmm[1].setName("Santiago de los Caballeros");
  49. // pucmm[1].setArea("524.01 km2");
  50. // pucmm[1].setPopulation("691,262");
  51. // pucmm[1].setDensity("1,300/km2");
  52. //
  53. // pucmm[2]= new Cities();
  54. // pucmm[2].setName("La Romana");
  55. // pucmm[2].setArea("185.52 km2");
  56. // pucmm[2].setPopulation("130,426");
  57. // pucmm[2].setDensity("700/km2");
  58. //
  59. // for(int i= 0; i < c; i++){
  60. // graph.addVertex(pucmm[i]);
  61. // }
  62. //
  63. // graph.addEdge(graph.findVertexByID("V0"), graph.findVertexByID("V1"), (double)152.8);
  64. // graph.addEdge(graph.findVertexByID("V1"), graph.findVertexByID("V0"), (double)152.8);
  65. // graph.addEdge(graph.findVertexByID("V0"), graph.findVertexByID("V2"), (double)124.6);
  66. // graph.addEdge(graph.findVertexByID("V2"), graph.findVertexByID("V0"), (double)124.6);
  67. // graph.addEdge(graph.findVertexByID("V1"), graph.findVertexByID("V2"), (double)275.5);
  68. // graph.addEdge(graph.findVertexByID("V2"), graph.findVertexByID("V1"), (double)275.5);
  69.  
  70. System.out.println("Reading file from XML....");
  71. ReadXML readXML = new ReadXML();
  72. readXML.Load(XML , agent, graph );
  73. System.out.println("File loaded successfully");
  74.  
  75. HashSet<Vertex> aux= new HashSet<Vertex>();
  76. HashSet<Edge> auxE= new HashSet<Edge>();
  77. aux= graph.getVertices();
  78. auxE= graph.getEdges();
  79.  
  80. System.out.println();
  81. System.out.println("Graph has " + aux.size() + " Vertices");
  82. System.out.println("Graph has " + auxE.size() + " Edges");
  83. System.out.println();
  84.  
  85. Vertex v;
  86. Iterator<Vertex> aux2= aux.iterator();
  87. while(aux2.hasNext()){
  88. v= aux2.next();
  89. System.out.println(v.getID());
  90. System.out.println(v.data.toString());
  91. System.out.println();
  92. }
  93.  
  94. System.out.println("Saving file to XML....");
  95. WriteXML writeXML = new WriteXML();
  96. writeXML.writeXML(XML , graph);
  97. System.out.println("File saved successfully");
  98.  
  99. System.out.println();
  100. System.out.println("Saving graph to PNG image....");
  101. graph.generarImagen("GraphvizImage.png");
  102. System.out.println("Image saved successfully");
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement