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 0457c6a..4db278f 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 @@ -8,7 +8,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm { @Override - protected Label createLabel(Node node) { + protected LabelStar createLabel(Node node) { return new LabelStar(node, false, Double.POSITIVE_INFINITY, null, getInputData().getDestination()); } diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java index d5bec72..3ebdc92 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java @@ -2,7 +2,8 @@ package org.insa.graphs.algorithm.shortestpath; import org.insa.graphs.model.Arc; import org.insa.graphs.model.Node; -import static org.insa.graphs.model.Point.distance; +import org.insa.graphs.model.Point; + public class LabelStar extends Label { @@ -10,12 +11,20 @@ public class LabelStar extends Label { private Node destination; public LabelStar(Node sommetCourant, Boolean marque, double coutRealise, Arc pere,Node destination) { super(sommetCourant, marque, coutRealise, pere); - this.destination=destination; //ou alors on le met juste en paramètre + this.destination=destination; } + + //pour optimiser l'algo : ATTENTION PAS à L'initialisation pas le faire sinon ça va le faire pr tout les pts + //on rajoute un paremètre distance ds le label et quand on passe sur le label si c'est linfini on le calcule + @Override public double getTotalCost() { //pourquoi getTotalCost ? psq il est utilisé dans le compareTo - return (getCoutRealise()+distance(getSommetCourant().getPoint(),this.destination.getPoint())); + //System.out.println("cout realise : " + getCoutRealise()+ "\n distance : "distance(getSommetCourant().getPoint(),this.destination.getPoint())); + double cout=getCoutRealise(); + Point calcul = this.destination.getPoint(); + cout+=calcul.distanceTo(this.getSommetCourant().getPoint()); + return (cout); } //pas nécessaire normalement