Dikjstra et A*

This commit is contained in:
Georgia Koutsodima 2023-04-16 10:56:42 +02:00
parent d867c0db7f
commit 018d321be4
2 changed files with 5 additions and 2 deletions

View file

@ -19,6 +19,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
for (int i=0;i<n;i++){
tab.add(new LabelStar(data.getGraph().get(i), false, Double.POSITIVE_INFINITY , null,data.getGraph().get(i).getPoint().distanceTo(destination)));
}
}
}

View file

@ -6,12 +6,13 @@ import org.insa.graphs.model.Path;
import java.util.ArrayList;
import java.util.Collections;
import org.insa.graphs.model.Point;
import org.insa.graphs.algorithm.utils.BinaryHeap;
public class DijkstraAlgorithm extends ShortestPathAlgorithm {
/*initialisation */
void init(ArrayList<Label> tab){
void init(ArrayList<Label> tab, Point destination){
/*nombre de nodes du graphe de data */
int n=data.getGraph().size();
/*on remplit tab */
@ -30,7 +31,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
ArrayList<Label> tab=new ArrayList<Label>();
BinaryHeap<Label> tas=new BinaryHeap<Label>();
ShortestPathSolution solution = null;
init(tab);
/*initialisation */
init(tab,data.getDestination().getPoint());
Label label_origine = tab.get(data.getOrigin().getId());
label_origine.setCoutmin(0);
Label label_dest =tab.get(data.getDestination().getId());