From 39ea623f84c15305af2fcaa15150118362868070 Mon Sep 17 00:00:00 2001 From: Fu Boyu Date: Fri, 21 Apr 2023 09:39:05 +0200 Subject: [PATCH] =?UTF-8?q?LabelStar=20conmenc=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graphs/algorithm/shortestpath/Label.java | 11 +++++++- .../algorithm/shortestpath/LabelStar.java | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java 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 a5e1f58..8482a2c 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 @@ -56,10 +56,19 @@ { this.currentNode = currentNode; } + + public double getTotalCost() + { + return this.getCost(); + } public int compareTo(Label label) { - return Double.compare(getCost(), label.getCost()); + int i = Double.compare(this.getTotalCost(), label.getTotalCost()); + if (i == 0){ + i = Double.compare(label.getCost(), this.getCost()); + } + return i; } } \ No newline at end of file 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..c78bafb --- /dev/null +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java @@ -0,0 +1,25 @@ +package org.insa.graphs.algorithm.shortestpath; + +import org.insa.graphs.model.*; + +public class LabelStar extends Label { + private double CostEstime; + + public LabelStar(Node node){ + super(node); + this.CostEstime = Double.POSITIVE_INFINITY ; + } + + public double getCostEstime(){ + return CostEstime; + } + + public void setCostEstime(double CostEstime){ + this.CostEstime = CostEstime; + } + + @Override + public double getTotalCost(){ + return super.getCost() + getCostEstime(); + } +}