This commit is contained in:
Georgia Koutsodima 2023-05-02 18:08:43 +02:00
parent 852f7f9d1e
commit fc581c42be

View file

@ -47,22 +47,22 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
for (Arc suc:x.getSommet().getSuccessors() ) {
int index=suc.getDestination().getId();
if (!tab.get(index).getMarque()) {
if (tab.get(index).getCost()>x.getCost()+suc.getLength()) {
if (data.isAllowed(suc) && tab.get(index).getCost()>x.getCost()+suc.getLength()) {
/*on vérifie si présent dans le tas ou pas en utilisant remove */
try {
tas.remove(tab.get(index));
} catch (Exception e) {
System.out.println("l'élement n'est pas dans la tas");
System.out.println("l'élement n'est pas dans le tas");
notifyNodeReached(tab.get(index).getSommet());
if(tab.get(index).getSommet().equals(data.getDestination())){
// The destination has been found, notify the observers.
notifyDestinationReached(tab.get(index).getSommet());
}
}
tab.get(index).setCoutmin(x.getCost()+suc.getLength());
tab.get(index).setPere(suc);
/*insertion dans le tas */
tas.insert(tab.get(index));
// The destination has been found, notify the observers.
tas.insert(tab.get(index));
}
}
@ -74,8 +74,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
}
else {
ArrayList<Arc> arcs = new ArrayList<>();
Arc arc = label_dest.getPere();
while (arc != null) {