diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java index af1c1db..1e5911c 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java @@ -43,7 +43,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { Node nodeOriginel=data.getOrigin(); Node nodeDestination=data.getDestination(); - BinaryHeap leTas=new BinaryHeap; + BinaryHeap leTas=new BinaryHeap; List listeSuccesseurs; @@ -55,18 +55,19 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { System.out.println("Le node originel n'a pas de successeurs \n"); } - //les mettre ds le tas (les destinations de l'arc pas les arcs en eux-mêmes) + //les mettre ds le tas for(Arc arcActuel : listeSuccesseurs){ - leTas.insert(arcActuel.getDestination()); + leTas.insert(arcActuel); } - + + // when the algorithm terminates, return the solution that has been found return solution; } diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java index ac4fbb5..f03f626 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java @@ -1,8 +1,9 @@ package org.insa.graphs.algorithm.shortestpath; 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). 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. 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 double coutRealise; 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.marque=marque; this.coutRealise=coutRealise; this.pere=pere; } - public int getSommetCourant() { + public Node getSommetCourant() { return sommetCourant; } @@ -37,5 +38,39 @@ private Arc pere; public double getCost(){ 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'"); + } + }