12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package org.insa.graphs.algorithm.shortestpath;
-
- import org.insa.graphs.algorithm.utils.BinaryHeap;
-
- public class DijkstraAlgorithm extends ShortestPathAlgorithm {
-
-
- public DijkstraAlgorithm(ShortestPathData data) {
- super(data);
- }
-
- @Override
- protected ShortestPathSolution doRun() {
- final ShortestPathData data = getInputData();
- ShortestPathSolution solution = null;
- // TODO:
-
- //initialisation
- BinaryHeap tas=new BinaryHeap();
- Label[] tablabel=new Label[data.getGraph().size()];
- for (int i=0;i<tablabel.length;i++) {
- tablabel[i]=new Label(data.getGraph().get(i),null,Integer.MAX_VALUE);
- }
- tablabel[data.getOrigin().getId()].cout=0;
- tas.insert(data.getOrigin().getId());
-
- boolean exnonmar=true;
- int min;
- //itérations
- while (exnonmar) {
- min=tas.deleteMin();
- tablabel[min].marque=true;
- for (successeurs y) {
- if (!tablabel[y].marque) {
- if (tablabel[y].cout>tablabel[x].cout+(int)tablabel[y].pere.getMinimumTravelTime()) {
- tablabel[y].cout=tablabel[x].cout+(int)tablabel[y].pere.getMinimumTravelTime();
- if (exist y in tas) {
- tas.update(y);
- }else {
- tas.insert(y);
- }
- }
- }
- }
-
- exnonmar=false;
- }
-
- return solution;
- }
-
- }
|