Dijktra
This commit is contained in:
parent
e537dfa8c0
commit
2b4e645c77
2 changed files with 42 additions and 2 deletions
|
@ -1,5 +1,10 @@
|
||||||
package org.insa.graphs.algorithm.shortestpath;
|
package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
|
import org.insa.graphs.algorithm.utils.BinaryHeap;
|
||||||
|
import java.util.ArrayList ;
|
||||||
|
import org.insa.graphs.model.Node;
|
||||||
|
import org.insa.graphs.model.Arc;
|
||||||
|
|
||||||
public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
|
|
||||||
public DijkstraAlgorithm(ShortestPathData data) {
|
public DijkstraAlgorithm(ShortestPathData data) {
|
||||||
|
@ -10,7 +15,42 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
protected ShortestPathSolution doRun() {
|
protected ShortestPathSolution doRun() {
|
||||||
final ShortestPathData data = getInputData();
|
final ShortestPathData data = getInputData();
|
||||||
ShortestPathSolution solution = null;
|
ShortestPathSolution solution = null;
|
||||||
// TODO:
|
|
||||||
|
|
||||||
|
int i ;
|
||||||
|
|
||||||
|
/* Taille du graphe */
|
||||||
|
int tailleGraphe = data.getGraph().size() ;
|
||||||
|
|
||||||
|
/* Tableau contenant tous les labels */
|
||||||
|
ArrayList<Label> labelSommets = new ArrayList<Label>() ;
|
||||||
|
|
||||||
|
/* Déclaration du label */
|
||||||
|
Label currentLabel ;
|
||||||
|
|
||||||
|
/* Déclaration du tas */
|
||||||
|
BinaryHeap<Integer> leTas = new BinaryHeap<Integer>() ;
|
||||||
|
|
||||||
|
/* Compte le nombre de sommets marqués */
|
||||||
|
int nbrMarques = 0 ;
|
||||||
|
|
||||||
|
int x ;
|
||||||
|
|
||||||
|
for(i=0;i<tailleGraphe;i++) {
|
||||||
|
/* Initialisation */
|
||||||
|
currentLabel = new Label(data.getGraph().get(i)) ;
|
||||||
|
labelSommets.set(i, currentLabel) ; //On met notre label dans le tableau dédié
|
||||||
|
}
|
||||||
|
|
||||||
|
leTas.insert(data.getOrigin().)
|
||||||
|
|
||||||
|
while (currentLabel.marque = false) {
|
||||||
|
x = leTas.deleteMin() ;
|
||||||
|
for (Arc arc : data.getGraph().getNodes()) {
|
||||||
|
currentLabel = new Label(node) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return solution;
|
return solution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class Label {
|
||||||
this.sommetCourant = sommetCourant ;
|
this.sommetCourant = sommetCourant ;
|
||||||
this.marque = false ;
|
this.marque = false ;
|
||||||
this.coutRealise = -1.0 ; //infini
|
this.coutRealise = -1.0 ; //infini
|
||||||
this.pere = null ;
|
this.pere = null ; //sommet inexistant
|
||||||
}
|
}
|
||||||
|
|
||||||
/* METHODES */
|
/* METHODES */
|
||||||
|
|
Loading…
Reference in a new issue