It is always possible to find a minimum-diameter spanning tree with one or two vertices that are not leaves. This can be proven by transforming any other tree into a tree of this special form, without increasing its diameter. To do so, consider the longest path in any given tree (its diameter path), and the vertex or edge at the midpoint of this path. If there is a vertex at the midpoint, it is the non-leaf vertex of a
star, whose diameter is at most that of the given tree. If the midpoint is interior to an edge of the given tree, then there exists a tree that includes this edge, and in which every remaining vertex is a leaf connected to the endpoint of this edge that is nearest in the given tree, with diameter at most that of the given tree. Because of this special form, it is possible to construct a minimum-diameter spanning tree of n points in time O(n^3), assuming that the distance between two points can be computed in constant time. To do so, test all candidates for the single point or pair of points that are not leaves. Each single point can be tested in O(n) time. Each pair of points can also be tested in O(n), after a precomputation step in which, for each point, the other points are sorted by their distance from it. To test a pair of points, start with a tree in which all remaining points are attached to one point of the pair, and then in decreasing order by distance from that point, reattach these points one at a time to the other point of the pair, keeping track of the diameter of the tree at each step. There are O(n^2) candidate pairs of non-leaf points, each of which can be evaluated in time O(n), giving a total time bound of O(n^3). The problem of constructing a minimum-diameter spanning tree is different from computing the diameter of the given points, the maximum pairwise distance. For some sets of points, the diameter of the points and the diameter of their minimum-diameter spanning tree are equal; for others (for instance, three equidistant points) these two distances can differ from each other by a factor of two. ==In graphs==