Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

NewMultipoleMethod.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/List.h>
36 #include <ogdf/basic/Array2D.h>
37 #include <ogdf/basic/geometry.h>
41 #include <complex>
42 
43 namespace ogdf {
44 namespace energybased {
45 namespace fmmm {
46 
48 {
49 public:
52 
54  void calculate_repulsive_forces(const Graph &G,
56  NodeArray<DPoint>& F_rep);
57 
59  void make_initialisations (const Graph &G,
60  double boxlength,
61  DPoint down_left_corner,
62  int particles_in_leaves,
63  int precision,
64  FMMMOptions::ReducedTreeConstruction tree_construction_way,
65  FMMMOptions::SmallestCellFinding find_small_cell);
66 
68  void deallocate_memory();
69 
71  void update_boxlength_and_cornercoordinate(double b_l,DPoint d_l_c);
72 
73 private:
80  bool using_NMM;
82 
86  int _precision;
87 
88  double boxlength;
90 
92  double ** BK;
93 
97 
98  // private helping functions
99 
101  int power_of_two(int i);
102 
104  int maxboxindex (int level);
105 
107  void calculate_repulsive_forces_by_NMM(const Graph &G, NodeArray
108  <NodeAttributes>& A, NodeArray<DPoint>& F_rep);
109 
112  void calculate_repulsive_forces_by_exact_method(const Graph &G,
114  NodeArray<DPoint>& F_rep);
115 
117 
120  void build_up_red_quad_tree_path_by_path(const Graph& G,
122  QuadTreeNM& T);
123 
128  void make_copy_and_init_Lists(List<ParticleInfo>& L_x_orig,
129  List<ParticleInfo>& L_x_copy,
130  List<ParticleInfo>& L_y_orig,
131  List<ParticleInfo>& L_y_copy);
132 
134  void build_up_root_node(const Graph& G,NodeArray<NodeAttributes>& A, QuadTreeNM& T);
135 
137  void create_sorted_coordinate_Lists(const Graph& G,NodeArray<NodeAttributes>& A,
139 
143  void decompose_subtreenode(QuadTreeNM& T,
144  List<ParticleInfo>& act_x_List_copy,
145  List<ParticleInfo>& act_y_List_copy,
146  List<QuadTreeNodeNM*>& new_leaf_List);
147 
149  void calculate_boundaries_of_act_node(QuadTreeNodeNM* act_ptr, DPoint &min, DPoint &max);
150 
153  bool in_lt_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
154  bool in_rt_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
155  bool in_lb_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
156  bool in_rb_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
157  bool quadHelper(DPoint min, DPoint max, DPoint bottomleft, DPoint topright, QuadTreeNodeNM* act_ptr);
158 
166  void split(
167  QuadTreeNodeNM* act_ptr,
168  List<ParticleInfo>*& L_x_left_ptr,
169  List<ParticleInfo>*& L_y_left_ptr,
170  List<ParticleInfo>*& L_x_right_ptr,
171  List<ParticleInfo>*& L_y_right_ptr,
172  bool isHorizontal);
173 
182  void delete_subLists(
183  QuadTreeNodeNM* act_ptr,
184  List<ParticleInfo>*& L_x_left_ptr,
185  List<ParticleInfo>*& L_y_left_ptr,
186  List<ParticleInfo>*& L_x_right_ptr,
187  List<ParticleInfo>*& L_y_right_ptr,
188  ListIterator<ParticleInfo> last_left_item,
189  bool deleteRight,
190  bool isHorizontal);
191 
194  void split_in_y_direction(
195  QuadTreeNodeNM* act_ptr,
196  List<ParticleInfo>*& L_x_ptr,
197  List<ParticleInfo>*& L_x_b_ptr,
198  List<ParticleInfo>*& L_x_t_ptr,
199  List<ParticleInfo>*& L_y_ptr,
200  List<ParticleInfo>*& L_y_b_ptr,
201  List<ParticleInfo>*& L_y_t_ptr);
202 
208  void move_subLists_vertical(
209  List<ParticleInfo>*& L_x_ptr,
210  List<ParticleInfo>*& L_x_b_ptr,
211  List<ParticleInfo>*& L_x_t_ptr,
212  List<ParticleInfo>*& L_y_ptr,
213  List<ParticleInfo>*& L_y_b_ptr,
214  List<ParticleInfo>*& L_y_t_ptr,
215  ListIterator<ParticleInfo> last_left_item,
216  bool moveRight);
217 
220  void build_up_sorted_subLists(List<ParticleInfo>& L_x_copy,
221  List<ParticleInfo>& act_y_List_copy);
222 
226 
229  void build_up_red_quad_tree_subtree_by_subtree(const Graph& G,
231  QuadTreeNM& T);
232 
235  void build_up_root_vertex(const Graph&G, QuadTreeNM& T);
236 
242  void construct_subtree(NodeArray<NodeAttributes>& A,
243  QuadTreeNM& T,
244  QuadTreeNodeNM* subtree_root_ptr,
245  List<QuadTreeNodeNM*>& new_subtree_root_List);
246 
252  void construct_complete_subtree(QuadTreeNM& T,
253  int subtree_depth,
254  Array2D<QuadTreeNodeNM*>& leaf_ptr,
255  int act_depth,
256  int act_x_index,
257  int act_y_index);
258 
263  void set_contained_nodes_for_leaves(NodeArray<NodeAttributes>& A,
264  QuadTreeNodeNM* subtree_root_ptr,
265  Array2D<QuadTreeNodeNM*>& leaf_ptr,
266  int maxindex);
267 
270  void set_particlenumber_in_subtree_entries(QuadTreeNM& T);
271 
276  void construct_reduced_subtree(NodeArray<NodeAttributes>& A,
277  QuadTreeNM& T,
278  List<QuadTreeNodeNM*>& new_subtree_root_List);
279 
282  void delete_empty_subtrees(QuadTreeNM& T);
283 
289  bool check_and_delete_degenerated_node(QuadTreeNM& T);
290 
295  void delete_sparse_subtree(QuadTreeNM& T, QuadTreeNodeNM* new_leaf_ptr);
296 
300  void collect_contained_nodes(QuadTreeNM& T, QuadTreeNodeNM* new_leaf_ptr);
301 
308  bool find_smallest_quad(NodeArray<NodeAttributes>& A, QuadTreeNM& T);
309 
311 
314  void find_small_cell_iteratively(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
315 
318  void find_small_cell_by_formula(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
319 
322  void find_small_cell(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max) {
323  switch (find_sm_cell()) {
325  find_small_cell_iteratively(act_ptr, min, max);
326  break;
328  find_small_cell_by_formula(act_ptr, min, max);
329  break;
330  }
331  }
332 
334  void delete_red_quad_tree_and_count_treenodes(QuadTreeNM& T);
335 
338  void form_multipole_expansions(NodeArray<NodeAttributes>& A,
339  QuadTreeNM& T,
340  List<QuadTreeNodeNM*>& quad_tree_leaves);
341 
344  void form_multipole_expansion_of_subtree(NodeArray<NodeAttributes>& A,
345  QuadTreeNM& T,
346  List<QuadTreeNodeNM*>& quad_tree_leaves);
347 
349  void init_expansion_Lists(QuadTreeNodeNM* act_ptr);
350 
352  void set_center(QuadTreeNodeNM* act_ptr);
353 
355  void form_multipole_expansion_of_leaf_node(NodeArray<NodeAttributes>& A,
356  QuadTreeNodeNM* act_ptr);
357 
360  void add_shifted_expansion_to_father_expansion(QuadTreeNodeNM* act_ptr);
361 
365  void calculate_local_expansions_and_WSPRLS(NodeArray<NodeAttributes>&A,
366  QuadTreeNodeNM* act_node_ptr);
367 
370  bool well_separated(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
371 
373  bool bordering(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
374 
377  void add_shifted_local_exp_of_parent(QuadTreeNodeNM* node_ptr);
378 
381  void add_local_expansion(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
382 
386  void add_local_expansion_of_leaf(NodeArray<NodeAttributes>&A,
387  QuadTreeNodeNM* leaf_ptr,
388  QuadTreeNodeNM* act_ptr);
389 
392  void transform_local_exp_to_forces(NodeArray <NodeAttributes>&A,
393  List<QuadTreeNodeNM*>& quad_tree_leaves,
394  NodeArray<DPoint>& F_local_exp);
395 
398  void transform_multipole_exp_to_forces(NodeArray<NodeAttributes>& A,
399  List<QuadTreeNodeNM*>& quad_tree_leaves,
400  NodeArray<DPoint>& F_multipole_exp);
401 
404  void calculate_neighbourcell_forces(NodeArray<NodeAttributes>& A,
405  List<QuadTreeNodeNM*>& quad_tree_leaves,
406  NodeArray<DPoint>& F_direct);
407 
409  void add_rep_forces(const Graph& G,
410  NodeArray<DPoint>& F_direct,
411  NodeArray<DPoint>& F_multipole_exp,
412  NodeArray<DPoint>& F_local_exp,
413  NodeArray<DPoint>& F_rep);
414 
416  void init_binko(int t);
417 
419  void free_binko();
420 
422  double binko(int n, int k);
423 
425  FMMMOptions::ReducedTreeConstruction tree_construction_way() const { return _tree_construction_way; }
426 
428  _tree_construction_way = rtc;
429  }
430 
433  FMMMOptions::SmallestCellFinding find_sm_cell() const { return _find_small_cell; }
434 
436  _find_small_cell = scf;
437  }
438 
440  void particles_in_leaves (int b) { _particles_in_leaves = ((b>= 1)? b : 1); }
441  int particles_in_leaves () const { return _particles_in_leaves; }
442 
444  void precision (int p) { _precision = ((p >= 1 ) ? p : 1); }
445  int precision () const { return _precision; }
446 };
447 
448 }
449 }
450 }
FruchtermanReingold ExactMethod
needed in case that using_NMM == false
FMMMOptions::SmallestCellFinding find_sm_cell() const
Returns the way the smallest quadratic cell that surrounds the particles of a node in the reduced buc...
helping data structure that stores the graphical attributes of a node that are needed for the force-d...
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
double ** BK
holds the binomial coefficients
ReducedTreeConstruction
Specifies how the reduced bucket quadtree is constructed.
Definition: FMMMOptions.h:136
FMMMOptions::ReducedTreeConstruction _tree_construction_way
int _precision
precision for p-term multipole expansion
bool using_NMM
Indicates whether the exact method or NMM is used for force calculation (value depends on MIN_NODE_NU...
Helping data structure that stores the information needed to represent a node of the reduced quad tre...
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
According to formula by Aluru et al.
Declaration of Fast Multipole Multilevel Method (FM^3) options.
List< DPoint > rep_forces
stores the rep. forces of the last iteration needed for error calculation)
Helping data structure that stores the information needed to represent the modified quadtree in the N...
Definition: QuadTreeNM.h:42
void find_small_cell(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
Finds the small cell of the actual node using the selected algorithm.
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
FMMMOptions::SmallestCellFinding _find_small_cell
The parameterized class Array2D implements dynamic two-dimensional arrays.
Definition: Array2D.h:46
Encapsulates a pointer to a list element.
Definition: List.h:42
void find_sm_cell(FMMMOptions::SmallestCellFinding scf)
void particles_in_leaves(int b)
Max. number of particles that are contained in a leaf of the red. quadtree.
Includes declaration of graph class.
Declaration of class FruchtermanReingold (computation of forces).
void precision(int p)
The precision p for the p-term multipole expansions.
FMMMOptions::ReducedTreeConstruction tree_construction_way() const
Returns the way to construct the reduced tree.
DPoint down_left_corner
down left corner of drawing box
Declaration of class QuadTreeNM.
The namespace for all OGDF objects.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment, DPolygon, DRect, DIntersectableRect.
SmallestCellFinding
Specifies how to calculate the smallest quadratic cell that surrounds the particles of a node in the ...
Definition: FMMMOptions.h:143
int MIN_NODE_NUMBER
The minimum number of nodes for which the forces are calculated using NMM (for lower values the exact...
void tree_construction_way(FMMMOptions::ReducedTreeConstruction rtc)
Declaration of doubly linked lists and iterators.
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays...