dijkstra * a completer

This commit is contained in:
Georgia Koutsodima 2023-04-12 18:28:13 +02:00
parent e4695e0ae7
commit d867c0db7f
4 changed files with 5 additions and 5 deletions

View file

@ -2,6 +2,8 @@ package org.insa.graphs.algorithm.shortestpath;
import java.util.ArrayList; import java.util.ArrayList;
import org.insa.graphs.model.Point;
public class AStarAlgorithm extends DijkstraAlgorithm { public class AStarAlgorithm extends DijkstraAlgorithm {
@ -10,12 +12,12 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
} }
/*on redéfinit l'initialisation */ /*on redéfinit l'initialisation */
void init(ArrayList<Label> tab){ void init(ArrayList<Label> tab,Point destination){
/*nombre de nodes du graphe de data */ /*nombre de nodes du graphe de data */
int n=data.getGraph().size(); int n=data.getGraph().size();
/*on remplit tab */ /*on remplit tab */
for (int i=0;i<n;i++){ for (int i=0;i<n;i++){
tab.add(new LabelStar(data.getGraph().get(i), false, Double.POSITIVE_INFINITY , null,0.0)); tab.add(new LabelStar(data.getGraph().get(i), false, Double.POSITIVE_INFINITY , null,data.getGraph().get(i).getPoint().distanceTo(destination)));
} }
} }

View file

@ -10,7 +10,6 @@ import java.util.Collections;
import org.insa.graphs.algorithm.utils.BinaryHeap; import org.insa.graphs.algorithm.utils.BinaryHeap;
public class DijkstraAlgorithm extends ShortestPathAlgorithm { public class DijkstraAlgorithm extends ShortestPathAlgorithm {
/*initialisation */ /*initialisation */
void init(ArrayList<Label> tab){ void init(ArrayList<Label> tab){
/*nombre de nodes du graphe de data */ /*nombre de nodes du graphe de data */

View file

@ -24,8 +24,6 @@ public class Label implements Comparable<Label>{
/*méthodes */ /*méthodes */
/*récupérer le cout */ /*récupérer le cout */
public double getCost() { return this.coutmin;} public double getCost() { return this.coutmin;}
/*récupérer le cout réalisé */
public double getCout() { return this.coutmin;}
/*récupérer le sommet du label */ /*récupérer le sommet du label */
public Node getSommet() { return this.sommet;} public Node getSommet() { return this.sommet;}
/*récupérer la marque */ /*récupérer la marque */

View file

@ -17,6 +17,7 @@ public class LabelStar extends Label {
/*méthodes */ /*méthodes */
/*récupérer le cout total */ /*récupérer le cout total */
@Override
public double getTotalCost() { return this.getCost()+this.coutest;} public double getTotalCost() { return this.getCost()+this.coutest;}