I have a tree-like graph/structure with the vertices as cities and let's say that the longest path is from 's' and 't'. Now, I want to prove that the longest path from any other city (let's say 'w') with end at either s or t.
What I am thinking about are two different cases:
If 'w' exists in the longest path between s and t then the longest path will obviously will either s or t if we just run a DFS.
If w is outside of the longest path. This is where I am confused. If I run a DFS how can I guarantee that it will end up giving me the longest distance that ends at either s or t.