dijkstra * a completer
This commit is contained in:
parent
e4695e0ae7
commit
d867c0db7f
4 changed files with 5 additions and 5 deletions
|
@ -2,6 +2,8 @@ package org.insa.graphs.algorithm.shortestpath;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.insa.graphs.model.Point;
|
||||
|
||||
|
||||
public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||
|
||||
|
@ -10,12 +12,12 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
|||
}
|
||||
|
||||
/*on redéfinit l'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 */
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.Collections;
|
|||
import org.insa.graphs.algorithm.utils.BinaryHeap;
|
||||
|
||||
public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||
|
||||
/*initialisation */
|
||||
void init(ArrayList<Label> tab){
|
||||
/*nombre de nodes du graphe de data */
|
||||
|
|
|
@ -24,8 +24,6 @@ public class Label implements Comparable<Label>{
|
|||
/*méthodes */
|
||||
/*récupérer le cout */
|
||||
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 */
|
||||
public Node getSommet() { return this.sommet;}
|
||||
/*récupérer la marque */
|
||||
|
|
|
@ -17,6 +17,7 @@ public class LabelStar extends Label {
|
|||
|
||||
/*méthodes */
|
||||
/*récupérer le cout total */
|
||||
@Override
|
||||
public double getTotalCost() { return this.getCost()+this.coutest;}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue