A dynamic forest data structure maintains a forest (and associated data like edge weights) under edge insertions and deletions. Dynamic forests are widely used to solve online and offline graph problems. Well-known examples of dynamic forest data structures are link-cut trees [Sleator and Tarjan '83] and top trees [Alstrup, Holm, de Lichtenberg, and Thorup '05], both of which need O(log n) time per operation. While top trees are more flexible and arguably easier to use, link-cut trees are faster in practice [Tarjan and Werneck '10]. In this paper, we propose an alternative to link-cut trees. Our data structure is based on search trees on trees (STTs, also known as elimination trees) and an STT algorithm [Berendsohn and Kozma '22] based on the classical Splay trees [Sleator and Tarjan '85]. While link-cut trees maintain a hierarchy of binary search trees, we maintain a single STT. Most of the complexity of our data structure lies in the implementation of the STT rotation primitive, which can easily be reused, simplifying the development of new STT-based approaches. We implement several variants of our data structure in the Rust programming language, along with an implementation of link-cut trees for comparison. Experimental evaluation suggests that our algorithms are faster when the dynamic forest is unrooted, while link-cut trees are faster for rooted dynamic forests.
翻译:动态森林数据结构维护一个森林(以及相关数据,如边权),以支持边的插入和删除操作。动态森林广泛应用于解决在线和离线图论问题。著名的动态森林数据结构包括链接-切割树(Sleator 和 Tarjan '83)和顶树(Alstrup、Holm、de Lichtenberg 和 Thorup '05),两者均需每次操作 O(log n) 时间。尽管顶树更灵活且易于使用,但链接-切割树在实践中速度更快(Tarjan 和 Werneck '10)。本文提出一种替代链接-切割树的数据结构。我们的数据结构基于树上的搜索树(STT,也称为消除树)以及基于经典伸展树(Sleator 和 Tarjan '85)的 STT 算法(Berendsohn 和 Kozma '22)。与链接-切割树维护二叉搜索树层级不同,我们仅维护单一STT。该数据结构的大部分复杂性体现在 STT 旋转基本操作的实现上,该操作易于复用,从而简化了基于 STT 的新方法开发。我们使用 Rust 编程语言实现了数据结构的多个变体,并实现了链接-切割树作为比较基准。实验评估表明,当动态森林为无根时,我们的算法速度更快;而当动态森林为有根时,链接-切割树速度更快。