lctree
Rust implementation of Link-cut tree: self-balancing data structure to maintain a dynamic forest of (un)rooted trees under the following operations that take O(logn) amortized time:
link(v, w): creates an edge between nodesvandw.cut(v, w): removes the edge between nodesvandw.connected(v, w): returnstrueif nodesvandware in the same tree.path(v, w): performs calculations on a path between nodesvandw.
Usage
This example shows how to link and cut edges:
use LinkCutTree;
Credits
This crate applies the core concepts and ideas presented in the following sources:
- "A data structure for dynamic trees" by D. Sleator and R. E. TarJan (published in STOC '81).
- Link-cut tree source code by the author D. Sleator.
- MIT's lecture on dynamic graphs: lecture, notes, and source code.
- Helpful blog posts on the concepts of rooted trees, rerooting and splay operations.
License
This project is licensed under the Apache License, Version 2.0 - See the LICENSE.md file for details.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.