BFS to find minimum length and DFS to find all paths