title: How to find longest path in graph?
body: <p>We are given an Adjacency list of the form</p>
  
  <pre><code>U -&gt; (U,V,C) -&gt; (U,V,C) ...  
  U2 -&gt; ...  
  U3 -&gt; ...  
  .  
  .  
  etc
  </code></pre>
  
  <p><code>(U,V,C)</code> means there's an edge from U to V with cost C.</p>
  
  <p>The given Adjacency list is for a single connected tree with N nodes thus containing N-1 edges.</p>
  
  <p>A set of nodes <code>F=F1,F2,F3...Fk</code> are given.</p>
  
  <p>Now the question is what is the best way to find the longest path amongst the nodes in F?
  Is it possible to do it in O(N)?</p>
  
  <p>Is DFS from each node in F the only option? </p>