dijkstra
This commit is contained in:
parent
852f7f9d1e
commit
fc581c42be
1 changed files with 4 additions and 6 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue