A handful of BFS and DFS algorithms in Ruby