ajout label
This commit is contained in:
parent
daf1c415a8
commit
7db1b405b3
2 changed files with 42 additions and 2 deletions
|
@ -0,0 +1,39 @@
|
||||||
|
package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
|
public class Label {
|
||||||
|
|
||||||
|
/* sommet courant : sommet associé à ce label (sommet ou numéro de sommet).
|
||||||
|
marque : booléen, vrai lorsque le coût min de ce sommet est définitivement connu par l'algorithme.
|
||||||
|
coût réalisé : valeur courante du plus court chemin depuis l'origine vers le sommet. Pour éviter toute confusion plus tard, ne l'appelez pas simplement coût.
|
||||||
|
père : correspond au sommet précédent sur le chemin correspondant au plus court chemin courant. Afin de reconstruire le chemin à la fin de l'algorithme, mieux vaut stocker l'arc plutôt que seulement le père.
|
||||||
|
Ajoutez les getters.
|
||||||
|
Important pour la suite : une méthode getCost() qui renvoie le coût de ce label. Pour le moment, le coût est égal au coût réalisé.
|
||||||
|
*/
|
||||||
|
private int sommetCourant;
|
||||||
|
private Boolean marque;
|
||||||
|
private double coutRealise;
|
||||||
|
private Arc pere;
|
||||||
|
public Label(int sommetCourant,Boolean marque,double coutRealise, Arc pere){
|
||||||
|
this.sommetCourant=sommetCourant;
|
||||||
|
this.marque=marque;
|
||||||
|
this.coutRealise=coutRealise;
|
||||||
|
this.pere=pere;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSommetCourant() {
|
||||||
|
return sommetCourant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getMarque() {
|
||||||
|
return marque;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCoutRealise() {
|
||||||
|
return coutRealise;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCost(){
|
||||||
|
return coutRealise;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -153,7 +153,8 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
||||||
currentSize--;
|
currentSize--;
|
||||||
percolateDown(ind);
|
percolateDown(ind);
|
||||||
percolateUp(ind);
|
percolateUp(ind);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
currentSize--;
|
currentSize--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue