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