Ajout observers

This commit is contained in:
Adrien Barbanson 2021-05-03 10:13:04 +02:00
parent 8199e93748
commit 5cb458cc25

View file

@ -46,6 +46,9 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
// We add into our binaryMinHeap the origin
minHeap.insert(labels[data.getOrigin().getId()]);
//We notify observers that we initialized the origin
notifyOriginProcessed(data.getOrigin());
// We can start searching for the shortestPath
// We stop the algorithm when the cost of last marked point is equal to the shortest found path
@ -57,6 +60,11 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
//We mark it
minLabel.setMarked();
//We notify we marked it
notifyNodeMarked(minLabel.getCurrent());
lastMarkedNodeCost = minLabel.getCost();
//We look at their successors
@ -91,6 +99,9 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
if(Double.isFinite(label.getCost())) {
minHeap.remove(label);
}
else {
notifyNodeReached(label.getCurrent());
}
label.setNewCost(successor, newCost);
minHeap.insert(label);
@ -119,7 +130,10 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
return new ShortestPathSolution(data, Status.INFEASIBLE);
}
//There is a path, let's find it
notifyDestinationReached(data.getDestination());
ArrayList<Arc> path = new ArrayList<Arc>();