minor improvement
This commit is contained in:
parent
a828de13ce
commit
727e1d7c2b
@ -31,4 +31,7 @@ public class Node<E> {
|
||||
edges.add(edge);
|
||||
}
|
||||
|
||||
public boolean equals(DijkstraNode other) {
|
||||
return this.name == other.getName();
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,12 @@ public class RouteServer implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dijkstra(String from, String to) {
|
||||
for (DijkstraNode<Edge> node : graph.getNodes()) {
|
||||
node.setMark(false);
|
||||
node.setDist(Double.POSITIVE_INFINITY);
|
||||
node.setPrev(null);
|
||||
}
|
||||
|
||||
Queue<DijkstraNode> pq = new PriorityQueue<DijkstraNode>();
|
||||
DijkstraNode<Edge> start = graph.findNode(from);
|
||||
DijkstraNode<Edge> goal = graph.findNode(to);
|
||||
@ -53,9 +59,7 @@ public class RouteServer implements CommandExecutor {
|
||||
while (!pq.isEmpty()) {
|
||||
DijkstraNode<Edge> current = pq.poll();
|
||||
current.setMark(true);
|
||||
// implement equals for this
|
||||
// if (current.equal(goal)) {
|
||||
if (current.getName() == to) {
|
||||
if (current.equals(goal)) {
|
||||
break;
|
||||
}
|
||||
for (Edge<DijkstraNode> edge : current.getEdges()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user