From 78879104017b49f491f7edfff48e98ec416b7c6d Mon Sep 17 00:00:00 2001 From: Ksan Date: Fri, 25 Jul 2025 14:18:29 +0200 Subject: [PATCH] test --- src/Graph.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Graph.java b/src/Graph.java index d223d93..ee985c2 100644 --- a/src/Graph.java +++ b/src/Graph.java @@ -20,7 +20,7 @@ public class Graph { CityManager.addCity(city); } Map result = - graph.calculateShortestPath(cities.getFirst(), cities.get(3), "price"); + graph.calculateShortestPath(cities.getFirst(), cities.get(3), "hops"); System.out.println( cities.getLast().getName() + " = " + result.get(cities.get(3).getLocation())); } @@ -55,10 +55,13 @@ public class Graph { Location neighborLocation = neighborCity.getLocation(); double newCost = 0.0; + double currentCost = distances.get(current.getLocation()); if (type.equals("price")) { newCost = distances.get(current.getLocation()) + dep.getPrice(); } else if (type.equals("time")) { newCost = distances.get(current.getLocation()) + dep.getDuration(); + } else if (type.equals("hops")) { + newCost = currentCost + 1; } if (newCost < distances.get(neighborLocation)) {