|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Lowest Common Ancestor (LCA) on rooted trees represented as Aleph graphs. More...
#include <algorithm>#include <bit>#include <cstddef>#include <limits>#include <utility>#include <ah-errors.H>#include <tpl_array.H>#include <tpl_dynListStack.H>#include <tpl_dynMapOhash.H>#include <tpl_dynMapTree.H>#include <tpl_graph.H>#include <tpl_sparse_table.H>Go to the source code of this file.
Classes | |
| class | Aleph::lca_detail::Rooted_Tree_Data< GT, SA > |
| struct | Aleph::lca_detail::Depth_Node |
| struct | Aleph::lca_detail::Depth_Node_Min_Op |
| class | Aleph::Gen_Binary_Lifting_LCA< GT, SA > |
| LCA via binary lifting on a rooted tree. More... | |
| class | Aleph::Gen_Euler_RMQ_LCA< GT, SA > |
| LCA via Euler tour + RMQ on depth in a rooted tree. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
| namespace | Aleph::lca_detail |
Typedefs | |
| template<class GT , class SA = Dft_Show_Arc<GT>> | |
| using | Aleph::Binary_Lifting_LCA = Gen_Binary_Lifting_LCA< GT, SA > |
| Convenience alias for binary-lifting LCA. | |
| template<class GT , class SA = Dft_Show_Arc<GT>> | |
| using | Aleph::Euler_RMQ_LCA = Gen_Euler_RMQ_LCA< GT, SA > |
| Convenience alias for Euler+RMQ LCA. | |
Lowest Common Ancestor (LCA) on rooted trees represented as Aleph graphs.
The Lowest Common Ancestor (LCA) of two nodes \(u\) and \(v\) in a rooted tree is the deepest node that is an ancestor of both \(u\) and \(v\).
This header provides two distinct LCA engines with different trade-offs:
Uses a jump table (sparse table over ancestors) where up[k][v] stores the \(2^k\)-th ancestor of node \(v\).
Reduces the LCA problem to a Range Minimum Query (RMQ) problem. It performs an Euler tour (recording nodes as they are visited and returned to) and stores the depths. The LCA of \(u\) and \(v\) is the node with minimum depth between their first occurrences in the tour.
Both classes:
List_Graph, List_SGraph, Array_Graph).SA) to define the tree topology over a general graph.Definition in file LCA.H.