title: All paths in directed tree graph from root to leaves in igraph R
body: <p>Given is a tree:</p>
  
  <pre><code>library(igraph)
  
  # setup graph
  g= graph.formula(A -+ B,
                   A -+ C,
                   B -+ C,
                   B -+ D,
                   B -+ E
  )
  plot(g, layout = layout.reingold.tilford(g, root="A"))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/CKRyI.png" alt="enter image description here"></p>
  
  <p>Vertex <code>"A"</code> is the root of the tree, while vertices <code>"C", "D", "E"</code> are considered as terminal leaves.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>The task is to find all paths between root and leaves. I fail with following code, as it only provides the shortest paths: </p>
  
  <pre><code># find root and leaves
  leaves= which(degree(g, v = V(g), mode = "out")==0, useNames = T)
  root= which(degree(g, v = V(g), mode = "in")==0, useNames = T)
  
  # find all paths
  paths= lapply(root, function(x) get.all.shortest.paths(g, from = x, to = leaves, mode = "out")$res)
  named_paths= lapply(unlist(paths, recursive=FALSE), function(x) V(g)[x])
  named_paths
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>$A1
  Vertex sequence:
  [1] "A" "C"
  
  $A2
  Vertex sequence:
  [1] "A" "B" "D"
  
  $A3
  Vertex sequence:
  [1] "A" "B" "E"
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>How can I find all paths including the vertex sequence: <code>"A" "B" "C"</code>?</p>
  
  <p>My understanding is, that the missing sequence <code>"A" "B" "C"</code> is not provided by <code>get.all.shortest.paths()</code> as the path from <code>"A"</code> to <code>"C"</code> via the vertex sequence: <code>"A" "C"</code> (which is found in list element <code>$A1</code>) is shorter. So <code>igraph</code> works properly.
  <strong>Nevertheless I am looking for a code solution to get all paths from the root to all leaves in form of a <code>R list</code>.</strong> </p>
  
  <p>Comment:</p>
  
  <p>I am aware that for large trees the algorithm covering all combinations might become expensive, but my real application is relatively small.</p>