Merge branch 'main' of https://git.etud.insa-toulouse.fr/bezza/BE-Graphe
This commit is contained in:
commit
21301949a8
2 changed files with 40 additions and 5 deletions
|
|
@ -75,11 +75,11 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// when the algorithm terminates, return the solution that has been found
|
// when the algorithm terminates, return the solution that has been found
|
||||||
return solution;
|
return solution;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package org.insa.graphs.algorithm.shortestpath;
|
package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
import org.insa.graphs.model.Arc;// sinon cela compilait pas
|
import org.insa.graphs.model.Arc;// sinon cela compilait pas
|
||||||
|
import org.insa.graphs.model.Node;
|
||||||
|
|
||||||
public class Label {
|
public class Label implements Comparable {
|
||||||
|
|
||||||
/* sommet courant : sommet associé à ce label (sommet ou numéro de sommet).
|
/* 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.
|
marque : booléen, vrai lorsque le coût min de ce sommet est définitivement connu par l'algorithme.
|
||||||
|
|
@ -11,18 +12,18 @@ père : correspond au sommet précédent sur le chemin correspondant au plus cou
|
||||||
Ajoutez les getters.
|
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é.
|
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 Node sommetCourant;
|
||||||
private Boolean marque;
|
private Boolean marque;
|
||||||
private double coutRealise;
|
private double coutRealise;
|
||||||
private Arc pere;
|
private Arc pere;
|
||||||
public Label(int sommetCourant,Boolean marque,double coutRealise, Arc pere){
|
public Label(Node sommetCourant,Boolean marque,double coutRealise, Arc pere){
|
||||||
this.sommetCourant=sommetCourant;
|
this.sommetCourant=sommetCourant;
|
||||||
this.marque=marque;
|
this.marque=marque;
|
||||||
this.coutRealise=coutRealise;
|
this.coutRealise=coutRealise;
|
||||||
this.pere=pere;
|
this.pere=pere;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSommetCourant() {
|
public Node getSommetCourant() {
|
||||||
return sommetCourant;
|
return sommetCourant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,5 +38,39 @@ private Arc pere;
|
||||||
public double getCost(){
|
public double getCost(){
|
||||||
return coutRealise;
|
return coutRealise;
|
||||||
}
|
}
|
||||||
|
//renvoit 0 si égal sinon renvoit la différence.
|
||||||
|
public int compareTo(Label L){
|
||||||
|
int retour;
|
||||||
|
if (coutRealise==L.getCoutRealise()){
|
||||||
|
retour=0;
|
||||||
|
}else {
|
||||||
|
retour=(int)(coutRealise-L.getCoutRealise());
|
||||||
|
}
|
||||||
|
return retour;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSommetCourant(Node sommetCourant) {
|
||||||
|
this.sommetCourant = sommetCourant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarque(Boolean marque) {
|
||||||
|
this.marque = marque;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoutRealise(double coutRealise) {
|
||||||
|
this.coutRealise = coutRealise;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPere(Arc pere) {
|
||||||
|
this.pere = pere;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Object arg0) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'compareTo'");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue