test2 dij
This commit is contained in:
parent
1821ccfa70
commit
852f7f9d1e
1 changed files with 20 additions and 2 deletions
|
@ -30,6 +30,13 @@ public class DijkstraTest {
|
||||||
private static ShortestPathSolution solBellman1;
|
private static ShortestPathSolution solBellman1;
|
||||||
private static Random random1 = new Random();
|
private static Random random1 = new Random();
|
||||||
|
|
||||||
|
private static Node origin2;
|
||||||
|
private static Node destination2;
|
||||||
|
private static DijkstraAlgorithm dijkstra2;
|
||||||
|
private static BellmanFordAlgorithm bellman2;
|
||||||
|
private static ShortestPathSolution solDijkstra2;
|
||||||
|
private static ShortestPathSolution solBellman2;
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initAll() throws IOException{
|
public static void initAll() throws IOException{
|
||||||
|
@ -44,17 +51,28 @@ public class DijkstraTest {
|
||||||
final int numNodes1 = graph1.size();
|
final int numNodes1 = graph1.size();
|
||||||
origin1 = graph1.get(random1.nextInt(numNodes1));
|
origin1 = graph1.get(random1.nextInt(numNodes1));
|
||||||
destination1 = graph1.get(random1.nextInt(numNodes1));
|
destination1 = graph1.get(random1.nextInt(numNodes1));
|
||||||
dijkstra1 = new DijkstraAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));
|
dijkstra1 = new DijkstraAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));//all roads allowed and length
|
||||||
bellman1 = new BellmanFordAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));
|
bellman1 = new BellmanFordAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));
|
||||||
solDijkstra1 = dijkstra1.run();
|
solDijkstra1 = dijkstra1.run();
|
||||||
solBellman1 = bellman1.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)));
|
||||||
|
solDijkstra2 = dijkstra2.run();
|
||||||
|
solBellman2 = bellman2.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDijkstra1(){
|
public void testDijkstra1(){//test en distance avec Bellman-Ford
|
||||||
assertEquals(solDijkstra1.getPath().getLength(),solBellman1.getPath().getLength(),0.00001);
|
assertEquals(solDijkstra1.getPath().getLength(),solBellman1.getPath().getLength(),0.00001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDijkstra2(){
|
||||||
|
assertEquals(solDijkstra2.getPath().getMinimumTravelTime(),solBellman2.getPath().getMinimumTravelTime(),0.00001);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue