Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

LinearQuadtreeBuilder.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 
37 #include <cstdint>
38 
39 namespace ogdf {
40 namespace fast_multipole_embedder {
41 
44 public:
47  : firstInner(0)
48  , firstLeaf(0)
49  , lastInner(0)
50  , lastLeaf(0)
51  , numInnerNodes(0)
52  , numLeaves(0)
53  , tree(treeRef)
55  n = tree.numberOfPoints();
56  }
57 
59  void build();
60 
63 
66 
68  void prepareTree();
69 
72 
75 
77  void buildHierarchy();
78 
83  } else {
84  firstInner = curr;
85  }
86  restoreChainLastNode = curr;
87  numInnerNodes++;
88  }
89 
91  if (tree.isLeaf(curr)) {
92  return;
93  } else {
94  restoreChain(tree.child(curr, 0));
95  tree.setFirstPoint(curr, tree.firstPoint(tree.child(curr, 0)));
97  for (uint32_t i = 1; i < tree.numberOfChilds(curr); i++) {
98  restoreChain(tree.child(curr, i));
99  }
100 
101  uint32_t lastPoint = tree.firstPoint(tree.child(curr, tree.numberOfChilds(curr) - 1))
102  + tree.numberOfPoints(tree.child(curr, tree.numberOfChilds(curr) - 1));
103  tree.setNumberOfPoints(curr, lastPoint - tree.firstPoint(curr));
104  }
105  }
106 
107  inline void restoreChain() {
109  numInnerNodes = 0;
110  if (!tree.isLeaf(tree.root())) {
112  }
113  if (restoreChainLastNode) {
115  }
116  }
117 
120  // 64 bit version
121 #if 0
122  // FIXME: a < 0 is always true (PointID is unsigned int)
123  if (a < 0) return 64;
124 #endif
125  if (b >= tree.numberOfPoints()) {
126  return 64;
127  }
128  uint32_t res = (32 - ((mostSignificantBit(tree.mortonNr(a) ^ tree.mortonNr(b))) / 2));
129  return res;
130  }
131 
134 
137  uint32_t numInnerNodes;
138  uint32_t numLeaves;
139 
143 };
144 
145 }
146 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::n
LinearQuadtree::PointID n
Definition: LinearQuadtreeBuilder.h:142
ogdf::fast_multipole_embedder::LinearQuadtree::NodeID
unsigned int NodeID
Definition: LinearQuadtree.h:55
ogdf::fast_multipole_embedder::LinearQuadtree::setNumberOfPoints
void setNumberOfPoints(NodeID nodeID, uint32_t numPoints)
sets the number of nodes containted in node nodeID
Definition: LinearQuadtree.h:421
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::restoreChain
void restoreChain(LinearQuadtree::NodeID curr)
Definition: LinearQuadtreeBuilder.h:90
LinearQuadtree.h
Declaration of class LinearQuadtree.
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::prepareNodeAndLeaf
void prepareNodeAndLeaf(LinearQuadtree::PointID leafPos, LinearQuadtree::PointID nextLeafPos)
prepares the node and leaf layer at position leafPos where nextLeafPos is the next position
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder
the builder for the LinearQuadtree
Definition: LinearQuadtreeBuilder.h:43
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::restoreChain
void restoreChain()
Definition: LinearQuadtreeBuilder.h:107
ogdf::fast_multipole_embedder::LinearQuadtree::numberOfPoints
uint32_t numberOfPoints(NodeID nodeID) const
returns the number of points contained in the subtree of node nodeID
Definition: LinearQuadtree.h:418
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::prepareTree
void prepareTree()
prepares the node and leaf layer for the complete tree from 0 to n (excluding n)
FastUtils.h
Definition of utility functions for FME layout.
ogdf::fast_multipole_embedder::LinearQuadtree::setFirstPoint
void setFirstPoint(NodeID nodeID, PointID firstPoint)
Definition: LinearQuadtree.h:385
ogdf::fast_multipole_embedder::LinearQuadtree::firstPoint
PointID firstPoint(NodeID nodeID) const
Definition: LinearQuadtree.h:383
ogdf::fast_multipole_embedder::LinearQuadtree::child
NodeID child(NodeID nodeID, uint32_t i) const
returns the i th child index of node nodeID
Definition: LinearQuadtree.h:406
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::restorePushBackChain
void restorePushBackChain(LinearQuadtree::NodeID curr)
used by restore chain
Definition: LinearQuadtreeBuilder.h:80
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::build
void build()
the main build call
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::firstLeaf
LinearQuadtree::NodeID firstLeaf
Definition: LinearQuadtreeBuilder.h:133
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::lastInner
LinearQuadtree::NodeID lastInner
Definition: LinearQuadtreeBuilder.h:135
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::CAL
uint32_t CAL(LinearQuadtree::PointID a, LinearQuadtree::PointID b)
returns the level of the first common ancestor of a and b
Definition: LinearQuadtreeBuilder.h:119
ogdf::fast_multipole_embedder::LinearQuadtree::setNextNode
void setNextNode(NodeID nodeID, NodeID next)
Definition: LinearQuadtree.h:379
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::numInnerNodes
uint32_t numInnerNodes
Definition: LinearQuadtreeBuilder.h:137
ogdf::fast_multipole_embedder::LinearQuadtree
Definition: LinearQuadtree.h:50
ogdf::fast_multipole_embedder::LinearQuadtree::PointID
unsigned int PointID
Definition: LinearQuadtree.h:56
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::mergeWithNext
void mergeWithNext(LinearQuadtree::NodeID curr)
merges the node curr with curr's next node by appending the next nodes children to curr except the fi...
ogdf::fast_multipole_embedder::mostSignificantBit
uint32_t mostSignificantBit(T n)
returns the index of the most signficant bit set. 0 = most signif, bitlength-1 = least signif
Definition: FastUtils.h:167
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::tree
LinearQuadtree & tree
Definition: LinearQuadtreeBuilder.h:140
ogdf::fast_multipole_embedder::LinearQuadtree::isLeaf
bool isLeaf(NodeID nodeID) const
returns true if the given node index is a leaf
Definition: LinearQuadtree.h:412
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::lastLeaf
LinearQuadtree::NodeID lastLeaf
Definition: LinearQuadtreeBuilder.h:136
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
ogdf::fast_multipole_embedder::LinearQuadtree::root
NodeID root() const
returns the index of the root
Definition: LinearQuadtree.h:426
ogdf::fast_multipole_embedder::LinearQuadtree::mortonNr
MortonNR mortonNr(PointID point) const
Definition: LinearQuadtree.h:393
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::restoreChainLastNode
LinearQuadtree::NodeID restoreChainLastNode
Definition: LinearQuadtreeBuilder.h:141
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::LinearQuadtreeBuilder
LinearQuadtreeBuilder(LinearQuadtree &treeRef)
constructor
Definition: LinearQuadtreeBuilder.h:46
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::firstInner
LinearQuadtree::NodeID firstInner
Definition: LinearQuadtreeBuilder.h:132
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::numLeaves
uint32_t numLeaves
Definition: LinearQuadtreeBuilder.h:138
ogdf::fast_multipole_embedder::LinearQuadtreeBuilder::buildHierarchy
void buildHierarchy()
the main function for the new link-only recursive builder
ogdf::fast_multipole_embedder::LinearQuadtree::numberOfChilds
uint32_t numberOfChilds(NodeID nodeID) const
returns the number of children of node nodeID. for an inner node this is 1..4 and can be accessed by ...
Definition: LinearQuadtree.h:398