Fix shortestPath NullPointerException
Fix exception when the departure and the arrival are next to each other. I redefined the path by including the arrival in the path.
This commit is contained in:
1 parent
f91f373986
commit
f3a1f51d10
1 file changed
+6
-4
@@ -28,12 +28,14 @@ public class Previous implements PreviousInterface {
|
||||
}
|
||||
|
||||
public ArrayList<VertexInterface> getShortestPathTo(VertexInterface vertex) {
|
||||
|
||||
|
||||
shortestPath.add(vertex);
|
||||
VertexInterface father = getPrevious(vertex) ;
|
||||
shortestPath.add(father) ;
|
||||
|
||||
if (((Box) getPrevious(father)).isDeparture()) return shortestPath ;
|
||||
else {
|
||||
if (((Box) getPrevious(father)) == null) {
|
||||
shortestPath.add(father);
|
||||
return shortestPath ;
|
||||
} else {
|
||||
return getShortestPathTo(father) ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user