From adad22dca4cda272831d5fafa6eec74a73b41e73 Mon Sep 17 00:00:00 2001 From: bezza Date: Mon, 12 May 2025 18:27:55 +0200 Subject: [PATCH] =?UTF-8?q?finalisation=20de=20Dijksra=20avec=20question?= =?UTF-8?q?=20bonus=20pour=20les=20pi=C3=A9tons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shortestpath/DijkstraAlgorithm.java | 157 +++++++----------- .../graphs/algorithm/shortestpath/Label.java | 102 ++++++------ .../graphs/algorithm/utils/BinaryHeap.java | 2 +- 3 files changed, 115 insertions(+), 146 deletions(-) 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 e4d6aa9..28651cf 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 @@ -2,8 +2,6 @@ package org.insa.graphs.algorithm.shortestpath; import java.util.ArrayList; import java.util.Collections; -import java.util.List; -import java.util.org.insa.graphs.algorithm.shortestpath.Label; import org.insa.graphs.algorithm.AbstractSolution.Status; import org.insa.graphs.algorithm.utils.BinaryHeap; @@ -22,127 +20,92 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { @Override protected ShortestPathSolution doRun() { - // retrieve data from the input problem (getInputData() is inherited from the - // parent class ShortestPathAlgorithm) final ShortestPathData data = getInputData(); - - // variable that will contain the solution of the shortest path problem ShortestPathSolution solution = null; + // accès au graphe + Graph graph = data.getGraph(); + int nbNodes = graph.size(); - // TODO: implement the Dijkstra algorithm + // Tableau des labels pour chaque sommet + Label[] labels = new Label[nbNodes]; + // Tableau des arcs prédécesseurs pour reconstruire le chemin + Arc[] predecessorArcs = new Arc[nbNodes]; - /*pseudo code : - on a à une destination et une origine et un graph pour les appliquer (et arcinspector jsp à quoi sert encore) - - dans graphe y'a la liste de nodes - dans chaque node y'a la liste de succesor avec des arcs - dans les arcs on peut avoir la destination - - dans BinaryHeap on a deletemin qu'on fera à chaque itération de dijkstra pour enlever du tas le sommet avec la plus petite distance de l'origine - - */ - - Graph graphe = data.getGraph(); - Node nodeOriginel=data.getOrigin(); - Node nodeDestination=data.getDestination(); - - BinaryHeap