observer dijkstra
Cette révision appartient à :
Parent
4e6a6cbcd3
révision
ce9743650b
1 fichiers modifiés avec 9 ajouts et 3 suppressions
|
@ -34,10 +34,12 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
Label label_dest =tab.get(data.getDestination().getId());
|
Label label_dest =tab.get(data.getDestination().getId());
|
||||||
/*insertion de label origine dans le tas */
|
/*insertion de label origine dans le tas */
|
||||||
tas.insert(label_origine);
|
tas.insert(label_origine);
|
||||||
|
notifyOriginProcessed(label_origine.getSommet());
|
||||||
Label x;
|
Label x;
|
||||||
while (label_dest.getMarque()==false && tas.isEmpty()==false) {
|
while (label_dest.getMarque()==false && tas.isEmpty()==false) {
|
||||||
x=tas.deleteMin();
|
x=tas.deleteMin();
|
||||||
x.setMarque(true);
|
x.setMarque(true);
|
||||||
|
notifyNodeMarked(x.getSommet());
|
||||||
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()) {
|
||||||
|
@ -47,11 +49,16 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
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 la tas");
|
||||||
|
notifyNodeReached(tab.get(index).getSommet());
|
||||||
|
if(tab.get(index).getSommet().equals(data.getDestination())){
|
||||||
|
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,8 +70,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// The destination has been found, notify the observers.
|
|
||||||
notifyDestinationReached(data.getDestination());
|
|
||||||
|
|
||||||
ArrayList<Arc> arcs = new ArrayList<>();
|
ArrayList<Arc> arcs = new ArrayList<>();
|
||||||
Arc arc = label_dest.getPere();
|
Arc arc = label_dest.getPere();
|
||||||
|
|
Chargement…
Référencer dans un nouveau ticket