LabelStar.java

This commit is contained in:
Lea Norgeux 2023-04-12 16:21:17 +02:00
parent 968e5af387
commit 6d48ab154a
2 changed files with 43 additions and 2 deletions

View file

@ -66,6 +66,10 @@ public class Label implements Comparable<Label>{
this.coutRealise = coutRealise;
}
public double getTotalCost() {
return this.coutRealise + ;
}
/**
* Compare the ID of this node with the ID of the given node.
*
@ -76,11 +80,11 @@ public class Label implements Comparable<Label>{
@Override
public int compareTo(Label other) {
if (this.getCost() < other.getCost())
if (this.getTotalCost() < other.getTotalCost())
{
return -1;
}
else if (this.getCost() > other.getCost())
else if (this.getTotalCost() > other.getTotalCost())
{
return 1;
}

View file

@ -0,0 +1,37 @@
package org.insa.graphs.algorithm.shortestpath;
//import org.insa.graphs.model.Arc;
import org.insa.graphs.model.Node;
//import org.insa.graphs.model.Point;
public class LabelStar extends Label {
/* ATTRIBUT */
private double totalCost ;
private double estimationCostDest ;
/* CONSTRUCTEUR */
public LabelStar(Node sommetCourant, Node Dest) {
super(sommetCourant) ;
this.totalCost = 0.0 ;
this.estimationCostDest = sommetCourant.getPoint().distanceTo(Dest.getPoint());
}
/* METHODES */
public void calculTotalCost() {
totalCost = this.getCoutRealise() + this.estimationCostDest ;
}
public double getTotalCost() {
return this.totalCost ;
}
}