From a0c6437bd2909e34366d14684f85acedc9a27f73 Mon Sep 17 00:00:00 2001 From: Paul ALNET Date: Fri, 3 May 2024 14:46:18 +0200 Subject: [PATCH] feat(astar): create class labelstar --- .../algorithm/shortestpath/LabelStar.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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/LabelStar.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java new file mode 100644 index 0000000..434883b --- /dev/null +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java @@ -0,0 +1,19 @@ +package org.insa.graphs.algorithm.shortestpath; + +import org.insa.graphs.model.Node; +import org.insa.graphs.model.Point; + +public class LabelStar extends Label { + private float distanceToDestination; + + public LabelStar(Node node, Node destination) { + super(node); + // precision was never an answer + distanceToDestination = (float) Point.distance(node.getPoint(), destination.getPoint()); + } + + @Override + public float getTotalCost() { + return this.getCost() + distanceToDestination; + } +}