An implementation of the heavy path decomposition on trees. More...
#include <ogdf/graphalg/steiner_tree/HeavyPathDecomposition.h>
Public Member Functions | |
HeavyPathDecomposition (const EdgeWeightedGraphCopy< T > &treeEWGraphCopy) | |
T | getBottleneckSteinerDistance (node x, node y) const |
computes in the bottleneck distance between terminals x and y More... | |
node | lowestCommonAncestor (node x, node y) const |
computes the lowest common ancestor of nodes x and y using the hpd More... | |
Private Member Functions | |
node | binarySearchUpmostTerminal (node v, const std::vector< node > &chainOfTerminals) const |
performs a binary search on chainOfTerminals, searches for the closest node to the root on chainOfTerminals that sits below v More... | |
void | buildMaxSegmentTree (std::vector< T > &segmentTree, const int nodeIndex, const int left, const int right, const std::vector< T > &baseArray) const |
builds a max segment tree on the baseArray More... | |
void | computeBottleneckOnBranch (node x, node ancestor, T &longestPathDistance, T &fromLowestToAncestor) const |
computes for the path from x to ancestor the maximum distance (sum of edges) between any two consecutive terminals using the hpd updates it in longestPathDistance also puts in fromLowestToAncestor the sum of edges from the last terminal found to the ancestor (the last terminal is special since its Steiner ancestor is ancestor for ancestor as well, so we would consider a wrong part of the path More... | |
void | computeLongestDistToSteinerAncestorOnChain () |
creates for every chain an array with the maximum of every prefix of a fictive array which keeps for every node the sum of the edges on the path from it to its closest terminal ancestor More... | |
void | computeLongestDistToSteinerAncestorSegTree () |
creates for every chain a segment tree built on a fictive array which keeps for every node the sum of the edges on the path from it to its closest terminal ancestor More... | |
void | dfsHeavyPathDecomposition (node v, node closestSteinerUpNode) |
performs the heavy path decomposition on the tree belonging to the class updates the fields of the class More... | |
T | distanceToAncestor (node v, node ancestor) const |
computes the sum of all edges on the path from v to ancestor v must be in ancestor's subtree More... | |
T | getMaxSegmentTree (const std::vector< T > &segmentTree, const int nodeIndex, const int left, const int right, const int queryLeft, const int queryRight) const |
extracts the maximum on the required interval More... | |
Private Attributes | |
NodeArray< int > | chainOfNode |
the index of a node's chain More... | |
std::vector< std::vector< node > > | chains |
list of chains of nodes corresponding to the decomposition More... | |
std::vector< std::vector< node > > | chainsOfTerminals |
list of chains only of terminals corresponding to the decomposition More... | |
NodeArray< node > | closestSteinerAncestor |
the highest-level Steiner ancestor of the current node More... | |
NodeArray< T > | distanceToRoot |
the length of the edge to his father More... | |
std::vector< node > | fatherOfChain |
the first node from bottom up that does not belong to the chain More... | |
const NodeArray< bool > | isTerminal |
isTerminal of the desc tree More... | |
std::vector< std::vector< T > > | longestDistToSteinerAncestorOnChain |
the max of the interval 0..i for every i on chains More... | |
std::vector< std::vector< T > > | longestDistToSteinerAncestorSegTree |
segment tree for segment maxs on every chain More... | |
NodeArray< int > | nodeLevel |
the level of a node in the tree More... | |
NodeArray< int > | positionOnChain |
position of a node on his chain More... | |
List< node > | terminals |
list of terminals of the desc tree More... | |
const EdgeWeightedGraphCopy< T > & | tree |
constant ref to the tree to be decomposed More... | |
NodeArray< int > | weightOfSubtree |
weight of the subtree rooted in one node More... | |
An implementation of the heavy path decomposition on trees.
It contains very specific queries used by reductions.
Definition at line 54 of file HeavyPathDecomposition.h.
|
inline |
Definition at line 296 of file HeavyPathDecomposition.h.
|
inlineprivate |
performs a binary search on chainOfTerminals, searches for the closest node to the root on chainOfTerminals that sits below v
Definition at line 232 of file HeavyPathDecomposition.h.
|
inlineprivate |
builds a max segment tree on the baseArray
Definition at line 77 of file HeavyPathDecomposition.h.
|
inlineprivate |
computes for the path from x to ancestor the maximum distance (sum of edges) between any two consecutive terminals using the hpd updates it in longestPathDistance also puts in fromLowestToAncestor the sum of edges from the last terminal found to the ancestor (the last terminal is special since its Steiner ancestor is ancestor for ancestor as well, so we would consider a wrong part of the path
Definition at line 259 of file HeavyPathDecomposition.h.
|
inlineprivate |
creates for every chain an array with the maximum of every prefix of a fictive array which keeps for every node the sum of the edges on the path from it to its closest terminal ancestor
Definition at line 143 of file HeavyPathDecomposition.h.
|
inlineprivate |
creates for every chain a segment tree built on a fictive array which keeps for every node the sum of the edges on the path from it to its closest terminal ancestor
Definition at line 163 of file HeavyPathDecomposition.h.
|
inlineprivate |
performs the heavy path decomposition on the tree belonging to the class updates the fields of the class
Definition at line 184 of file HeavyPathDecomposition.h.
|
inlineprivate |
computes the sum of all edges on the path from v to ancestor v must be in ancestor's subtree
Definition at line 131 of file HeavyPathDecomposition.h.
|
inline |
computes in the bottleneck distance between terminals x and y
Definition at line 354 of file HeavyPathDecomposition.h.
|
inlineprivate |
extracts the maximum on the required interval
Definition at line 98 of file HeavyPathDecomposition.h.
|
inline |
computes the lowest common ancestor of nodes x and y using the hpd
Definition at line 328 of file HeavyPathDecomposition.h.
|
private |
the index of a node's chain
Definition at line 62 of file HeavyPathDecomposition.h.
|
private |
list of chains of nodes corresponding to the decomposition
Definition at line 60 of file HeavyPathDecomposition.h.
|
private |
list of chains only of terminals corresponding to the decomposition
Definition at line 61 of file HeavyPathDecomposition.h.
|
private |
the highest-level Steiner ancestor of the current node
Definition at line 67 of file HeavyPathDecomposition.h.
|
private |
the length of the edge to his father
Definition at line 66 of file HeavyPathDecomposition.h.
|
private |
the first node from bottom up that does not belong to the chain
Definition at line 68 of file HeavyPathDecomposition.h.
|
private |
isTerminal of the desc tree
Definition at line 58 of file HeavyPathDecomposition.h.
|
private |
the max of the interval 0..i for every i on chains
Definition at line 70 of file HeavyPathDecomposition.h.
|
private |
segment tree for segment maxs on every chain
Definition at line 71 of file HeavyPathDecomposition.h.
|
private |
the level of a node in the tree
Definition at line 65 of file HeavyPathDecomposition.h.
|
private |
position of a node on his chain
Definition at line 63 of file HeavyPathDecomposition.h.
|
private |
list of terminals of the desc tree
Definition at line 57 of file HeavyPathDecomposition.h.
|
private |
constant ref to the tree to be decomposed
Definition at line 56 of file HeavyPathDecomposition.h.
|
private |
weight of the subtree rooted in one node
Definition at line 64 of file HeavyPathDecomposition.h.