dijkstra
This commit is contained in:
parent
852f7f9d1e
commit
fc581c42be
1 changed files with 4 additions and 6 deletions
|
@ -47,14 +47,15 @@ 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +63,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
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) {
|
||||||
|
|
Loading…
Reference in a new issue