One such method is to select any node, A, and linear time calculations for all other nodes. Assume B is farthest from A. In step 2, find the node farthest from B.
Let d (P, Q) denote the distance from P to Q. Note that if E is the smallest common ancestor of A, B, C, then d (A, B) = d (A, E) + d (E, B) , and also note that d (E, B) ≥ d (E, C).
Edit 1: Algorithm or method - find B farthest from any A; find C farthest from B; argue that d (B, C) is maximal for all vertex pairs in the graph - it seems to sound, but it does not prove above.
On the one hand, it is not necessary that d (E, B) ≥ d (E, C), and on the other hand, this was not enough to establish d (B, C) ≥ d (F, G), where F, G - any nodes in the tree ....
source share