diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java new file mode 100644 index 0000000..58ea349 --- /dev/null +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java @@ -0,0 +1,34 @@ +package org.insa.graphs.algorithm.shortestpath; + +import org.insa.graphs.model.Node; +import org.insa.graphs.model.Point; + +public class LabelStar extends Label { + + private double volOiseau; + + public LabelStar(Node sommetCourant) { + super(sommetCourant); + volOiseau = Double.POSITIVE_INFINITY; + } + + public void setVolOiseau(Node sommetDestination) { + volOiseau = Point.distance(this.getSommetCourant().getPoint(), sommetDestination.getPoint()); + } + + public double getVolOiseau() { + return volOiseau; + } + + public int compareTo(LabelStar o) { + double coutthis = this.volOiseau + this.getCost(); + double coutautre = o.getVolOiseau() + o.getCost(); + if (coutthis == coutautre) { + return Double.compare(this.volOiseau, o.getVolOiseau()); + } + else { + return Double.compare(coutthis, coutautre); + } + } + +}