12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package org.insa.graphs.algorithm.shortestpath;
-
- import org.insa.graphs.model.Arc;
- import org.insa.graphs.model.Node;
-
- public class Label implements Comparable<Label>{
-
- //quelles valeurs de protection?
- protected Node sommet_courant;
-
- //vrai quand cout_min définitivement connu par l'algo
- public boolean marque;
-
- //valeur courante du plus court chemin, de l'origine au sommet
- protected float cout;
-
- //arc (permettant d'avoir le sommet) précédent sur le plus court chemin courant
- protected Arc pere;
-
-
- //constructeur
- public Label(Node sommet,Arc padre, float prix) {
- this.sommet_courant=sommet;
- this.pere=padre;
- this.cout=prix;
- this.marque=false;//!\\ pas sûr que ce soit une bonne idée
- }
-
- public Label(Node sommet,Arc padre, float prix, boolean mark) {
- this.sommet_courant=sommet;
- this.pere=padre;
- this.cout=prix;
- this.marque=mark;
-
- }
-
- public float getCost() {
- return this.cout;
- }
-
- //fonction de comparaison
- public int compareTo(Label comp) {
- float diff= this.cout-comp.cout;
- if (diff>0) {
- return 1;
- }else if (diff<0) {
- return -1;
- }else {
- return 0;
- }
- }
- }
|