Skip to content

Commit

Permalink
Add node to path and update DijkstraDistanceRouter for path details.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcy362 committed May 9, 2024
1 parent a79f02a commit ba061a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/main/java/com/mobo/mobosubway/data/PathInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public void addNodeToPath(String id) {
detail.add(id);
}

public void addNodeToPath(Station station) {
detail.add(station.getId());
PathNode pathNode = new PathNode();
pathNode.setStationName(station.getName());
pathNode.setStationId(station.getId());
pathDetail.add(pathNode);
}

public boolean accessible() {
return length < MAX || distance < MAX_DISTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ protected void handleAllPath(Map<String, PathInfo> knownPath, Map<String, PathIn
nextPath.setDistance(calculateNewDistance(nowPath, currentStation, nextPath));
log.debug("set " + stations.get(nextPath.getStationId()).getName() + " distance to " + nextPath.getDistance());
nextPath.setDetail(new ArrayList<>(nowPath.getDetail()));
nextPath.addNodeToPath(nextPath.getStationId());
nextPath.setPathDetail(new ArrayList<>(nowPath.getPathDetail()));
nextPath.addNodeToPath(stations.get(nextPath.getStationId()));
});

//选出离当前站点距离最小的站,作为下一个要处理的站点
Expand Down

0 comments on commit ba061a0

Please sign in to comment.