title: Use list of lists to save every path in a graph
body: <p>I have to implement dfs algorithm to save all paths from a starting node. So for example i have the following graph:</p>
  
  <p><a href="https://i.stack.imgur.com/0g7fX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0g7fX.png" alt="enter image description here"></a></p>
  
  <p>i have a list <code>path = []</code> to save all the paths starting from node 1. So my list will have only the starting node 1: <a href="https://i.stack.imgur.com/0g7fX.png" rel="nofollow noreferrer">1</a>, then i will check for neighbors of 1 which is the node 2 and the list will be: <code>[1,2]</code>.
  Now i check the neighbors of 2 which are 3 and 4. The list now i think that it will be like <code>[[1,2,3], [1,2,4]]</code> and in the end the final list will be <code>[[1,2,3], [1,2,4,5], [1,2,4,6]]</code>. How can i implement this? I have the neighbors of every node but i dont know how to save every path because im new to python.
  Here is my code:</p>
  
  <pre><code>def bfs(G, s):
      paths = []
      q = queue.Queue()
      visited = []
      q.put(s)
      visited.append(s)
      while not q.empty():
          v = q.get()
          for node in G.neighbors(v):
              #here i think that i must save the paths
              if node not in visited:
                  q.put(node)
                  visited.append(node)
  </code></pre>
  
  <p>I used networkx to create the Graph. So G is my graph, s is the starting node and with <code>G.neighbors(v)</code> i can find the neighbors of node v.</p>