Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
44 namespace ogdf {
45 namespace energybased {
46 namespace fmmm {
47 
49 public:
52 
54  void calculate_repulsive_forces(const Graph& G, NodeArray<NodeAttributes>& A,
55  NodeArray<DPoint>& F_rep);
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 
64  void deallocate_memory();
65 
67  void update_boxlength_and_cornercoordinate(double b_l, DPoint d_l_c);
68 
69 private:
76  bool using_NMM;
78 
82  int _precision;
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 
103  void calculate_repulsive_forces_by_NMM(const Graph& G, NodeArray<NodeAttributes>& A,
104  NodeArray<DPoint>& F_rep);
105 
108  void calculate_repulsive_forces_by_exact_method(const Graph& G, NodeArray<NodeAttributes>& A,
109  NodeArray<DPoint>& F_rep);
110 
113 
116  void build_up_red_quad_tree_path_by_path(const Graph& G, NodeArray<NodeAttributes>& A,
117  QuadTreeNM& T);
118 
123  void make_copy_and_init_Lists(List<ParticleInfo>& L_x_orig, List<ParticleInfo>& L_x_copy,
124  List<ParticleInfo>& L_y_orig, List<ParticleInfo>& L_y_copy);
125 
127  void build_up_root_node(const Graph& G, NodeArray<NodeAttributes>& A, QuadTreeNM& T);
128 
130  void create_sorted_coordinate_Lists(const Graph& G, NodeArray<NodeAttributes>& A,
132 
136  void decompose_subtreenode(QuadTreeNM& T, List<ParticleInfo>& act_x_List_copy,
137  List<ParticleInfo>& act_y_List_copy, List<QuadTreeNodeNM*>& new_leaf_List);
138 
140  void calculate_boundaries_of_act_node(QuadTreeNodeNM* act_ptr, DPoint& min, DPoint& max);
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);
148  bool quadHelper(DPoint min, DPoint max, DPoint bottomleft, DPoint topright,
149  QuadTreeNodeNM* act_ptr);
150 
158  void split(QuadTreeNodeNM* act_ptr, List<ParticleInfo>*& L_x_left_ptr,
159  List<ParticleInfo>*& L_y_left_ptr, List<ParticleInfo>*& L_x_right_ptr,
160  List<ParticleInfo>*& L_y_right_ptr, bool isHorizontal);
161 
170  void delete_subLists(QuadTreeNodeNM* act_ptr, List<ParticleInfo>*& L_x_left_ptr,
171  List<ParticleInfo>*& L_y_left_ptr, List<ParticleInfo>*& L_x_right_ptr,
172  List<ParticleInfo>*& L_y_right_ptr, ListIterator<ParticleInfo> last_left_item,
173  bool deleteRight, bool isHorizontal);
174 
177  void split_in_y_direction(QuadTreeNodeNM* act_ptr, List<ParticleInfo>*& L_x_ptr,
178  List<ParticleInfo>*& L_x_b_ptr, List<ParticleInfo>*& L_x_t_ptr,
179  List<ParticleInfo>*& L_y_ptr, List<ParticleInfo>*& L_y_b_ptr,
180  List<ParticleInfo>*& L_y_t_ptr);
181 
187  void move_subLists_vertical(List<ParticleInfo>*& L_x_ptr, List<ParticleInfo>*& L_x_b_ptr,
188  List<ParticleInfo>*& L_x_t_ptr, List<ParticleInfo>*& L_y_ptr,
189  List<ParticleInfo>*& L_y_b_ptr, List<ParticleInfo>*& L_y_t_ptr,
190  ListIterator<ParticleInfo> last_left_item, bool moveRight);
191 
194  void build_up_sorted_subLists(List<ParticleInfo>& L_x_copy, List<ParticleInfo>& act_y_List_copy);
195 
199 
202  void build_up_red_quad_tree_subtree_by_subtree(const Graph& G, NodeArray<NodeAttributes>& A,
203  QuadTreeNM& T);
204 
207  void build_up_root_vertex(const Graph& G, QuadTreeNM& T);
208 
214  void construct_subtree(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
215  QuadTreeNodeNM* subtree_root_ptr, List<QuadTreeNodeNM*>& new_subtree_root_List);
216 
222  void construct_complete_subtree(QuadTreeNM& T, int subtree_depth,
223  Array2D<QuadTreeNodeNM*>& leaf_ptr, int act_depth, int act_x_index, int act_y_index);
224 
229  void set_contained_nodes_for_leaves(NodeArray<NodeAttributes>& A,
230  QuadTreeNodeNM* subtree_root_ptr, Array2D<QuadTreeNodeNM*>& leaf_ptr, int maxindex);
231 
234  void set_particlenumber_in_subtree_entries(QuadTreeNM& T);
235 
240  void construct_reduced_subtree(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
241  List<QuadTreeNodeNM*>& new_subtree_root_List);
242 
245  void delete_empty_subtrees(QuadTreeNM& T);
246 
252  bool check_and_delete_degenerated_node(QuadTreeNM& T);
253 
258  void delete_sparse_subtree(QuadTreeNM& T, QuadTreeNodeNM* new_leaf_ptr);
259 
263  void collect_contained_nodes(QuadTreeNM& T, QuadTreeNodeNM* new_leaf_ptr);
264 
271  bool find_smallest_quad(NodeArray<NodeAttributes>& A, QuadTreeNM& T);
272 
274 
277  void find_small_cell_iteratively(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
278 
281  void find_small_cell_by_formula(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
282 
285  void find_small_cell(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max) {
286  switch (find_sm_cell()) {
288  find_small_cell_iteratively(act_ptr, min, max);
289  break;
291  find_small_cell_by_formula(act_ptr, min, max);
292  break;
293  }
294  }
295 
297  void delete_red_quad_tree_and_count_treenodes(QuadTreeNM& T);
298 
301  void form_multipole_expansions(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
302  List<QuadTreeNodeNM*>& quad_tree_leaves);
303 
306  void form_multipole_expansion_of_subtree(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
307  List<QuadTreeNodeNM*>& quad_tree_leaves);
308 
310  void init_expansion_Lists(QuadTreeNodeNM* act_ptr);
311 
313  void set_center(QuadTreeNodeNM* act_ptr);
314 
316  void form_multipole_expansion_of_leaf_node(NodeArray<NodeAttributes>& A, QuadTreeNodeNM* act_ptr);
317 
320  void add_shifted_expansion_to_father_expansion(QuadTreeNodeNM* act_ptr);
321 
325  void calculate_local_expansions_and_WSPRLS(NodeArray<NodeAttributes>& A,
326  QuadTreeNodeNM* act_node_ptr);
327 
330  bool well_separated(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
331 
333  bool bordering(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
334 
337  void add_shifted_local_exp_of_parent(QuadTreeNodeNM* node_ptr);
338 
341  void add_local_expansion(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
342 
346  void add_local_expansion_of_leaf(NodeArray<NodeAttributes>& A, QuadTreeNodeNM* leaf_ptr,
347  QuadTreeNodeNM* act_ptr);
348 
351  void transform_local_exp_to_forces(NodeArray<NodeAttributes>& A,
352  List<QuadTreeNodeNM*>& quad_tree_leaves, NodeArray<DPoint>& F_local_exp);
353 
356  void transform_multipole_exp_to_forces(NodeArray<NodeAttributes>& A,
357  List<QuadTreeNodeNM*>& quad_tree_leaves, NodeArray<DPoint>& F_multipole_exp);
358 
361  void calculate_neighbourcell_forces(NodeArray<NodeAttributes>& A,
362  List<QuadTreeNodeNM*>& quad_tree_leaves, NodeArray<DPoint>& F_direct);
363 
365  void add_rep_forces(const Graph& G, NodeArray<DPoint>& F_direct,
366  NodeArray<DPoint>& F_multipole_exp, NodeArray<DPoint>& F_local_exp,
367  NodeArray<DPoint>& F_rep);
368 
370  void init_binko(int t);
371 
373  void free_binko();
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 
391  void find_sm_cell(FMMMOptions::SmallestCellFinding scf) { _find_small_cell = scf; }
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 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::energybased::fmmm::NewMultipoleMethod::ExactMethod
FruchtermanReingold ExactMethod
needed in case that using_NMM == false
Definition: NewMultipoleMethod.h:77
Graph.h
Includes declaration of graph class.
ogdf::GenericPoint
Parameterized base class for points.
Definition: geometry.h:74
ogdf::energybased::fmmm::NewMultipoleMethod::BK
double ** BK
holds the binomial coefficients
Definition: NewMultipoleMethod.h:88
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::energybased::fmmm::NewMultipoleMethod::particles_in_leaves
int particles_in_leaves() const
Definition: NewMultipoleMethod.h:396
ogdf::whaType::A
@ A
ogdf::sync_plan::split
std::pair< node, node > split(Graph &G, sync_plan::PipeBij &bij, const EdgeArray< edge > *new_edges=nullptr, const EdgeArray< bool > *reverse_edges=nullptr, node src=nullptr, node tgt=nullptr)
ogdf::energybased::fmmm::NewMultipoleMethod
Definition: NewMultipoleMethod.h:48
ogdf::energybased::fmmm::NewMultipoleMethod::rep_forces
List< DPoint > rep_forces
stores the rep. forces of the last iteration needed for error calculation)
Definition: NewMultipoleMethod.h:92
ogdf::Array2D
The parameterized class Array2D implements dynamic two-dimensional arrays.
Definition: Array2D.h:47
ogdf::FMMMOptions::SmallestCellFinding::Aluru
@ Aluru
According to formula by Aluru et al.
ogdf::energybased::fmmm::NewMultipoleMethod::find_sm_cell
FMMMOptions::SmallestCellFinding find_sm_cell() const
Returns the way the smallest quadratic cell that surrounds the particles of a node in the reduced buc...
Definition: NewMultipoleMethod.h:389
ogdf::energybased::fmmm::NewMultipoleMethod::precision
int precision() const
Definition: NewMultipoleMethod.h:401
ogdf::energybased::fmmm::QuadTreeNM
Helping data structure that stores the information needed to represent the modified quadtree in the N...
Definition: QuadTreeNM.h:42
ogdf::energybased::fmmm::NewMultipoleMethod::find_small_cell
void find_small_cell(QuadTreeNodeNM *act_ptr, DPoint min, DPoint max)
Finds the small cell of the actual node using the selected algorithm.
Definition: NewMultipoleMethod.h:285
ogdf::energybased::fmmm::FruchtermanReingold
Definition: FruchtermanReingold.h:44
ogdf::energybased::fmmm::NewMultipoleMethod::using_NMM
bool using_NMM
Indicates whether the exact method or NMM is used for force calculation (value depends on MIN_NODE_NU...
Definition: NewMultipoleMethod.h:76
QuadTreeNM.h
Declaration of class QuadTreeNM.
FruchtermanReingold.h
Declaration of class FruchtermanReingold (computation of forces).
ogdf::energybased::fmmm::NewMultipoleMethod::_find_small_cell
FMMMOptions::SmallestCellFinding _find_small_cell
Definition: NewMultipoleMethod.h:80
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::energybased::fmmm::QuadTreeNodeNM
Helping data structure that stores the information needed to represent a node of the reduced quad tre...
Definition: QuadTreeNodeNM.h:47
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::FMMMOptions::SmallestCellFinding::Iteratively
@ Iteratively
Iteratively (in constant time).
ogdf::energybased::fmmm::NewMultipoleMethod::_tree_construction_way
FMMMOptions::ReducedTreeConstruction _tree_construction_way
Definition: NewMultipoleMethod.h:79
ogdf::energybased::fmmm::NewMultipoleMethod::_precision
int _precision
precision for p-term multipole expansion
Definition: NewMultipoleMethod.h:82
ogdf::energybased::fmmm::NewMultipoleMethod::precision
void precision(int p)
The precision p for the p-term multipole expansions.
Definition: NewMultipoleMethod.h:399
ogdf::energybased::fmmm::NewMultipoleMethod::particles_in_leaves
void particles_in_leaves(int b)
Max. number of particles that are contained in a leaf of the red. quadtree.
Definition: NewMultipoleMethod.h:394
ogdf::energybased::fmmm::NewMultipoleMethod::tree_construction_way
FMMMOptions::ReducedTreeConstruction tree_construction_way() const
Returns the way to construct the reduced tree.
Definition: NewMultipoleMethod.h:379
ogdf::FMMMOptions::SmallestCellFinding
SmallestCellFinding
Specifies how to calculate the smallest quadratic cell that surrounds the particles of a node in the ...
Definition: FMMMOptions.h:144
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::energybased::fmmm::NewMultipoleMethod::down_left_corner
DPoint down_left_corner
down left corner of drawing box
Definition: NewMultipoleMethod.h:85
ogdf::energybased::fmmm::NewMultipoleMethod::max_power_of_2_index
const int max_power_of_2_index
holds max.
Definition: NewMultipoleMethod.h:87
List.h
Declaration of doubly linked lists and iterators.
ogdf::FMMMOptions::ReducedTreeConstruction
ReducedTreeConstruction
Specifies how the reduced bucket quadtree is constructed.
Definition: FMMMOptions.h:137
ogdf::energybased::fmmm::NewMultipoleMethod::_particles_in_leaves
int _particles_in_leaves
max.
Definition: NewMultipoleMethod.h:81
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:46
ogdf::energybased::fmmm::NewMultipoleMethod::boxlength
double boxlength
length of drawing box
Definition: NewMultipoleMethod.h:84
ogdf::energybased::fmmm::NewMultipoleMethod::tree_construction_way
void tree_construction_way(FMMMOptions::ReducedTreeConstruction rtc)
Definition: NewMultipoleMethod.h:383
Array2D.h
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays.
ogdf::energybased::fmmm::NewMultipoleMethod::find_sm_cell
void find_sm_cell(FMMMOptions::SmallestCellFinding scf)
Definition: NewMultipoleMethod.h:391
FMMMOptions.h
Declaration of Fast Multipole Multilevel Method (FM^3) options.
ogdf::energybased::fmmm::NewMultipoleMethod::MIN_NODE_NUMBER
int MIN_NODE_NUMBER
The minimum number of nodes for which the forces are calculated using NMM (for lower values the exact...
Definition: NewMultipoleMethod.h:73