test
This commit is contained in:
parent
ae113856d0
commit
7887910401
@ -20,7 +20,7 @@ public class Graph {
|
|||||||
CityManager.addCity(city);
|
CityManager.addCity(city);
|
||||||
}
|
}
|
||||||
Map<Location, Double> result =
|
Map<Location, Double> result =
|
||||||
graph.calculateShortestPath(cities.getFirst(), cities.get(3), "price");
|
graph.calculateShortestPath(cities.getFirst(), cities.get(3), "hops");
|
||||||
System.out.println(
|
System.out.println(
|
||||||
cities.getLast().getName() + " = " + result.get(cities.get(3).getLocation()));
|
cities.getLast().getName() + " = " + result.get(cities.get(3).getLocation()));
|
||||||
}
|
}
|
||||||
@ -55,10 +55,13 @@ public class Graph {
|
|||||||
Location neighborLocation = neighborCity.getLocation();
|
Location neighborLocation = neighborCity.getLocation();
|
||||||
|
|
||||||
double newCost = 0.0;
|
double newCost = 0.0;
|
||||||
|
double currentCost = distances.get(current.getLocation());
|
||||||
if (type.equals("price")) {
|
if (type.equals("price")) {
|
||||||
newCost = distances.get(current.getLocation()) + dep.getPrice();
|
newCost = distances.get(current.getLocation()) + dep.getPrice();
|
||||||
} else if (type.equals("time")) {
|
} else if (type.equals("time")) {
|
||||||
newCost = distances.get(current.getLocation()) + dep.getDuration();
|
newCost = distances.get(current.getLocation()) + dep.getDuration();
|
||||||
|
} else if (type.equals("hops")) {
|
||||||
|
newCost = currentCost + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newCost < distances.get(neighborLocation)) {
|
if (newCost < distances.get(neighborLocation)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user