From 0df767c9b5168e003adb92cb23bbf450129cc829 Mon Sep 17 00:00:00 2001 From: HU helene Date: Fri, 29 Mar 2024 09:56:22 +0100 Subject: [PATCH] =?UTF-8?q?#16=20Adaptation=20mod=C3=A9lisation=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../u_paris/gla/project/itinerary/Finder.java | 2 ++ .../u_paris/gla/project/itinerary/Graph.java | 7 +++-- .../u_paris/gla/project/itinerary/Main.java | 31 ++++++++++++++++++- .../u_paris/gla/project/itinerary/Stop.java | 11 +++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java b/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java index 6bfcf95..a8a8312 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java @@ -29,6 +29,8 @@ public class Finder { while (!openSet.isEmpty()) { Stop current = openSet.poll(); + //System.out.println(current); + //System.out.println(graph.getConnections(current)); if (current.equals(goalNode)) { return reconstructPath(cameFrom, current); diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java b/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java index 3009bbc..3025a04 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java @@ -14,8 +14,6 @@ public class Graph{ this.connections = connections; } - - public Set getConnections(Stop node) { return connections.get(node); } @@ -23,4 +21,9 @@ public class Graph{ public Set getNodes() { return nodes; } + + + public Map> getConnections() { + return connections; + } } diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Main.java b/src/main/java/fr/u_paris/gla/project/itinerary/Main.java index eb0266d..781ed19 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Main.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Main.java @@ -77,6 +77,11 @@ public class Main{ connections.computeIfAbsent(fromStop, k -> new HashSet<>()).add(connection); } + public static void find(Graph graph){ + + + } + public static void main(String[] args){ if (args.length != 0) { LOGGER.severe("Invalid command line. Target file names are in the main file for now."); @@ -89,9 +94,33 @@ public class Main{ HashMap tmp = new HashMap<>(); CSVTools.readCSVFromFile(TRACE_FILE_NAME, (String[] line) -> addLine(line, nodes, tmp, connections)); - Graph 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> 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 res = finder.findPath(porteivry, chatelet); + + for (Stop element : res) { + System.out.println(element); + } + } catch (IOException e) { LOGGER.log(Level.SEVERE, "Error while reading the line paths", e); } + + } } diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Stop.java b/src/main/java/fr/u_paris/gla/project/itinerary/Stop.java index bc0ac4d..70c6e79 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Stop.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Stop.java @@ -25,6 +25,17 @@ public class Stop implements GraphNode { this.longitude = longitude; } + @Override + public String toString() { + return "Stop{" + + "id=" + id + + ", lines=" + lines + + ", name='" + name + '\'' + + ", latitude=" + latitude + + ", longitude=" + longitude + + '}'; + } + @Override public int getId(){ return id;