The tree edit distance problem is a natural generalization of the classic string edit distance problem. Given two ordered, edge-labeled trees $T_1$ and $T_2$, the edit distance between $T_1$ and $T_2$ is defined as the minimum total cost of operations that transform $T_1$ into $T_2$. In one operation, we can contract an edge, split a vertex into two or change the label of an edge. For the weighted version of the problem, where the cost of each operation depends on the type of the operation and the label on the edge involved, $\mathcal{O}(n^3)$ time algorithms are known for both rooted and unrooted trees. The existence of a truly subcubic $\mathcal{O}(n^{3-\epsilon})$ time algorithm is unlikely, as it would imply a truly subcubic algorithm for the APSP problem. However, recently Mao (FOCS'21) showed that if we assume that each operation has a unit cost, then the tree edit distance between two rooted trees can be computed in truly subcubic time. In this paper, we show how to adapt Mao's algorithm to make it work for unrooted trees and we show an $\widetilde{\mathcal{O}}(n^{(7\omega + 15)/(2\omega + 6)}) \leq \mathcal{O}(n^{2.9417})$ time algorithm for the unweighted tree edit distance between two unrooted trees, where $\omega \leq 2.373$ is the matrix multiplication exponent. It is the first known subcubic algorithm for unrooted trees. The main idea behind our algorithm is the fact that to compute the tree edit distance between two unrooted trees, it is enough to compute the tree edit distance between an arbitrary rooting of the first tree and every rooting of the second tree.
翻译:树编辑距离问题是经典字符串编辑距离问题的自然推广。给定两棵有序、边标记的树 $T_1$ 和 $T_2$,它们之间的编辑距离定义为将 $T_1$ 转换为 $T_2$ 所需操作的最小总代价。在一次操作中,我们可以收缩一条边、将一个顶点拆分为两个或更改边的标签。对于该问题的加权版本,其中每次操作的代价取决于操作类型和所涉及边的标签,针对有根树和无根树均已知 $\mathcal{O}(n^3)$ 时间算法。存在一个真正的次立方 $\mathcal{O}(n^{3-\epsilon})$ 时间算法的可能性不大,因为这将意味着 APSP 问题存在真正的次立方算法。然而,最近 Mao (FOCS'21) 指出,如果假设每次操作具有单位代价,则两棵有根树之间的树编辑距离可以在真正的次立方时间内计算。在本文中,我们展示了如何调整 Mao 的算法以使其适用于无根树,并给出了两棵无根树之间无权重树编辑距离的 $\widetilde{\mathcal{O}}(n^{(7\omega + 15)/(2\omega + 6)}) \leq \mathcal{O}(n^{2.9417})$ 时间算法,其中 $\omega \leq 2.373$ 是矩阵乘法指数。这是首个已知的无根树次立方算法。我们算法的主要思想在于:要计算两棵无根树之间的树编辑距离,只需计算第一棵树的任意一种有根化与第二棵树的每一种有根化之间的树编辑距离。