0

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:

  1. 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.

  2. 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.

max
  • 167
  • 2
  • 9
  • Can't prove that -- it's not true. If s-t is the longest path, then there cannot of course be longer paths, but there may be many paths just as long that don't end at either s or t. – Matt Timmermans Sep 13 '21 at 02:38
  • There appear to be several grammar issues in your post, and that makes your problem ambiguous. Could you please clarify precisely what you are trying to prove? – Stef Sep 13 '21 at 10:14

1 Answers1

1

enter image description here

Your second scenario leads to a contradiction. Let's say, we have a tree, from s to t the distance is a + c.

There is another node p, let's say from your idea, the longest path from w ends at p (some node other than s or t).

Now, as s-t is the longest path, we know a > b, c > b (otherwise the longest path from s, t would end at w).

But, if the longest path from w ends at p, it must be true that d > a, d > c (otherwise the path should end at s or t).

Now, this clearly leads to a contradiction. If d is both larger than a and c, the longest path must include d. So, this can not be true.

Zabir Al Nazi
  • 10,298
  • 4
  • 33
  • 60