anyone else ever attempted to make shortest_path_between fast?
https://github.com/payrollhero/acts-as-dag/blob/master/lib/dag/edges.rb#L88-L108
#Finds the shortest path between ancestor and descendant returning as an array
def shortest_path_between(ancestor, descendant, path=[])
shortest = []
ancestor.children.each do |child|
if child == descendant
temp = path.clone
temp << child
if shortest.blank? || temp.length < shortest.length
shortest = temp
end
elsif self.find_link(child, descendant)
temp = path.clone
temp << child
temp = self.shortest_path_between(child, descendant, temp)
if shortest.blank? || temp.length < shortest.length
shortest = temp
end
end
end
return shortest
end
anyone else ever attempted to make
shortest_path_betweenfast?https://github.com/payrollhero/acts-as-dag/blob/master/lib/dag/edges.rb#L88-L108