-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathRouteRepository.java
More file actions
35 lines (26 loc) · 1.43 KB
/
Copy pathRouteRepository.java
File metadata and controls
35 lines (26 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package subway.domain;
import org.jgrapht.alg.shortestpath.DijkstraShortestPath;
import java.util.List;
public class RouteRepository {
public static void init() {
RouteResource.init();
}
public static double getTotalDistance(String startStation, String endStation) {
DijkstraShortestPath dijkstraShortestPath = new DijkstraShortestPath(RouteResource.getDistanceGraph());
return dijkstraShortestPath.getPath(startStation, endStation).getWeight();
}
public static double getTotalTime(String startStation, String endStation) {
DijkstraShortestPath dijkstraShortestPath = new DijkstraShortestPath(RouteResource.getTimeGraph());
return dijkstraShortestPath.getPath(startStation, endStation).getWeight();
}
public static List<String> getRouteMinDistance(String startStation, String endStation) {
DijkstraShortestPath dijkstraShortestPath = new DijkstraShortestPath(RouteResource.getDistanceGraph());
List<String> shortestPath = dijkstraShortestPath.getPath(startStation, endStation).getVertexList();
return shortestPath;
}
public static List<String> getRouteMinTime(String startStation, String endStation) {
DijkstraShortestPath dijkstraShortestPath = new DijkstraShortestPath(RouteResource.getTimeGraph());
List<String> shortestPath = dijkstraShortestPath.getPath(startStation, endStation).getVertexList();
return shortestPath;
}
}