Pour resynchroniser le projet

This commit is contained in:
Gasson-Betuing Danyl 2025-05-09 10:37:38 +02:00
parent cf44ddf86c
commit 40ac23a8c1

View file

@ -1,5 +1,12 @@
package org.insa.graphs.algorithm.shortestpath; package org.insa.graphs.algorithm.shortestpath;
import java.util.Arrays;
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 DijkstraAlgorithm extends ShortestPathAlgorithm { public class DijkstraAlgorithm extends ShortestPathAlgorithm {
public DijkstraAlgorithm(ShortestPathData data) { public DijkstraAlgorithm(ShortestPathData data) {
@ -9,15 +16,36 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
@Override @Override
protected ShortestPathSolution doRun() { protected ShortestPathSolution doRun() {
// retrieve data from the input problem (getInputData() is inherited from the // retrieve data from the input problem (getInputData() is inherited from the
// parent class ShortestPathAlgorithm) // parent class ShortestPathAlgorithm)
final ShortestPathData data = getInputData(); final ShortestPathData data = getInputData();
// the graph
Graph graph = data.getGraph();
// node number
final int nbNodes = graph.size();
// Initialize array of distances.
double[] distances = new double[nbNodes];
Arrays.fill(distances, Double.POSITIVE_INFINITY);
distances[data.getOrigin().getId()] = 0;
// variable that will contain the solution of the shortest path problem // variable that will contain the solution of the shortest path problem
ShortestPathSolution solution = null; ShortestPathSolution solution = null;
// TODO: implement the Dijkstra algorithm // TODO: implement the Dijkstra algorithm
boolean found = false;
for (int i = 0; !found && i < nbNodes; ++i) {
found = true;
for (Node node : graph.getNodes()) {
for (Arc arc : node.getSuccessors()) {
}
}
}
// when the algorithm terminates, return the solution that has been found // when the algorithm terminates, return the solution that has been found