title: How to find path between two nodes on a minimum spanning tree
body: <p>I have minimum spanning tree and I have created list of adjacency. With help of this list of adjacency I run DFS algorithm and it works correctly.
  Problem is that I want to get path between two nodes.
  Example Tree:
  <a href="https://i.stack.imgur.com/LhnLH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LhnLH.png" alt="enter image description here" /></a></p>
  <p>For example I want to get path from 4 to 6<br>
  <strong>Current output</strong>: 4-3-1-7-2-5-6<br>
  <strong>Wanted output</strong>: 4-3-5-6</p>
  <p>Code:</p>
  <pre><code>void Graph::DFS(int source, int destination)
  {
      Visited[source - 1] = true;
  
      vector&lt;pair&lt;int,int&gt;&gt; adjList = MSTAdjacencyLists[source - 1]; //first is vertice, second is weight
  
      cout &lt;&lt; source &lt;&lt; &quot;-&quot;;
     
      for (int i = 0; i &lt; adjList.size(); i++)
      {
          if (adjList[i].first == destination)
          {
              cout &lt;&lt; adjList[i].first &lt;&lt;&quot;\nFound!!&quot; &lt;&lt; endl;
              break;
          }
  
          if (Visited[adjList[i].first-1] == false)
          {
              DFS(adjList[i].first, destination);
          }
      }
  }
  </code></pre>
  <p>I have read that DFS can be helpful but maybe there are better methods?</p>