title: Finding all paths between source and destination vertex in Graphx - Scala
body: <p>I want to get all vertices and edges between 2 given vertices(source and destination) in Graphx. So, I think about finding all paths between 2 vetices and then to remove duplicate edges.</p>
  
  <p>here is the shortest path code that I'm following from this <a href="https://gist.github.com/ankurdave/63acd24ef744aaac87e0" rel="nofollow noreferrer">link</a>:</p>
  
  <pre><code>/**
  
  * Returns the shortest directed-edge path from src to dst in the graph. If no path exists, returns
  * the empty list.
  */
  
  def bfs[VD, ED](graph: Graph[VD, ED], src: VertexId, dst: VertexId): Seq   [VertexId] = {
   if (src == dst) return List(src)
  
   // The attribute of each vertex is (dist from src, id of vertex with dist-1)
   var g: Graph[(Int, VertexId), ED] =
     graph.mapVertices((id, _) =&gt; (if (id == src) 0 else Int.MaxValue, 0L)).cache()
  
   // Traverse forward from src
   var dstAttr = (Int.MaxValue, 0L)
   while (dstAttr._1 == Int.MaxValue) {
     val msgs = g.aggregateMessages[(Int, VertexId)](
       e =&gt; if (e.srcAttr._1 != Int.MaxValue &amp;&amp; e.srcAttr._1 + 1 &lt; e.dstAttr._1) {
        e.sendToDst((e.srcAttr._1 + 1, e.srcId))
       },
       (a, b) =&gt; if (a._1 &lt; b._1) a else b).cache()
  
     if (msgs.count == 0) return List.empty
  
     g = g.ops.joinVertices(msgs) {
      (id, oldAttr, newAttr) =&gt;
       if (newAttr._1 &lt; oldAttr._1) newAttr else oldAttr
     }.cache()
  
     dstAttr = g.vertices.filter(_._1 == dst).first()._2
   }
  
   // Traverse backward from dst and collect the path
   var path: List[VertexId] = dstAttr._2 :: dst :: Nil
   while (path.head != src) {
     path = g.vertices.filter(_._1 == path.head).first()._2._2 :: path
   }
   path
  }
  </code></pre>
  
  <p>I'm trying to modify it to get all paths instead of just shortest one. I am only able to get largest or shortest path. How can I get list of lists containing all paths?  </p>