#16 Adaptation modélisation debug

This commit is contained in:
HU helene 2024-03-29 09:56:22 +01:00
parent a9f4d17b97
commit 0df767c9b5
4 changed files with 48 additions and 3 deletions

View file

@ -29,6 +29,8 @@ public class Finder {
while (!openSet.isEmpty()) { while (!openSet.isEmpty()) {
Stop current = openSet.poll(); Stop current = openSet.poll();
//System.out.println(current);
//System.out.println(graph.getConnections(current));
if (current.equals(goalNode)) { if (current.equals(goalNode)) {
return reconstructPath(cameFrom, current); return reconstructPath(cameFrom, current);

View file

@ -14,8 +14,6 @@ public class Graph{
this.connections = connections; this.connections = connections;
} }
public Set<Connection> getConnections(Stop node) { public Set<Connection> getConnections(Stop node) {
return connections.get(node); return connections.get(node);
} }
@ -23,4 +21,9 @@ public class Graph{
public Set<Stop> getNodes() { public Set<Stop> getNodes() {
return nodes; return nodes;
} }
public Map<Stop, Set<Connection>> getConnections() {
return connections;
}
} }

View file

@ -77,6 +77,11 @@ public class Main{
connections.computeIfAbsent(fromStop, k -> new HashSet<>()).add(connection); connections.computeIfAbsent(fromStop, k -> new HashSet<>()).add(connection);
} }
public static void find(Graph graph){
}
public static void main(String[] args){ public static void main(String[] args){
if (args.length != 0) { if (args.length != 0) {
LOGGER.severe("Invalid command line. Target file names are in the main file for now."); LOGGER.severe("Invalid command line. Target file names are in the main file for now.");
@ -89,9 +94,33 @@ public class Main{
HashMap<String, Stop> tmp = new HashMap<>(); HashMap<String, Stop> tmp = new HashMap<>();
CSVTools.readCSVFromFile(TRACE_FILE_NAME, CSVTools.readCSVFromFile(TRACE_FILE_NAME,
(String[] line) -> addLine(line, nodes, tmp, connections)); (String[] line) -> addLine(line, nodes, tmp, connections));
Graph<Stop> graph = new Graph<>(nodes, connections);
Stop porteivry = tmp.get("48.821352988336876, 2.369294978223312");
Stop repu = tmp.get("48.867687468165165, 2.3640990472225725");
Graph graph = new Graph(nodes, connections);
int cpt = 0;
for (Map.Entry<Stop, Set<Connection>> entry : graph.getConnections().entrySet()) {
if (entry.getValue() == null) cpt +=1;
}
Stop garenord = tmp.get("48.88143149182458, 2.357767843520973");
Stop chatelet = tmp.get("48.856953460785334, 2.3481609912345776");
//System.out.println(graph.getConnections(garenord));
//System.out.println(cpt);
//System.out.println(graph.getConnections(porteivry));
Finder finder = new Finder(graph);
List<Stop> res = finder.findPath(porteivry, chatelet);
for (Stop element : res) {
System.out.println(element);
}
} catch (IOException e) { } catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error while reading the line paths", e); LOGGER.log(Level.SEVERE, "Error while reading the line paths", e);
} }
} }
} }

View file

@ -25,6 +25,17 @@ public class Stop implements GraphNode {
this.longitude = longitude; this.longitude = longitude;
} }
@Override
public String toString() {
return "Stop{" +
"id=" + id +
", lines=" + lines +
", name='" + name + '\'' +
", latitude=" + latitude +
", longitude=" + longitude +
'}';
}
@Override @Override
public int getId(){ public int getId(){
return id; return id;