Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
NewMultipoleMethod.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Array2D.h>
35#include <ogdf/basic/Graph.h>
36#include <ogdf/basic/List.h>
37#include <ogdf/basic/geometry.h>
41
42#include <complex>
43
44namespace ogdf {
45namespace energybased {
46namespace fmmm {
47
49public:
52
56
58 void make_initialisations(const Graph& G, double boxlength, DPoint down_left_corner,
59 int particles_in_leaves, int precision,
60 FMMMOptions::ReducedTreeConstruction tree_construction_way,
61 FMMMOptions::SmallestCellFinding find_small_cell);
62
65
68
69private:
78
83
84 double boxlength;
86
88 double** BK;
89
93
94 // private helping functions
95
97 int power_of_two(int i);
98
100 int maxboxindex(int level);
101
105
110
113
117 QuadTreeNM& T);
118
125
128
132
138
141
144 bool in_lt_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
145 bool in_rt_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
146 bool in_lb_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
147 bool in_rb_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
149 QuadTreeNodeNM* act_ptr);
150
160 List<ParticleInfo>*& L_y_right_ptr, bool isHorizontal);
161
173 bool deleteRight, bool isHorizontal);
174
181
191
195
199
203 QuadTreeNM& T);
204
208
216
224
231
235
242
246
253
259
264
272
274
278
282
285 void find_small_cell(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max) {
286 switch (find_sm_cell()) {
287 case FMMMOptions::SmallestCellFinding::Iteratively:
288 find_small_cell_iteratively(act_ptr, min, max);
289 break;
290 case FMMMOptions::SmallestCellFinding::Aluru:
291 find_small_cell_by_formula(act_ptr, min, max);
292 break;
293 }
294 }
295
298
303
308
311
314
317
321
327
331
334
338
342
347 QuadTreeNodeNM* act_ptr);
348
353
358
363
368
370 void init_binko(int t);
371
374
376 double binko(int n, int k);
377
380 return _tree_construction_way;
381 }
382
384 _tree_construction_way = rtc;
385 }
386
389 FMMMOptions::SmallestCellFinding find_sm_cell() const { return _find_small_cell; }
390
392
394 void particles_in_leaves(int b) { _particles_in_leaves = ((b >= 1) ? b : 1); }
395
396 int particles_in_leaves() const { return _particles_in_leaves; }
397
399 void precision(int p) { _precision = ((p >= 1) ? p : 1); }
400
401 int precision() const { return _precision; }
402};
403
404}
405}
406}
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays.
Declaration of Fast Multipole Multilevel Method (FM^3) options.
Declaration of class FruchtermanReingold (computation of forces).
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Declaration of class QuadTreeNM.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
The parameterized class Array2D implements dynamic two-dimensional arrays.
Definition Array2D.h:47
SmallestCellFinding
Specifies how to calculate the smallest quadratic cell that surrounds the particles of a node in the ...
ReducedTreeConstruction
Specifies how the reduced bucket quadtree is constructed.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Encapsulates a pointer to a list element.
Definition List.h:103
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
void calculate_repulsive_forces(const Graph &G, NodeArray< NodeAttributes > &A, NodeArray< DPoint > &F_rep)
Calculate rep. forces for each node.
FMMMOptions::SmallestCellFinding find_sm_cell() const
Returns the way the smallest quadratic cell that surrounds the particles of a node in the reduced buc...
List< DPoint > rep_forces
stores the rep. forces of the last iteration needed for error calculation)
void build_up_root_vertex(const Graph &G, QuadTreeNM &T)
The root node of T is constructed and contained_nodes is set to the list of all nodes of G.
void add_shifted_expansion_to_father_expansion(QuadTreeNodeNM *act_ptr)
Add the shifted ME Lists of *act_ptr to act_ptr->get_father_ptr() ; precondition *act_ptr has a fathe...
void form_multipole_expansions(NodeArray< NodeAttributes > &A, QuadTreeNM &T, List< QuadTreeNodeNM * > &quad_tree_leaves)
The multipole expansion terms ME are calculated for all nodes of T ( centers are initialized for each...
void find_small_cell_iteratively(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
Finds the small cell of the actual Node of T iteratively,and updates Sm_downleftcorner,...
bool well_separated(QuadTreeNodeNM *ptr_1, QuadTreeNodeNM *ptr_2)
If the small cell of ptr_1 and ptr_2 are well separated true is returned (else false).
void calculate_boundaries_of_act_node(QuadTreeNodeNM *act_ptr, DPoint &min, DPoint &max)
The extreme coordinates of the particles contained in *act_ptr are calculated.
bool in_rt_quad(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
void build_up_sorted_subLists(List< ParticleInfo > &L_x_copy, List< ParticleInfo > &act_y_List_copy)
The sorted subLists, that can be accesssed by the entries in L_x(y)_copy->get_subList_ptr() are const...
double binko(int n, int k)
Returns n over k.
void construct_reduced_subtree(NodeArray< NodeAttributes > &A, QuadTreeNM &T, List< QuadTreeNodeNM * > &new_subtree_root_List)
The reduced subtree rooted at *T.get_act_ptr() is calculated ; A pointer to every leaf of this subtre...
void calculate_repulsive_forces_by_NMM(const Graph &G, NodeArray< NodeAttributes > &A, NodeArray< DPoint > &F_rep)
Use NMM for force calculation (used for large Graphs (|V| > MIN_NODE_NUMBER)).
bool bordering(QuadTreeNodeNM *ptr_1, QuadTreeNodeNM *ptr_2)
If ptr_1 and ptr_2 are nonequal and bordering true is returned; else false.
void add_local_expansion_of_leaf(NodeArray< NodeAttributes > &A, QuadTreeNodeNM *leaf_ptr, QuadTreeNodeNM *act_ptr)
The multipole expansion for every particle of leaf_ptr->contained_nodes (1,0,...) is transformed into...
int power_of_two(int i)
Returns power_of_2[i] for values <= max_power_of_2_index.
void delete_subLists(QuadTreeNodeNM *act_ptr, List< ParticleInfo > *&L_x_left_ptr, List< ParticleInfo > *&L_y_left_ptr, List< ParticleInfo > *&L_x_right_ptr, List< ParticleInfo > *&L_y_right_ptr, ListIterator< ParticleInfo > last_left_item, bool deleteRight, bool isHorizontal)
The Lists *L_x(y)_left_ptr are constructed from *act_ptr->get_x(y)_List_ptr() by deleting all element...
void transform_local_exp_to_forces(NodeArray< NodeAttributes > &A, List< QuadTreeNodeNM * > &quad_tree_leaves, NodeArray< DPoint > &F_local_exp)
For each leaf v in quad_tree_leaves the force contribution defined by v.get_local_exp() is calculated...
bool check_and_delete_degenerated_node(QuadTreeNM &T)
If *T.get_act_ptr() is a degenerated node (has only one child c) *T.get_act_ptr() is deleted from T a...
void delete_red_quad_tree_and_count_treenodes(QuadTreeNM &T)
The reduced quad tree is deleted; Furthermore the treenode_number is calculated.
void build_up_root_node(const Graph &G, NodeArray< NodeAttributes > &A, QuadTreeNM &T)
The root node of T is constructed.
void split_in_y_direction(QuadTreeNodeNM *act_ptr, List< ParticleInfo > *&L_x_ptr, List< ParticleInfo > *&L_x_b_ptr, List< ParticleInfo > *&L_x_t_ptr, List< ParticleInfo > *&L_y_ptr, List< ParticleInfo > *&L_y_b_ptr, List< ParticleInfo > *&L_y_t_ptr)
The Lists *L_x(y)_b_ptr and *L_x(y)_t_ptr are constructed from the Lists *L_x(y)_ptr.
void deallocate_memory()
Dynamically allocated memory is freed here.
bool in_lt_quad(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
Returns true if the rectangle defined by min and max lies within the left(right)_top(bottom) quad of ...
bool using_NMM
Indicates whether the exact method or NMM is used for force calculation (value depends on MIN_NODE_NU...
void form_multipole_expansion_of_subtree(NodeArray< NodeAttributes > &A, QuadTreeNM &T, List< QuadTreeNodeNM * > &quad_tree_leaves)
The multipole expansion List ME for the tree rooted at T.get_act_ptr() is recursively calculated.
void set_contained_nodes_for_leaves(NodeArray< NodeAttributes > &A, QuadTreeNodeNM *subtree_root_ptr, Array2D< QuadTreeNodeNM * > &leaf_ptr, int maxindex)
The particles in subtree_root_ptr->get_contained_nodes() are assigned to the the contained_nodes list...
bool in_rb_quad(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
void make_initialisations(const Graph &G, double boxlength, DPoint down_left_corner, int particles_in_leaves, int precision, FMMMOptions::ReducedTreeConstruction tree_construction_way, FMMMOptions::SmallestCellFinding find_small_cell)
Make all initialisations that are needed for New Multipole Method (NMM)
void set_particlenumber_in_subtree_entries(QuadTreeNM &T)
The subtree of T rooted at *T.get_act_ptr() is traversed bottom up, such that the subtreeparticlenumb...
void form_multipole_expansion_of_leaf_node(NodeArray< NodeAttributes > &A, QuadTreeNodeNM *act_ptr)
Calculate List ME for *act_ptr Precondition: *act_ptr is a leaf.
bool in_lb_quad(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
void init_expansion_Lists(QuadTreeNodeNM *act_ptr)
The Lists ME and LE are both initialized to zero entries for *act_ptr.
void build_up_red_quad_tree_path_by_path(const Graph &G, NodeArray< NodeAttributes > &A, QuadTreeNM &T)
The reduced quadtree is build up path by path (the Lists LE,ME, the centers, D1, D2,...
void calculate_neighbourcell_forces(NodeArray< NodeAttributes > &A, List< QuadTreeNodeNM * > &quad_tree_leaves, NodeArray< DPoint > &F_direct)
For each leaf v in quad_tree_leaves the force contributions from all leaves in v.get_D1() and v....
void add_shifted_local_exp_of_parent(QuadTreeNodeNM *node_ptr)
The shifted local expansion of the father of node_ptr is added to the local expansion of node_ptr;pre...
void decompose_subtreenode(QuadTreeNM &T, List< ParticleInfo > &act_x_List_copy, List< ParticleInfo > &act_y_List_copy, List< QuadTreeNodeNM * > &new_leaf_List)
T is extended by a subtree T1 rooted at the T.get_act_node(). The boxlength and down_left_corner of t...
int maxboxindex(int level)
Returns the maximal index of a box in level i.
void set_center(QuadTreeNodeNM *act_ptr)
The center of the box of *act_ptr is initialized.
void tree_construction_way(FMMMOptions::ReducedTreeConstruction rtc)
bool quadHelper(DPoint min, DPoint max, DPoint bottomleft, DPoint topright, QuadTreeNodeNM *act_ptr)
void delete_sparse_subtree(QuadTreeNM &T, QuadTreeNodeNM *new_leaf_ptr)
The subtree rooted at new_leaf_ptr is deleted, *new_leaf_ptr is a leaf of T and new_leaf_ptr->get_con...
void split(QuadTreeNodeNM *act_ptr, List< ParticleInfo > *&L_x_left_ptr, List< ParticleInfo > *&L_y_left_ptr, List< ParticleInfo > *&L_x_right_ptr, List< ParticleInfo > *&L_y_right_ptr, bool isHorizontal)
The Lists *act_ptr->get_x(y)_List_ptr() are split into two sublists containing the particles in the l...
FMMMOptions::SmallestCellFinding _find_small_cell
FMMMOptions::ReducedTreeConstruction _tree_construction_way
int _precision
precision for p-term multipole expansion
FruchtermanReingold ExactMethod
needed in case that using_NMM == false
void calculate_repulsive_forces_by_exact_method(const Graph &G, NodeArray< NodeAttributes > &A, NodeArray< DPoint > &F_rep)
Use the exact method for force calculation (used for small Graphs (|V| <= MIN_NODE_NUMBER) for speed ...
void update_boxlength_and_cornercoordinate(double b_l, DPoint d_l_c)
Import updated information of the drawing area.
void move_subLists_vertical(List< ParticleInfo > *&L_x_ptr, List< ParticleInfo > *&L_x_b_ptr, List< ParticleInfo > *&L_x_t_ptr, List< ParticleInfo > *&L_y_ptr, List< ParticleInfo > *&L_y_b_ptr, List< ParticleInfo > *&L_y_t_ptr, ListIterator< ParticleInfo > last_left_item, bool moveRight)
The Lists *L_x(y)_b(t)_ptr are constructed from the Lists *L_x(y)_ptr by moving all List elements fro...
void create_sorted_coordinate_Lists(const Graph &G, NodeArray< NodeAttributes > &A, List< ParticleInfo > &L_x, List< ParticleInfo > &L_y)
The sorted and linked Lists L_x and L_y for the root node are created.
void construct_subtree(NodeArray< NodeAttributes > &A, QuadTreeNM &T, QuadTreeNodeNM *subtree_root_ptr, List< QuadTreeNodeNM * > &new_subtree_root_List)
The reduced subtree of T rooted at *subtree_root_ptr containing all the particles of subtree_root_ptr...
void find_sm_cell(FMMMOptions::SmallestCellFinding scf)
void delete_empty_subtrees(QuadTreeNM &T)
All subtrees of *T.get_act_ptr() that have a child c of *T.get_act_ptr() as root and c....
void calculate_local_expansions_and_WSPRLS(NodeArray< NodeAttributes > &A, QuadTreeNodeNM *act_node_ptr)
According to NMM T is traversed recursively top-down starting from act_node_ptr == T....
void add_rep_forces(const Graph &G, NodeArray< DPoint > &F_direct, NodeArray< DPoint > &F_multipole_exp, NodeArray< DPoint > &F_local_exp, NodeArray< DPoint > &F_rep)
Add repulsive force contributions for each node.
FMMMOptions::ReducedTreeConstruction tree_construction_way() const
Returns the way to construct the reduced tree.
void collect_contained_nodes(QuadTreeNM &T, QuadTreeNodeNM *new_leaf_ptr)
new_leaf_ptr->get_contained_nodes() contains all the particles contained in the leaves of its subtree...
void find_small_cell_by_formula(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
Finds the small cell of the actual Node of T by Aluru's Formula, and updates Sm_downleftcorner,...
int MIN_NODE_NUMBER
The minimum number of nodes for which the forces are calculated using NMM (for lower values the exact...
void make_copy_and_init_Lists(List< ParticleInfo > &L_x_orig, List< ParticleInfo > &L_x_copy, List< ParticleInfo > &L_y_orig, List< ParticleInfo > &L_y_copy)
Makes L_x(y)_copy a copy of L_x(y)_orig and sets p.copy_item for each element in L_x(y)_orig to the L...
bool find_smallest_quad(NodeArray< NodeAttributes > &A, QuadTreeNM &T)
If all nodes in T.get_act_ptr()->get_contained_nodes() have the same position false is returned....
double ** BK
holds the binomial coefficients
void construct_complete_subtree(QuadTreeNM &T, int subtree_depth, Array2D< QuadTreeNodeNM * > &leaf_ptr, int act_depth, int act_x_index, int act_y_index)
A complete subtree of T and of depth subtree_depth, rooted at *T.get_act_ptr() is constructed....
void add_local_expansion(QuadTreeNodeNM *ptr_1, QuadTreeNodeNM *ptr_2)
The multipole expansion of *ptr_1 is transformed into a local expansion around the center of *ptr_2 a...
void find_small_cell(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
Finds the small cell of the actual node using the selected algorithm.
DPoint down_left_corner
down left corner of drawing box
void transform_multipole_exp_to_forces(NodeArray< NodeAttributes > &A, List< QuadTreeNodeNM * > &quad_tree_leaves, NodeArray< DPoint > &F_multipole_exp)
For each leaf v in quad_tree_leaves the force contribution defined by all nodes in v....
void init_binko(int t)
Init BK -matrix for values n, k in 0 to t.
void build_up_red_quad_tree_subtree_by_subtree(const Graph &G, NodeArray< NodeAttributes > &A, QuadTreeNM &T)
The reduced quadtree is build up subtree by subtree (the lists LE, ME the centers,...
void precision(int p)
The precision p for the p-term multipole expansions.
void particles_in_leaves(int b)
Max. number of particles that are contained in a leaf of the red. quadtree.
Helping data structure that stores the information needed to represent the modified quadtree in the N...
Definition QuadTreeNM.h:42
Helping data structure that stores the information needed to represent a node of the reduced quad tre...
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.