diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java index e0683cc..21f25b9 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java @@ -17,7 +17,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm { } @Override - public void shortestVerif(ShortestPathSolution solution,ArrayList solutionNodes , ShortestPathData data) + public void ShortestVerif(ShortestPathSolution solution,ArrayList solutionNodes , ShortestPathData data) { Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes); System.out.println("shortest path : " + p.getLength()); 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 bbc1c85..1a0ca42 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 @@ -8,6 +8,7 @@ import org.insa.graphs.algorithm.utils.BinaryHeap; import org.insa.graphs.model.Arc; import org.insa.graphs.model.Node; import org.insa.graphs.model.Path; +import org.insa.graphs.model.Point; public class DijkstraAlgorithm extends ShortestPathAlgorithm { @@ -82,10 +83,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { } } - } - Label dest =List_Label.get(data.getDestination().getId()); - + Label dest =List_Label.get(data.getDestination().getId()); while (dest.getParent() != null){ Arcs.add(dest.getParent()); dest = List_Label.get(dest.getParent().getOrigin().getId()); @@ -97,15 +96,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { solutionNodes.add(a.getOrigin()); } solutionNodes.add(data.getDestination()); - shortestVerif(solution, solutionNodes, data); + ShortestVerif(solution, solutionNodes, data); fastestVerif(solution, solutionNodes, data); - + volDoiseauVerif(data, solution); return solution; } - - - public void shortestVerif(ShortestPathSolution solution,ArrayList solutionNodes , ShortestPathData data) + //Permet de vérifier si le chemin obtenu par la solution est bien le plus court + public void ShortestVerif(ShortestPathSolution solution,ArrayList solutionNodes , ShortestPathData data) { Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes); System.out.println("shortest path : " + p.getLength()); @@ -124,4 +122,13 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { } } + // Permet de vérifier si la distance de la solution est plus long que la distance à vol d'oiseau + public void volDoiseauVerif(ShortestPathData data, ShortestPathSolution solution){ + double distanceV = Point.distance(data.getGraph().get(data.getOrigin().getId()).getPoint(), data.getDestination().getPoint()); + if (distanceV > solution.getPath().getLength()){ + System.out.println("La solution n'est pas réalisable"); + } else { + System.out.println("La solution est réalisable"); + } + } } \ No newline at end of file diff --git a/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.class b/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.class index c711e43..e3314ca 100644 Binary files a/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.class and b/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.class differ 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 f08991c..0e4a22f 100644 Binary files a/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.class and b/be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.class differ