avancement mineurs

This commit is contained in:
Matteo Sabben 2025-05-20 12:12:25 +02:00
parent 2835497c61
commit e8db0bfb33
2 changed files with 13 additions and 4 deletions

View file

@ -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());
}

View file

@ -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