From 268ed91e8570807278feeda3cd21111255cd74a9 Mon Sep 17 00:00:00 2001 From: Bensouda Idriss Date: Sat, 20 May 2023 16:06:18 +0200 Subject: [PATCH] Ajout test Solving Time --- .../shortestpath/DijkstraAlgorithm.java | 1 + .../utils/DijkstraAlgorithmTest.java | 17 +++++++++++++++++ .../shortestpath/DijkstraAlgorithm.class | Bin 5411 -> 5411 bytes 3 files changed, 18 insertions(+) diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java index 6b02464..6124b21 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java @@ -89,6 +89,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { //On récupère le chemin (liste d'arcs) de la destination vers la source Label dest =List_Label.get(data.getDestination().getId()); + //Si on n'a pas de parent ou que la destination = origin on renvoie une solution avec status() infaisable if (dest.getParent() == null || data.getOrigin()==data.getDestination()) { return solution = new ShortestPathSolution(data, Status.INFEASIBLE); } diff --git a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraAlgorithmTest.java b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraAlgorithmTest.java index 539cd5b..aca0909 100644 --- a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraAlgorithmTest.java +++ b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/DijkstraAlgorithmTest.java @@ -121,6 +121,23 @@ public class DijkstraAlgorithmTest { assertEquals(solution.getStatus(),soluce_Bellma.getStatus()); } + @Test + public void Comparaison_Solving_Time() throws IOException{ + final String map_c = "/mnt/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/carre-dense.mapgr"; + final GraphReader reader = new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream(map_c)))); + Graph graph_c = reader.read(); + ShortestPathData data = new ShortestPathData(graph_c,graph_c.get(120084),graph_c.get(191086),ArcInspectorFactory.getAllFilters().get(0)); + ShortestPathAlgorithm Dijkstra =new DijkstraAlgorithm(data); + ShortestPathAlgorithm A_star= new AStarAlgorithm(data); + ShortestPathSolution soluce_Dijkstra= Dijkstra.run(); + ShortestPathSolution soluce_Astar= A_star.run(); + boolean result = false; + if (soluce_Dijkstra.getSolvingTime().toSeconds() > soluce_Astar.getSolvingTime().toSeconds()){ + result = true; + } + assertTrue(result); + } + @Test public void Carte_Length() throws IOException{ diff --git a/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.class b/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.class index 2094a1d4c33d30005ccbcb08efc01edbdf3ac916..5d60419a0601878b1e918d677dcb2513a3e1eba6 100644 GIT binary patch delta 50 zcmZ3iwODJzH6hhl#`6qujCUE58J{wwFuq_&W&F&L#>CE$!o<&z%_PE*%cRRtxcRq` G1``01@D2