diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java index bdf40e0..99b7b06 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java @@ -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 path = new ArrayList();