diff --git a/app/models/busstop_node.rb b/app/models/busstop_node.rb index 1f340cf..ed94c11 100644 --- a/app/models/busstop_node.rb +++ b/app/models/busstop_node.rb @@ -165,6 +165,7 @@ def self.allUnvisitedNode end def self.findRoute(startID,endID) + allRoutesFound = Array.new if not (Route.all.count > 0) puts "No Routes Exist." return false; @@ -194,10 +195,15 @@ def self.findRoute(startID,endID) while true #break and retrun `pathRoute` if we have reached the destinationNode. if currentNode.id == destNode.id + currentNode.visited = false #we might arrive on this through a different route. print "#{currentNode.to_yaml}" print "Algo complete" - @@graph = [] - return pathRoute + newPathFound = Array.new + newPathFound = pathRoute.map(&:dup) + allRoutesFound << newPathFound + #set the current node to go to. + #Required. Please Implement before calling this method. + raise "Method Imcomplete." end unVisitedNodes = self.allUnvisitedNode shortestDistance = 999999999999999 @@ -231,7 +237,7 @@ def self.findRoute(startID,endID) "\n\n\n" else currentNode == nil puts "end of algo. Reached Back to sourceNode." - return false #end of algo. Reached Back to sourceNode. ###Should Return pathRoute.### + return allRoutesFound #end of algo. Reached Back to sourceNode. ###Should Return pathRoute.### end end #remove this if condition in future.