Minimize diameter of a tree Hi! I have an acyclic undirected unweighted connected graph (a tree :) ), and I have to disconnect an edge and create a new one to minimize the diameter. 
For now, I do a bfs on a arbitrary node, find the furtherest node, start another bfs from this node and I get the diameter in O(2n). One of the neighbor from the node that have distance equals to (diameter+1)/2 is the edge to disconnect.
After that, I have two different connected component. So i'll find on both component the node that has lowest diameter, and connect it.
Obviously this solution is not perfect, do you have any hint? 
Sorry for my bad english...
 A: You may not be able to decrease the diameter at all with a single cut, for example for the Y-shaped tree (Mercedes sign-shaped tree).  At any rate in order to decrease the diameter you will have to deal with the midpoint of the tree (midpoint of the longest imbedded path).  It seems the number of edges you will have to remove depends on the valence at the midpoint (or adjacent vertices).
A: The diameter of a tree is the length of a longest path, so to reduce the diameter you must remove an edge from each longest path.  Find the center by repeatedly removing all the leaves until only one or two vertices are left (BFS is a terrible way to do it). If the center is an edge, removing that reduces the diameter.  If the center is a vertex, you need to remove some edges incident to that vertex.  Every longest path passes through the center.  You need to remove enough edges incident to the center so that one edge from each longest path is included; it could be anything from one edge to all but one of the edges incident to the center.
A: It is a real possibility that you will not be able to change the diameter by changing one edge. I think this is an efficient best possible procedure for doing what you can.
Find the diameter and center by repeatedly removing all leaves. Either the diameter is odd and the center is an edge or the diameter is even and the center is a vertex.
When the diameter is odd consider the tree one step before (of diameter 3), if it is anything other than a path you can't decrease the diameter. Otherwise, delete the central edge, this results in two trees of even diameter. Find the center of each and connect those with an edge. 
If the diameter is even then there is a central vertex and the tree one step before has diameter 2. If it is a path of length two, delete one of those two edges from the starting tree, then proceed as above, otherwise you again can not decrease the diameter by changing one edge.
