An algorithm for finding a representation of a subtree distance

Generalizing the concept of tree metric, Hirai (2006) introduced the concept of subtree distance. A mapping \(d:X\times X \rightarrow \mathbb {R}_+\) is called a subtree distance if there exist a weighted tree T and a family \(\{T_x\,|\,x \in X\}\) of subtrees of T indexed by the elements in X such that \(d(x,y)=d_T(T_x,T_y)\), where \(d_T(T_x,T_y)\) is the distance between \(T_x\) and \(T_y\) in T. Hirai (2006) gave a characterization of subtree distances which corresponds to Buneman’s four-point condition (1974) for the tree metrics. Using this characterization, we can decide whether or not a given matrix is a subtree distance in O\((n^4)\) time. However, the existence of a polynomial time algorithm for finding a tree and subtrees representing a subtree distance has been an open question. In this paper, we show an O\((n^3)\) time algorithm that finds a tree and subtrees representing a given subtree distance.