35namespace energybased {
87 void setPoint(
int i,
int d,
double coord);
162 : m_numPoints(numPoints)
163 , m_wspdSeparationFactor(1.0)
164 , m_wspdSeparationFactorPlus2Squared_cached(9.0) {
169 for (
int i = 0; i <
Dim; i++) {
183 m_pTree =
new Tree(m_numPoints);
184 m_nodeData =
new NodeData[m_pTree->maxNumNodes()];
185 m_pointData =
new PointData[m_numPoints];
192 delete[] m_pointData;
201 updateTreeGridPoints();
207 updateTreeNodeGeometry();
215 const double s = (m_wspdSeparationFactor + 2.0);
218 m_wspdSeparationFactorPlus2Squared_cached = s * s;
221 wspdRecursive(m_pTree->rootIndex());
228 for (
int i = 0; i < m_pTree->numChilds(
curr); i++) {
230 const int first_child = m_pTree->child(
curr, i);
233 for (
int j = i + 1;
j < m_pTree->numChilds(
curr);
j++) {
242 wspdRecursive(first_child);
248 if (areWellSeparated(a, b)) {
251 m_pIWSPD->onWellSeparatedPair(a, b);
280 for (
int d = 0;
d <
Dim;
d++) {
293 const double s = (m_wspdSeparationFactor + 2.0);
294 return dist_sq > (m_wspdSeparationFactor * m_wspdSeparationFactor + 4.0 * m_wspdSeparationFactor + 4) *
r_max *
r_max;
335 m_pointData[i].x[
d] = coord;
345 for (
int d = 0;
d <
Dim;
d++) {
346 m_bboxMin[
d] = m_bboxMax[
d] = point(0).x[
d];
350 for (
int i = 1; i < m_numPoints; i++) {
351 for (
int d = 0;
d <
Dim;
d++) {
352 m_bboxMin[
d] = std::min(m_bboxMin[
d], point(i).x[
d]);
353 m_bboxMax[
d] = std::max(m_bboxMax[
d], point(i).x[
d]);
361 for (
int d = 0;
d <
Dim;
d++) {
362 double noise_max = (m_bboxMax[
d] - m_bboxMin[
d]) * 0.25;
367 double quad_size = m_bboxMax[0] - m_bboxMin[0];
368 for (
int d = 1;
d <
Dim;
d++) {
372 const double factor = (
double)(0xffffffff);
376 for (
int i = 0; i < m_numPoints; i++) {
377 for (
int d = 0;
d <
Dim;
d++) {
380 double nx = ((point(i).x[
d] - m_bboxMin[
d] + 0.01) /
quad_size + 0.02);
382 double nx = ((point(i).x[
d] - m_bboxMin[
d]) * scale);
385 unsigned int ix =
static_cast<unsigned int>(
nx);
388 m_pTree->setPoint(i,
d,
ix);
395 updateTreeNodeGeometry(m_pTree->rootIndex());
402 if (m_pTree->numChilds(
curr)) {
406 for (
int i = 0; i < m_pTree->numChilds(
curr); i++) {
408 const int child = m_pTree->child(
curr, i);
411 updateTreeNodeGeometry(child);
415 for (
int d = 0;
d <
Dim;
d++) {
420 for (
int d = 0;
d <
Dim;
d++) {
428 for (
int d = 0;
d <
Dim;
d++) {
433 for (
int i = 1; i <
tree().numPoints(
curr); ++i) {
434 for (
int d = 0;
d <
Dim;
d++) {
447 for (
int d = 0;
d <
Dim;
d++) {
Basic declarations, included by all source files.
Implentation of the reduced quadtree for Dim dimensions.
Tree * m_pTree
the quadtree this wspd is working on
const NodeData & node(int i) const
returns the data for a quadtree
const Tree & tree() const
returns the corresponding Dtree
const PointData & point(int i) const
return ith point
double m_bboxMax[Dim]
the bounding box max coord of the point set
double m_bboxMin[Dim]
the bounding box min coord of the point set
NodeData * m_nodeData
geometry for the quadtree nodes
void computeWSPD(IWSPD *m_pIWSPD)
void allocate()
allocate mem
PointData * m_pointData
point data
void updateTreeNodeGeometry()
updates the geometry of the quadtree nodes
void updateBoundingBox()
updates the bounding box by iterating over all points
double separationFactor() const
returns the parameter s of the WSPD (default is 1.0)
void wspdRecursive(int a)
the unary recursive function generating the binary calls
double m_wspdSeparationFactorPlus2Squared_cached
a cached value for the ws test
void update()
call this when the point set has been updated.
double m_wspdSeparationFactor
the separation factor for the ws predicate
DTreeWSPD(int numPoints)
constructs a new WSPD for numPoints
void deallocate()
free mem
bool areWellSeparated(int a, int b) const
predicate for determining if cells are well-separated
int m_numPoints
number of points
void setSeparationFactor(double s)
sets the parameter s of the WSPD (default is 1.0)
void updateTreeGridPoints()
updates the integer grid points in the quadtree
void setPoint(int i, int d, double coord)
sets the point to the given coords
NodeData & node(int i)
returns the data for a quadtree
virtual void onWellSeparatedPair(int aIndex, int bIndex)=0
called by the WSPD for a pair that is well separated
NodeElement * node
The type of nodes.
double randomDouble(double low, double high)
Returns a random double value from the interval [low, high).
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
geometry for the quadtree nodes
double min_x[Dim]
bounding box min coord
double max_x[Dim]
bounding box min coord
double x[Dim]
center of cell circle
double radius_sq
radius of the cell
world coordinates of the points
double x[Dim]
coords of the point