fastest path

This commit is contained in:
Georgia Koutsodima 2023-05-10 09:47:56 +02:00
parent 026f99c0e6
commit b18a939270

View file

@ -47,7 +47,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
for (Arc suc:x.getSommet().getSuccessors() ) {
int index=suc.getDestination().getId();
if (!tab.get(index).getMarque()) {
if (data.isAllowed(suc) && tab.get(index).getCost()>x.getCost()+suc.getLength()) {
if (data.isAllowed(suc) && tab.get(index).getCost()>x.getCost()+data.getCost(suc)) {
/*on vérifie si présent dans le tas ou pas en utilisant remove */
try {
tas.remove(tab.get(index));
@ -59,7 +59,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
notifyDestinationReached(tab.get(index).getSommet());
}
}
tab.get(index).setCoutmin(x.getCost()+suc.getLength());
tab.get(index).setCoutmin(x.getCost()+data.getCost(suc));
tab.get(index).setPere(suc);
/*insertion dans le tas */
tas.insert(tab.get(index));