Moving an edge in a weighted tree to maximize longest path length
Hints:

When you remove an edge from the graph, you split it into two trees.

Given a tree, can you find the longest path in that tree?  (It's not hard.)

Given two trees, can you find which edge to add to make the longest path in the resulting graph as long as possible?  (Hint: first find the longest path in each of the two trees.  Then..)

This is your exercise, so I'll let you take it from here.  That should give you plenty to work with.