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:
antograb committed 2018-01-03 10:35:09 +01:00
1 parent f91f373986
commit f3a1f51d10
1 file changed
+5 -3
+5 -3
View File
@@ -29,11 +29,13 @@ public class Previous implements PreviousInterface {
public ArrayList<VertexInterface> getShortestPathTo(VertexInterface vertex) { public ArrayList<VertexInterface> getShortestPathTo(VertexInterface vertex) {
shortestPath.add(vertex);
VertexInterface father = getPrevious(vertex) ; VertexInterface father = getPrevious(vertex) ;
shortestPath.add(father) ;
if (((Box) getPrevious(father)).isDeparture()) return shortestPath ; if (((Box) getPrevious(father)) == null) {
else { shortestPath.add(father);
return shortestPath ;
} else {
return getShortestPathTo(father) ; return getShortestPathTo(father) ;
} }
} }