Compare commits
2 commits
224ab4a97d
...
24012e3afc
| Author | SHA1 | Date | |
|---|---|---|---|
| 24012e3afc | |||
| a0c6437bd2 |
2 changed files with 33 additions and 1 deletions
|
|
@ -33,8 +33,21 @@ public class Label implements Comparable<Label> {
|
||||||
return pathCost;
|
return pathCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getTotalCost() {
|
||||||
|
// will be overriden for A*
|
||||||
|
return pathCost;
|
||||||
|
}
|
||||||
|
|
||||||
public int compareTo(Label other) {
|
public int compareTo(Label other) {
|
||||||
|
final float difference = this.getTotalCost() - other.getTotalCost();
|
||||||
|
final boolean equal = Math.abs(difference) < 1.0;
|
||||||
|
if (equal) {
|
||||||
|
return 0;
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
// TODO ensure this works properly
|
// TODO ensure this works properly
|
||||||
return (int)(this.pathCost - other.pathCost);
|
// return (int)(this.pathCost - other.pathCost);
|
||||||
|
return this.pathCost - other.pathCost < 0 ? -1 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue