|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Heavy-Light and Centroid decomposition on rooted trees represented as Aleph graphs. More...
#include <algorithm>#include <concepts>#include <cstddef>#include <limits>#include <type_traits>#include <utility>#include <ah-errors.H>#include <ahFunction.H>#include <tpl_array.H>#include <tpl_dynListStack.H>#include <tpl_dynMapOhash.H>#include <tpl_dynMapTree.H>#include <tpl_graph.H>#include <tpl_segment_tree.H>Go to the source code of this file.
Classes | |
| struct | Aleph::tree_decomposition_detail::Id_Range |
| class | Aleph::tree_decomposition_detail::Rooted_Tree_Topology< GT, SA > |
| class | Aleph::Gen_Heavy_Light_Decomposition< GT, SA > |
| Heavy-Light Decomposition over a rooted tree represented as an Aleph graph. More... | |
| class | Aleph::Gen_HLD_Path_Query< GT, T, Op, SA > |
| Segment-tree-powered path/subtree queries over an HLD layout. More... | |
| class | Aleph::Gen_Centroid_Decomposition< GT, SA > |
| Centroid decomposition over a rooted tree represented as an Aleph graph. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
| namespace | Aleph::tree_decomposition_detail |
Typedefs | |
| template<class GT , class SA = Dft_Show_Arc<GT>> | |
| using | Aleph::Heavy_Light_Decomposition = Gen_Heavy_Light_Decomposition< GT, SA > |
| Convenience alias for heavy-light decomposition. | |
| template<class GT , typename T = typename GT::Node::Node_Type, class Op = Aleph::plus<T>, class SA = Dft_Show_Arc<GT>> | |
| using | Aleph::HLD_Path_Query = Gen_HLD_Path_Query< GT, T, Op, SA > |
| Convenience alias for segment-tree-backed HLD queries. | |
| template<class GT , class SA = Dft_Show_Arc<GT>> | |
| using | Aleph::Centroid_Decomposition = Gen_Centroid_Decomposition< GT, SA > |
| Convenience alias for centroid decomposition. | |
Heavy-Light and Centroid decomposition on rooted trees represented as Aleph graphs.
This header provides two complementary tree decomposition engines:
Heavy-Light Decomposition (HLD)
Gen_Heavy_Light_Decomposition<GT, SA>Gen_HLD_Path_Query<GT, T, Op, SA>HLD maps each tree node to a position in a base array. Any path query becomes a small number of contiguous segments (O(log n) segments), which can be aggregated with a range-query structure such as Gen_Segment_Tree.
Centroid Decomposition
Gen_Centroid_Decomposition<GT, SA>Centroid decomposition builds a centroid tree in O(n log n), exposing, for each node, its chain of centroid ancestors and the distance to each ancestor. This is ideal for dynamic nearest/farthest marked-node queries, distance-constrained updates, and other "niche but powerful" tree tricks.
Use this header when your tree workload is one of these:
query(path(u, v)) plus point updates. Typical examples: path risk score, path maintenance sum, path min/max.query(subtree(u)) plus point updates. Typical examples: total load/cost under a supervisor/rooted region.LCA.H.tpl_mo_on_trees.H.Both engines work on Aleph graph backends:
List_GraphList_SGraphArray_Graphand accept an optional arc filter SA to project a tree subgraph from a larger graph.
Construction validates that the filtered graph is a simple undirected tree:
n-1 edgesIf validation fails, a domain error is raised with an explanatory message.
Definition in file Tree_Decomposition.H.