|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
45 class EdgeWeightedGraphCopy;
47 namespace steiner_tree {
60 std::vector<std::vector<node>>
chains;
78 const int right,
const std::vector<T>& baseArray)
const {
80 segmentTree[nodeIndex] = baseArray[left];
84 int middle = (left + right) >> 1;
85 int leftNodeIndex = nodeIndex + nodeIndex + 1;
86 int rightNodeIndex = leftNodeIndex + 1;
91 segmentTree[nodeIndex] = max(segmentTree[leftNodeIndex], segmentTree[rightNodeIndex]);
99 const int right,
const int queryLeft,
const int queryRight)
const {
100 if (queryLeft > queryRight || left > queryRight || queryLeft > right) {
104 if (queryLeft <= left && right <= queryRight) {
105 return segmentTree[nodeIndex];
108 int middleIndex = (left + right) >> 1;
109 int leftNodeIndex = nodeIndex + nodeIndex + 1;
110 int rightNodeIndex = leftNodeIndex + 1;
113 if (queryLeft <= middleIndex) {
118 if (queryRight > middleIndex) {
121 queryLeft, queryRight));
132 if (ancestor ==
nullptr) {
145 for (
int i = 0; i < (int)
chains.size(); ++i) {
147 for (
int j = 0; j < (int)
chains[i].size(); ++j) {
165 for (
int i = 0; i < (int)
chains.size(); ++i) {
168 std::vector<T> distanceToSteinerAncestor_byPosition;
169 distanceToSteinerAncestor_byPosition.resize(
chains[i].size());
170 for (
int j = 0; j < (int)
chains[i].size(); ++j) {
171 distanceToSteinerAncestor_byPosition[j] =
176 (
int)
chains[i].size() - 1, distanceToSteinerAncestor_byPosition);
186 node heaviestSon =
nullptr;
209 if (heaviestSon ==
nullptr) {
212 std::vector<node> new_chain;
213 chains.push_back(new_chain);
233 int left = 0, middle, right = (int)chainOfTerminals.size() - 1;
234 while (left <= right) {
235 middle = (left + right) >> 1;
244 if (left == (
int)chainOfTerminals.size()) {
247 return chainOfTerminals[left];
260 T& fromLowestToAncestor)
const {
261 node upmostTerminal = x;
276 node upmostTerminalLastChain =
279 upmostTerminalLastChain =
nullptr;
281 if (upmostTerminalLastChain !=
nullptr) {
282 upmostTerminal = upmostTerminalLastChain;
285 if (upmostTerminalLastChain !=
nullptr) {
297 :
tree {treeEWGraphCopy}
311 int numberOfChains =
static_cast<int>(
chains.size());
312 for (
int i = 0; i < numberOfChains; ++i) {
337 if (xlevelOfFatherOfChain >= ylevelOfFatherOfChain) {
355 T xLongestPathDistance = 0, yLongestPathDistance = 0;
356 T xFromLowestToLCA = 0, yFromLowestToLCA = 0;
362 T
maxValue = max(xLongestPathDistance, yLongestPathDistance);
The namespace for all OGDF objects.
std::vector< node > fatherOfChain
the first node from bottom up that does not belong to the chain
Includes declaration of graph class.
NodeArray< int > nodeLevel
the level of a node in the tree
HeavyPathDecomposition(const EdgeWeightedGraphCopy< T > &treeEWGraphCopy)
const EdgeWeightedGraphCopy< T > & tree
constant ref to the tree to be decomposed
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
T getBottleneckSteinerDistance(node x, node y) const
computes in the bottleneck distance between terminals x and y
std::vector< std::vector< node > > chainsOfTerminals
list of chains only of terminals corresponding to the decomposition
void dfsHeavyPathDecomposition(node v, node closestSteinerUpNode)
performs the heavy path decomposition on the tree belonging to the class updates the fields of the cl...
NodeArray< int > positionOnChain
position of a node on his chain
List< node > terminals
list of terminals of the desc tree
Class for adjacency list elements.
Reverse< T > reverse(T &container)
Provides iterators for container to make it easily iterable in reverse.
std::vector< std::vector< T > > longestDistToSteinerAncestorOnChain
the max of the interval 0..i for every i on chains
edge theEdge() const
Returns the edge associated with this adjacency entry.
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
NodeArray< int > chainOfNode
the index of a node's chain
int degree() const
Returns the degree of the node (indegree + outdegree).
void computeLongestDistToSteinerAncestorSegTree()
creates for every chain a segment tree built on a fictive array which keeps for every node the sum of...
NodeArray< T > distanceToRoot
the length of the edge to his father
Decralation of GraphElement and GraphList classes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
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
NodeElement * node
The type of nodes.
void computeLongestDistToSteinerAncestorOnChain()
creates for every chain an array with the maximum of every prefix of a fictive array which keeps for ...
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
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 chainOfTer...
node lowestCommonAncestor(node x, node y) const
computes the lowest common ancestor of nodes x and y using the hpd
const NodeArray< bool > isTerminal
isTerminal of the desc tree
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
NodeArray< int > weightOfSubtree
weight of the subtree rooted in one node
void updateMax(T &max, const T &newValue)
Stores the maximum of max and newValue in max.
Basic declarations, included by all source files.
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
std::vector< std::vector< T > > longestDistToSteinerAncestorSegTree
segment tree for segment maxs on every chain
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
std::vector< std::vector< node > > chains
list of chains of nodes corresponding to the decomposition
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 consecut...
NodeArray< node > closestSteinerAncestor
the highest-level Steiner ancestor of the current node
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
An implementation of the heavy path decomposition on trees.
Container::value_type maxValue(const Container &values)
Returns the maximum of an iterable container of given values.
Class for the representation of nodes.