title: How to get all the edges between two vertices in bfs java
body: <p>Currently I'm having only one to one relationship between two vertices. I just want to handle multiple relationships between two vertices. How can I do that?</p>
  
  <p>My current code is :</p>
  
  <pre><code> public Collection&lt;Vertex&lt;V, E&gt;&gt; bfs() {
  
      Queue&lt;Graph.Vertex&lt;V, E&gt;&gt; queue = new ArrayBlockingQueue&lt;&gt;(this.getVertices().size());
      Collection&lt;Vertex&lt;V, E&gt;&gt; queryVertices = new LinkedList&lt;&gt;();
      Vertex&lt;V, E&gt; source = this.vertices.get(0);
      Set&lt;Vertex&lt;V, E&gt;&gt; visited = new HashSet&lt;&gt;();
  
      visited.add(source);
      queue.add(source);
      queryVertices.add(source);
  
      while (!queue.isEmpty()) {
          Graph.Vertex&lt;V, E&gt; v = queue.remove();
          Graph.Vertex&lt;V, E&gt; w;
          while ((w = getAdjUnvisitedVertex(v, visited)) != null) {
              visited.add(w);
              queue.add(w);
              queryVertices.add(w);
          }
      }
  
      return queryVertices;
  }
  
  private Vertex&lt;V, E&gt; getAdjUnvisitedVertex(Vertex&lt;V, E&gt; v, Set&lt;Vertex&lt;V, E&gt;&gt; visited) {
  
      for (Graph.Edge&lt;V, E&gt; edge : v.edges) {
          if (!visited.contains(edge.getTo())) {
              return edge.getTo();
          }
      }
      return null;
  }
  </code></pre>