diff --git a/src/dijkstra/Previous.java b/src/dijkstra/Previous.java index 15f2280..461263a 100644 --- a/src/dijkstra/Previous.java +++ b/src/dijkstra/Previous.java @@ -28,12 +28,14 @@ public class Previous implements PreviousInterface { } public ArrayList 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) ; } }