From 852f7f9d1e03b887bdb62c84c90beeb0839cd516 Mon Sep 17 00:00:00 2001 From: Raph Date: Tue, 2 May 2023 18:00:30 +0200 Subject: [PATCH] test2 dij --- .../graphs/algorithm/utils/DijkstraTest.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraTest.java b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraTest.java index 87ba2cb..a62514d 100644 --- a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraTest.java +++ b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraTest.java @@ -30,6 +30,13 @@ public class DijkstraTest { private static ShortestPathSolution solBellman1; 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 public static void initAll() throws IOException{ @@ -44,17 +51,28 @@ public class DijkstraTest { final int numNodes1 = graph1.size(); origin1 = 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))); 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))); + solDijkstra2 = dijkstra2.run(); + solBellman2 = bellman2.run(); } @Test - public void testDijkstra1(){ + public void testDijkstra1(){//test en distance avec Bellman-Ford assertEquals(solDijkstra1.getPath().getLength(),solBellman1.getPath().getLength(),0.00001); } + @Test + public void testDijkstra2(){ + assertEquals(solDijkstra2.getPath().getMinimumTravelTime(),solBellman2.getPath().getMinimumTravelTime(),0.00001); + } + }