title: Find number of unique routes to specific node using Depth First Search
body: <p>I have a directed graph with vertexes 123456. Using a depth first search, if I wanted to be able to find the number of unique routes from 1-4 (for example), how would I go about doing it? Here is my current DFS.</p>
  
  <pre><code>private final Map&lt;Character, Node&gt; mNodes;
  private final List&lt;Edge&gt; mEdges;
  private List&lt;Node&gt; mVisited = new ArrayList&lt;&gt;();
  int weight;
  int numberOfPaths;
  
  public DepthFirstSearch(Graph graph){
      mNodes = graph.getNodes();
      mEdges = new ArrayList&lt;&gt;(graph.getEdges());
      for(Node node : mNodes.values()){
          node.setVisited(false);
      }
  }
  
  public void depthFirstSearch(Node source){
  
      source.setVisited(true);
      List&lt;Edge&gt; neighbours = source.getNeighbouringEdges(mEdges);
      for(Edge edge : neighbours){
          System.out.println(edge.getFrom().getName()+"-"+edge.getTo().getName());
          if(!edge.getTo().isVisited()){
  
              mVisited.add(edge.getTo());
              weight += edge.getWeight();
              depthFirstSearch(edge.getTo());
  
          }
      }
  
  }
  </code></pre>