4.25

public static String shortest(User user) {

Connection connection = JDBCUtils.getConn();
String startingStation = user.getStarting_Station();
String terminusStation = user.getTerminus_Station();

// 1. 构建站点名称到ID的映射
Map<String, Integer> stationIdMap = buildStationIdMap();

// 2. 构建邻接矩阵
int[][] adjacencyMatrix = adjacency();

// 3. 计算最短路径长度
int shortestPathLength = calculateShortestPath(adjacencyMatrix, startingStation, terminusStation, stationIdMap);

System.out.println(shortestPathLength+startingStation+"erhjhgfdshjhgfds");

// 返回结果,这里可以根据需要将结果转换为字符串
return "Shortest path length from " + startingStation + " to " + terminusStation + " is: " + shortestPathLength;



}

posted @ 2024-06-13 16:07  kxzzow  阅读(15)  评论(0)    收藏  举报