From 8de2ae972b17c9d8791830b51eb5d79ed3a68c5b Mon Sep 17 00:00:00 2001 From: Pellerin Tiphaine Date: Fri, 29 May 2026 17:50:36 +0200 Subject: [PATCH] =?UTF-8?q?on=20a=20commenc=C3=A9=20=C3=A0=20impl=C3=A9men?= =?UTF-8?q?ter=20l'algo=20du=20probl=C3=A8me=20ouvert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shortestpath/DijkstraAlgorithm.java | 2 +- .../algorithm/shortestpath/Marathon.java | 103 ++++++++++++++++++ .../shortestpath/DijkstraAlgorithm.class | Bin 5300 -> 5283 bytes .../algorithm/shortestpath/Marathon.class | Bin 0 -> 1313 bytes .../org/insa/graphs/gui/simple/Launch.java | 22 ++-- .../org/insa/graphs/gui/simple/Launch.class | Bin 6740 -> 6743 bytes 6 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Marathon.java create mode 100644 be-graphes-algos/target/classes/org/insa/graphs/algorithm/shortestpath/Marathon.class 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 1ae3391..1922d9e 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 @@ -88,7 +88,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { // Create the path from the array of predecessors... ArrayList arcs = new ArrayList<>(); Label nCourant = listLabel[dataInput.getDestination().getId()]; - while (nCourant.pere != null) { + while (nCourant.getPere() != null) { arcs.add(nCourant.getPere()); nCourant = listLabel[nCourant.getPere().getOrigin().getId()]; } diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Marathon.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Marathon.java new file mode 100644 index 0000000..01c1652 --- /dev/null +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Marathon.java @@ -0,0 +1,103 @@ +package org.insa.graphs.algorithm.shortestpath; + +import java.util.ArrayList; +import java.util.Collections; + +import org.insa.graphs.algorithm.AbstractSolution.Status; +import org.insa.graphs.algorithm.utils.BinaryHeap; +import org.insa.graphs.model.Arc; +import org.insa.graphs.model.Graph; +import org.insa.graphs.model.Node; +import org.insa.graphs.model.Path; + +public class Marathon extends ShortestPathAlgorithm { + + public Marathon(ShortestPathData data) { + super(data); + } + + public Label newLabelMarathon(Node s) { + return new LabelMarathon(s, false, Double.MAX_VALUE, null); + } + + @Override + public ShortestPathSolution doRun() { + + // retrieve data from the input problem (getInputData() is inherited from the + // parent class ShortestPathAlgorithm) + final ShortestPathData dataInput = getInputData(); + Graph graph = dataInput.getGraph(); + final int nbNodes = graph.size(); + Label[] listLabel = new Label[nbNodes]; + BinaryHeap