legères modifications pour afficher le nombre de sommet explorés et marqués

This commit is contained in:
Benmouffok Helwen 2026-06-07 21:24:50 +02:00
parent c9cb1ae65e
commit 432bf1bb96

View file

@ -40,9 +40,15 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
labels[data.getOrigin().getId()].setCoutRealise(0); labels[data.getOrigin().getId()].setCoutRealise(0);
notifyOriginProcessed(data.getOrigin()); notifyOriginProcessed(data.getOrigin());
tas.insert(labels[data.getOrigin().getId()]); tas.insert(labels[data.getOrigin().getId()]);
// Compteurs de performance
int labelsExplores = 0; // inseres dans le tas
int labelsMarques = 0; // definitvement traites
while (!tas.isEmpty()) { while (!tas.isEmpty()) {
Label labelMin = tas.deleteMin(); Label labelMin = tas.deleteMin();
labelMin.setMarque(); labelMin.setMarque();
labelsMarques++; // incremente apres chaque marquage
notifyNodeMarked(labelMin.getSommetCourant()); notifyNodeMarked(labelMin.getSommetCourant());
if (labelMin.getSommetCourant().equals(data.getDestination())) { if (labelMin.getSommetCourant().equals(data.getDestination())) {
break; break;
@ -59,6 +65,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
tas.remove(labelSucc); tas.remove(labelSucc);
} else { } else {
notifyNodeReached(arc.getDestination()); notifyNodeReached(arc.getDestination());
labelsExplores++; // incremente quand on atteint un nouveau sommet
} }
labelSucc.setCoutRealise(nouveauCout); labelSucc.setCoutRealise(nouveauCout);
labelSucc.setPere(arc); labelSucc.setPere(arc);
@ -67,6 +74,10 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
} }
} }
} }
System.out.println("Labels explores : " + labelsExplores);
System.out.println("Labels marques : " + labelsMarques);
// Construction de la solution // Construction de la solution
if (labels[data.getDestination().getId()].getPere() == null) { if (labels[data.getDestination().getId()].getPere() == null) {
solution = new ShortestPathSolution(data, Status.INFEASIBLE); solution = new ShortestPathSolution(data, Status.INFEASIBLE);