I want to find all paths between two nodes in a graph. I wrote a recursive function that finds all the paths with help of the depth-first-search algorithm. But for bigger graphs, it is very inefficient, so that i can not use it for my programm.

I am thinking about implementing an **iterative method for my problem**. This will be very time consuming for me. So did anybody know if this would make sense?

Is an iterative way more efficient in this case? Or is it possible to optimize my recursive method?

My current function:

```
function RecDFS(g::GenericGraph, visited)
    nodes = out_neighbors(visited[length(visited)], g) 

    for i in nodes
    if in(i,visited)
        continue
    end

    if i.label == "End"
        push!(visited,i)
        println(visited) # print every path from the first node in visited to the node with the label End
        pop!(visited)
        break
    end

    # continue recursive..
    for i in nodes
        if (in(i, visited) || i.label == "End")
            continue
        end
        push!(visited,i)
        depthFirstSearchAllI(g, visited)
        pop!(visited)
    end
end

```