#16 Update priority queue

This commit is contained in:
HU helene 2024-04-15 13:47:53 +02:00
parent 38f2974bd9
commit 318a915b84

View file

@ -52,6 +52,8 @@ public class Finder {
if (!openSet.contains(neighbor)) { if (!openSet.contains(neighbor)) {
openSet.add(neighbor); openSet.add(neighbor);
updatePriority(openSet, neighbor, fScore.get(neighbor));
} else if (tentativeGScore >= gScore.get(neighbor)) { } else if (tentativeGScore >= gScore.get(neighbor)) {
continue; // This is not a better path. continue; // This is not a better path.
} }
@ -80,12 +82,16 @@ public class Finder {
return totalPath; return totalPath;
} }
public void updatePriority(PriorityQueue<Stop> openSet, Stop node, double newF) {
openSet.remove(node);
node.setF(newF);
openSet.add(node);
}
//TODO: //TODO:
public List<Stop> findPath(double longitude, double latitude){ public List<Stop> findPath(double longitude, double latitude){
return null; return null;
} }
} }