1
0
Fork 0
BE_Graphes/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java

47 Zeilen
1,3 KiB
Java

package org.insa.graphs.algorithm.shortestpath;
import org.insa.graphs.model.Node;
import org.insa.graphs.model.Arc;
public class Label implements Comparable<Label> {
Node node;
boolean marked;
boolean reached;
double pathCost;
Arc parentArc;
public Label(Node node) {
this.node = node;
this.marked = false;
this.marked = false;
this.pathCost = Double.MAX_VALUE;
this.parentArc = null;
}
public Node getNode() { return this.node; }
public boolean isMarked() { return this.marked; }
public void mark() { this.marked = true; }
public boolean isReached() { return this.reached; }
public void markReached() { this.reached = true; }
public double getPathCost() { return this.pathCost; }
public void setPathCost(double newCost) { this.pathCost = newCost; }
public Arc getParentArc() { return this.parentArc; }
public void setParentArc(Arc parentArc) { this.parentArc = parentArc; }
public double getCost() {
// function will be modified later
return pathCost;
}
public double getTotalCost() {
// will be overriden for A*
return pathCost;
}
public int compareTo(Label other) {
final double difference = this.getTotalCost() - other.getTotalCost();
return (int) Math.signum(difference);
}
}