|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Story-driven demo of Heavy-Light Decomposition path/subtree queries. More...
#include <Tree_Decomposition.H>#include <tpl_graph.H>#include <array>#include <cassert>#include <format>#include <iomanip>#include <iostream>#include <string>Go to the source code of this file.
Functions | |
| int | main () |
| Executable example demonstrating heavy-light decomposition on a small tree. | |
Story-driven demo of Heavy-Light Decomposition path/subtree queries.
Each node is a substation with a current maintenance cost. We need:
Definition in file heavy_light_decomposition_example.cc.
| int main | ( | ) |
Executable example demonstrating heavy-light decomposition on a small tree.
Builds a sample "Aurora Power Grid" tree with per-node maintenance costs, constructs an HLD-based query structure, and exercises path-sum and subtree-sum queries. Results are validated against brute-force computations via assertions. The program also performs point updates (increment and set), re-validates affected queries, prints node mappings, query results, and shows how a path is split into base-array segments by the HLD.
Definition at line 133 of file heavy_light_decomposition_example.cc.
References Aleph::Array< T >::create(), Aleph::divide_and_conquer_partition_dp(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), l, and r.