Commit f9a3e967 by 李进峰

is neighbour api update

parent 2d109468
...@@ -306,13 +306,15 @@ public class GameEnv implements Serializable{ ...@@ -306,13 +306,15 @@ public class GameEnv implements Serializable{
int y = this.mapNames.get(placeB); int y = this.mapNames.get(placeB);
if(this.mapGraph[x][y] == 1) { if(this.mapGraph[x][y] == 1) {
return 1; return 1;
}else { }else if(this.getAllPath(placeA, placeB).size()>1) {
return 2; return 2;
}else {
return 3;
} }
} }
} }
// 两点之间的路径 // 使用广度优先算法单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。 // 两点之间的路径 // 使用广度优先算法单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。
public List<String> queryPathBySite(String placeA, String placeB){ public List<String> getAllPath(String placeA, String placeB){
List<String> paths = new ArrayList<String>(); List<String> paths = new ArrayList<String>();
Deque<PlaceLink> placeDeque = new ArrayDeque<PlaceLink>(); Deque<PlaceLink> placeDeque = new ArrayDeque<PlaceLink>();
Integer start = this.mapNames.get(placeA); Integer start = this.mapNames.get(placeA);
...@@ -350,6 +352,10 @@ public class GameEnv implements Serializable{ ...@@ -350,6 +352,10 @@ public class GameEnv implements Serializable{
} }
} }
Collections.reverse(paths); Collections.reverse(paths);
return paths;
}
public List<String> queryPathBySite(String placeA, String placeB){
List<String> paths = this.getAllPath(placeA, placeB);
List<String> path = new ArrayList<String>(); List<String> path = new ArrayList<String>();
for(int i=0; i<paths.size(); i++) { for(int i=0; i<paths.size(); i++) {
if(i!=0&&i!=(paths.size()-1)) { if(i!=0&&i!=(paths.size()-1)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment