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 0833f7b..e30befe 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 @@ -1,13 +1,7 @@ package org.insa.graphs.algorithm.shortestpath; - -import org.insa.graphs.algorithm.AbstractSolution.Status; - -import java.util.ArrayList; -import java.util.Collections; -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 AStarAlgorithm extends DijkstraAlgorithm { 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 1cd907e..7ea02b7 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 @@ -46,7 +46,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { } Tas.insert(List_Label.get(data.getOrigin().getId())); Label x; - while (!List_Label.get(data.getDestination().getId()).isMarque() && !Tas.isEmpty()){ x = Tas.findMin(); x.setMarque(true); @@ -86,15 +85,25 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { } Label dest =List_Label.get(data.getDestination().getId()); - + while (dest.getParent() != null){ Arcs.add(dest.getParent()); dest = List_Label.get(dest.getParent().getOrigin().getId()); } Collections.reverse(Arcs); solution = new ShortestPathSolution(data, Status.OPTIMAL, new Path(data.getGraph(), Arcs)); + ArrayList solutionNodes = new ArrayList(); + for (Arc a : Arcs){ + solutionNodes.add(a.getOrigin()); + } + solutionNodes.add(data.getDestination()); + Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes); + Path p2 = Path.createFastestPathFromNodes(data.getGraph(), solutionNodes); + System.out.println("shortest path : " + p.getLength()); + if (p.getLength()-solution.getPath().getLength() < 1.00){ + System.out.println("le chemin Dijkstra est le shortest"); + } + return solution; } - - } \ 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 fbcdc60..79af93e 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 2bc0b8a..93981dc 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 diff --git a/be-graphes-gui/src/main/java/org/insa/graphs/gui/simple/Launch.java b/be-graphes-gui/src/main/java/org/insa/graphs/gui/simple/Launch.java index dc447da..46c7181 100644 --- a/be-graphes-gui/src/main/java/org/insa/graphs/gui/simple/Launch.java +++ b/be-graphes-gui/src/main/java/org/insa/graphs/gui/simple/Launch.java @@ -11,6 +11,7 @@ import java.io.FileInputStream; import javax.swing.JFrame; import javax.swing.SwingUtilities; +import org.insa.graphs.algorithm.shortestpath.ShortestPathAlgorithm; import org.insa.graphs.gui.drawing.Drawing; import org.insa.graphs.gui.drawing.components.BasicDrawing; import org.insa.graphs.model.Graph; @@ -70,7 +71,7 @@ public class Launch { // TODO: Read the path. final Path path = pathReader.readPath(graph); - + System.out.println(); // TODO: Draw the path. drawing.drawPath(path,Color.green); diff --git a/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch$1.class b/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch$1.class index 4fdcf7d..5a2b741 100644 Binary files a/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch$1.class and b/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch$1.class differ diff --git a/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch.class b/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch.class index 6e8b432..a6f0fb0 100644 Binary files a/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch.class and b/be-graphes-gui/target/classes/org/insa/graphs/gui/simple/Launch.class differ diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java index 5d23423..cc16537 100644 --- a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java +++ b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java @@ -59,6 +59,7 @@ public class Path { } arcs.add(a); } + System.out.println(new Path(graph, arcs)); return new Path(graph, arcs); } diff --git a/be-graphes-model/target/classes/org/insa/graphs/model/Path.class b/be-graphes-model/target/classes/org/insa/graphs/model/Path.class index f709685..395dc28 100644 Binary files a/be-graphes-model/target/classes/org/insa/graphs/model/Path.class and b/be-graphes-model/target/classes/org/insa/graphs/model/Path.class differ