This commit is contained in:
HU helene 2024-04-23 21:06:27 +02:00
parent bfa2f14c0b
commit a8357ef564

View file

@ -2,12 +2,19 @@ package fr.u_paris.gla.project.itinerary;
import java.util.*; import java.util.*;
public class Finder { public class Finder {
private Graph graph; private Graph graph;
public Finder(Graph graph) { public Finder(Graph graph) {
this.graph = graph; this.graph = graph;
} }
/**
* return a path from startNode to goalNode using A* algorithm
* @param startNode
* @param goalNode
*/
public List<Stop> findPath(Stop startNode, Stop goalNode) { public List<Stop> findPath(Stop startNode, Stop goalNode) {
double startTime = 43200; //12h double startTime = 43200; //12h
@ -74,6 +81,12 @@ public class Finder {
return null; return null;
} }
/**
* Once we found the destination we reconstruct the path
* @param cameFrom
* @param current
* @return path
*/
private List<Stop> reconstructPath(HashMap<Stop, Stop> cameFrom, Stop current) { private List<Stop> reconstructPath(HashMap<Stop, Stop> cameFrom, Stop current) {
List<Stop> totalPath = new ArrayList<>(); List<Stop> totalPath = new ArrayList<>();
totalPath.add(current); totalPath.add(current);
@ -86,16 +99,17 @@ public class Finder {
return totalPath; return totalPath;
} }
/**
* Update the priority queue
* @param openSet
* @param node
* @param newF
*/
public void updatePriority(PriorityQueue<Stop> openSet, Stop node, double newF) { public void updatePriority(PriorityQueue<Stop> openSet, Stop node, double newF) {
openSet.remove(node); openSet.remove(node);
node.setF(newF); node.setF(newF);
openSet.add(node); openSet.add(node);
} }
//TODO:
public List<Stop> findPath(double longitude, double latitude){
return null;
}
} }