This repository implements balanced transformed minimum spanning trees (T-MSTs) for incremental MST maintenance and path-max queries. We will release the accompanying paper separately.
Every structure is a header-only class in include/tmst/ with the same
interface (checked by the concept tmst::IncrementalMST in common.h):
using weight_type = W; // template parameter, default int
explicit T(int n); // n vertices, no edges
void Insert(int u, int v, W w);
std::optional<W> PathMax(int u, int v); // nullopt if u == v or disconnected
bool Check() const; // verifies invariants for debugging
static std::string Name();Height is the maximum vertex depth in edges after an operation on
| Implementation | Height | Insert |
PathMax |
Search-tree analogue |
|---|---|---|---|---|
OECForest<W>oec_forest.h |
|
|
|
Treap |
WeightedDSU<W>weighted_dsu.h |
|
|
|
Treap (OEC variant) |
StrictAMTree<LinkMode, W, kHash>am_tree_strict.h |
|
|
Weight-balanced tree (BB[α]) | |
LazyAMTree<LinkMode, W>am_tree_lazy.h |
|
|
— | |
BottleneckTree<W>bottleneck_tree.h |
|
|
Splay tree | |
RivalTree<LinkMode, W, kHash>rival_tree.h |
|
|
AVL tree | |
LinkCutTree<W>link_cut_tree.h · baseline |
|
|
|
— |
With
The w.h.p. bounds assume uniformly random vertex priorities independent of the
operation sequence. They hold simultaneously over polynomially many insertions
and the intervening queries. OECForest and WeightedDSU default to seed 0
for reproducibility. For a fixed vertex in a component of size
LinkMode selects the perch-based link (kPerch) or the stitch-based link
(kStitch). The OEC-forest allows ties. The bounds for the two-sided stitch,
including weighted DSU, and for BottleneckTree's access rule assume distinct
edge weights. The insertion bounds for StrictAMTree and RivalTree use the
default array of child-list heads, which takes kHash = true stores the nonempty groups in
Every structure implements its own link. The shared path-max walk and forest
check are in common.h. The weight type W defaults to
int. Every inserted weight must be less than std::numeric_limits<W>::max(),
the weight reserved for the virtual parent edge of a root.
The technical report contains the algorithms, theorems, and proofs for the OEC-forest, priority-based stitch, weighted DSU, and Rival-tree.
Requires CMake >= 3.18 and a C++20 compiler.
cmake -B build
cmake --build build -j
./build/test/tmst_test [seed] # randomized tests against brute force
./build/bench/tmst_bench [n] [m] [q] [seed]Status: the OEC-forest, weighted DSU, AM-tree (both versions, both links), BottleneckTree, Rival-tree (both links), and Link-Cut Tree are implemented and tested.