This commit is contained in:
Georgia Koutsodima 2023-05-10 10:06:54 +02:00
parent b18a939270
commit d044186aa4

View file

@ -31,6 +31,9 @@ public class DijkstraTest {
private static ShortestPathSolution solBellman1;
private static Random random1 = new Random();
private static String mapName2;
private static GraphReader reader2;
private static Graph graph2;
private static Node origin2;
private static Node destination2;
private static DijkstraAlgorithm dijkstra2;
@ -47,6 +50,12 @@ public class DijkstraTest {
reader1 = new BinaryGraphReader(
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName1))));
mapName2 = "/mnt/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/toulouse.mapgr";
// Create a graph reader.
reader2 = new BinaryGraphReader(
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName2))));
// Read the graph.
graph1 = reader1.read();
final int numNodes1 = graph1.size();
@ -57,10 +66,12 @@ public class DijkstraTest {
solDijkstra1 = dijkstra1.run();
solBellman1 = bellman1.run();
origin2 = graph1.get(random1.nextInt(numNodes1));
destination2 = graph1.get(random1.nextInt(numNodes1));
dijkstra2 = new DijkstraAlgorithm(new ShortestPathData(graph1,origin2,destination2,ArcInspectorFactory.getAllFilters().get(2)));//only roads for cars and time
bellman2 = new BellmanFordAlgorithm(new ShortestPathData(graph1,origin2,destination2,ArcInspectorFactory.getAllFilters().get(2)));
graph2 = reader2.read();
final int numNodes2 = graph2.size();
origin2 = graph2.get(random1.nextInt(numNodes2));
destination2 = graph2.get(random1.nextInt(numNodes2));
dijkstra2 = new DijkstraAlgorithm(new ShortestPathData(graph2,origin2,destination2,ArcInspectorFactory.getAllFilters().get(2)));//only roads for cars and time
bellman2 = new BellmanFordAlgorithm(new ShortestPathData(graph2,origin2,destination2,ArcInspectorFactory.getAllFilters().get(2)));
solDijkstra2 = dijkstra2.run();
solBellman2 = bellman2.run();
}