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/Graph.h>
35 #include <ogdf/basic/List.h>
36 #include <ogdf/basic/basic.h>
37 #include <ogdf/basic/geometry.h>
40 
41 namespace ogdf::energybased::fmmm {
42 class NodeAttributes;
43 class ParticleInfo;
44 class QuadTreeNM;
45 class QuadTreeNodeNM;
46 } // namespace ogdf::energybased::fmmm
47 
48 namespace ogdf {
49 template<class E>
50 class Array2D;
51 
52 namespace energybased {
53 namespace fmmm {
54 
56 public:
59 
61  void calculate_repulsive_forces(const Graph& G, NodeArray<NodeAttributes>& A,
62  NodeArray<DPoint>& F_rep);
63 
65  void make_initialisations(const Graph& G, double boxlength, DPoint down_left_corner,
66  int particles_in_leaves, int precision,
67  FMMMOptions::ReducedTreeConstruction tree_construction_way,
68  FMMMOptions::SmallestCellFinding find_small_cell);
69 
71  void deallocate_memory();
72 
74  void update_boxlength_and_cornercoordinate(double b_l, DPoint d_l_c);
75 
76 private:
83  bool using_NMM;
85 
89  int _precision;
90 
91  double boxlength;
93 
95  double** BK;
96 
100 
101  // private helping functions
102 
104  int power_of_two(int i);
105 
107  int maxboxindex(int level);
108 
110  void calculate_repulsive_forces_by_NMM(const Graph& G, NodeArray<NodeAttributes>& A,
111  NodeArray<DPoint>& F_rep);
112 
115  void calculate_repulsive_forces_by_exact_method(const Graph& G, NodeArray<NodeAttributes>& A,
116  NodeArray<DPoint>& F_rep);
117 
120 
123  void build_up_red_quad_tree_path_by_path(const Graph& G, NodeArray<NodeAttributes>& A,
124  QuadTreeNM& T);
125 
130  void make_copy_and_init_Lists(List<ParticleInfo>& L_x_orig, List<ParticleInfo>& L_x_copy,
131  List<ParticleInfo>& L_y_orig, 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, List<ParticleInfo>& act_x_List_copy,
144  List<ParticleInfo>& act_y_List_copy, List<QuadTreeNodeNM*>& new_leaf_List);
145 
147  void calculate_boundaries_of_act_node(QuadTreeNodeNM* act_ptr, DPoint& min, DPoint& max);
148 
151  bool in_lt_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
152  bool in_rt_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
153  bool in_lb_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
154  bool in_rb_quad(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
155  bool quadHelper(DPoint min, DPoint max, DPoint bottomleft, DPoint topright,
156  QuadTreeNodeNM* act_ptr);
157 
165  void split(QuadTreeNodeNM* act_ptr, List<ParticleInfo>*& L_x_left_ptr,
166  List<ParticleInfo>*& L_y_left_ptr, List<ParticleInfo>*& L_x_right_ptr,
167  List<ParticleInfo>*& L_y_right_ptr, bool isHorizontal);
168 
177  void delete_subLists(QuadTreeNodeNM* act_ptr, List<ParticleInfo>*& L_x_left_ptr,
178  List<ParticleInfo>*& L_y_left_ptr, List<ParticleInfo>*& L_x_right_ptr,
179  List<ParticleInfo>*& L_y_right_ptr, ListIterator<ParticleInfo> last_left_item,
180  bool deleteRight, bool isHorizontal);
181 
184  void split_in_y_direction(QuadTreeNodeNM* act_ptr, List<ParticleInfo>*& L_x_ptr,
185  List<ParticleInfo>*& L_x_b_ptr, List<ParticleInfo>*& L_x_t_ptr,
186  List<ParticleInfo>*& L_y_ptr, List<ParticleInfo>*& L_y_b_ptr,
187  List<ParticleInfo>*& L_y_t_ptr);
188 
194  void move_subLists_vertical(List<ParticleInfo>*& L_x_ptr, List<ParticleInfo>*& L_x_b_ptr,
195  List<ParticleInfo>*& L_x_t_ptr, List<ParticleInfo>*& L_y_ptr,
196  List<ParticleInfo>*& L_y_b_ptr, List<ParticleInfo>*& L_y_t_ptr,
197  ListIterator<ParticleInfo> last_left_item, bool moveRight);
198 
201  void build_up_sorted_subLists(List<ParticleInfo>& L_x_copy, List<ParticleInfo>& act_y_List_copy);
202 
206 
209  void build_up_red_quad_tree_subtree_by_subtree(const Graph& G, NodeArray<NodeAttributes>& A,
210  QuadTreeNM& T);
211 
214  void build_up_root_vertex(const Graph& G, QuadTreeNM& T);
215 
221  void construct_subtree(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
222  QuadTreeNodeNM* subtree_root_ptr, List<QuadTreeNodeNM*>& new_subtree_root_List);
223 
229  void construct_complete_subtree(QuadTreeNM& T, int subtree_depth,
230  Array2D<QuadTreeNodeNM*>& leaf_ptr, int act_depth, int act_x_index, int act_y_index);
231 
236  void set_contained_nodes_for_leaves(NodeArray<NodeAttributes>& A,
237  QuadTreeNodeNM* subtree_root_ptr, Array2D<QuadTreeNodeNM*>& leaf_ptr, int maxindex);
238 
241  void set_particlenumber_in_subtree_entries(QuadTreeNM& T);
242 
247  void construct_reduced_subtree(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
248  List<QuadTreeNodeNM*>& new_subtree_root_List);
249 
252  void delete_empty_subtrees(QuadTreeNM& T);
253 
259  bool check_and_delete_degenerated_node(QuadTreeNM& T);
260 
265  void delete_sparse_subtree(QuadTreeNM& T, QuadTreeNodeNM* new_leaf_ptr);
266 
270  void collect_contained_nodes(QuadTreeNM& T, QuadTreeNodeNM* new_leaf_ptr);
271 
278  bool find_smallest_quad(NodeArray<NodeAttributes>& A, QuadTreeNM& T);
279 
281 
284  void find_small_cell_iteratively(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
285 
288  void find_small_cell_by_formula(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max);
289 
292  void find_small_cell(QuadTreeNodeNM* act_ptr, DPoint min, DPoint max) {
293  switch (find_sm_cell()) {
295  find_small_cell_iteratively(act_ptr, min, max);
296  break;
298  find_small_cell_by_formula(act_ptr, min, max);
299  break;
300  }
301  }
302 
304  void delete_red_quad_tree_and_count_treenodes(QuadTreeNM& T);
305 
308  void form_multipole_expansions(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
309  List<QuadTreeNodeNM*>& quad_tree_leaves);
310 
313  void form_multipole_expansion_of_subtree(NodeArray<NodeAttributes>& A, QuadTreeNM& T,
314  List<QuadTreeNodeNM*>& quad_tree_leaves);
315 
317  void init_expansion_Lists(QuadTreeNodeNM* act_ptr);
318 
320  void set_center(QuadTreeNodeNM* act_ptr);
321 
323  void form_multipole_expansion_of_leaf_node(NodeArray<NodeAttributes>& A, QuadTreeNodeNM* act_ptr);
324 
327  void add_shifted_expansion_to_father_expansion(QuadTreeNodeNM* act_ptr);
328 
332  void calculate_local_expansions_and_WSPRLS(NodeArray<NodeAttributes>& A,
333  QuadTreeNodeNM* act_node_ptr);
334 
337  bool well_separated(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
338 
340  bool bordering(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
341 
344  void add_shifted_local_exp_of_parent(QuadTreeNodeNM* node_ptr);
345 
348  void add_local_expansion(QuadTreeNodeNM* ptr_1, QuadTreeNodeNM* ptr_2);
349 
353  void add_local_expansion_of_leaf(NodeArray<NodeAttributes>& A, QuadTreeNodeNM* leaf_ptr,
354  QuadTreeNodeNM* act_ptr);
355 
358  void transform_local_exp_to_forces(NodeArray<NodeAttributes>& A,
359  List<QuadTreeNodeNM*>& quad_tree_leaves, NodeArray<DPoint>& F_local_exp);
360 
363  void transform_multipole_exp_to_forces(NodeArray<NodeAttributes>& A,
364  List<QuadTreeNodeNM*>& quad_tree_leaves, NodeArray<DPoint>& F_multipole_exp);
365 
368  void calculate_neighbourcell_forces(NodeArray<NodeAttributes>& A,
369  List<QuadTreeNodeNM*>& quad_tree_leaves, NodeArray<DPoint>& F_direct);
370 
372  void add_rep_forces(const Graph& G, NodeArray<DPoint>& F_direct,
373  NodeArray<DPoint>& F_multipole_exp, NodeArray<DPoint>& F_local_exp,
374  NodeArray<DPoint>& F_rep);
375 
377  void init_binko(int t);
378 
380  void free_binko();
381 
383  double binko(int n, int k);
384 
387  return _tree_construction_way;
388  }
389 
391  _tree_construction_way = rtc;
392  }
393 
396  FMMMOptions::SmallestCellFinding find_sm_cell() const { return _find_small_cell; }
397 
398  void find_sm_cell(FMMMOptions::SmallestCellFinding scf) { _find_small_cell = scf; }
399 
401  void particles_in_leaves(int b) { _particles_in_leaves = ((b >= 1) ? b : 1); }
402 
403  int particles_in_leaves() const { return _particles_in_leaves; }
404 
406  void precision(int p) { _precision = ((p >= 1) ? p : 1); }
407 
408  int precision() const { return _precision; }
409 };
410 
411 }
412 }
413 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::energybased::fmmm::NewMultipoleMethod::ExactMethod
FruchtermanReingold ExactMethod
needed in case that using_NMM == false
Definition: NewMultipoleMethod.h:84
Graph.h
Includes declaration of graph class.
ogdf::GenericPoint
Parameterized base class for points.
Definition: geometry.h:81
ogdf::energybased::fmmm::NewMultipoleMethod::BK
double ** BK
holds the binomial coefficients
Definition: NewMultipoleMethod.h:95
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::energybased::fmmm
Definition: common.h:43
ogdf::energybased::fmmm::NewMultipoleMethod::particles_in_leaves
int particles_in_leaves() const
Definition: NewMultipoleMethod.h:403
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:55
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:99
ogdf::Array2D
The parameterized class Array2D implements dynamic two-dimensional arrays.
Definition: Array2D.h:53
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:396
ogdf::energybased::fmmm::NewMultipoleMethod::precision
int precision() const
Definition: NewMultipoleMethod.h:408
ogdf::energybased::fmmm::QuadTreeNM
Helping data structure that stores the information needed to represent the modified quadtree in the N...
Definition: QuadTreeNM.h:51
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:292
ogdf::energybased::fmmm::FruchtermanReingold
Definition: FruchtermanReingold.h:46
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:83
FruchtermanReingold.h
Declaration of class FruchtermanReingold (computation of forces).
ogdf::energybased::fmmm::NewMultipoleMethod::_find_small_cell
FMMMOptions::SmallestCellFinding _find_small_cell
Definition: NewMultipoleMethod.h:87
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: DfsMakeBiconnected.h:40
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::energybased::fmmm::QuadTreeNodeNM
Helping data structure that stores the information needed to represent a node of the reduced quad tre...
Definition: QuadTreeNodeNM.h:52
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::FMMMOptions::SmallestCellFinding::Iteratively
@ Iteratively
Iteratively (in constant time).
ogdf::energybased::fmmm::NewMultipoleMethod::_tree_construction_way
FMMMOptions::ReducedTreeConstruction _tree_construction_way
Definition: NewMultipoleMethod.h:86
ogdf::energybased::fmmm::NewMultipoleMethod::_precision
int _precision
precision for p-term multipole expansion
Definition: NewMultipoleMethod.h:89
ogdf::energybased::fmmm::NewMultipoleMethod::precision
void precision(int p)
The precision p for the p-term multipole expansions.
Definition: NewMultipoleMethod.h:406
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:401
ogdf::energybased::fmmm::NewMultipoleMethod::tree_construction_way
FMMMOptions::ReducedTreeConstruction tree_construction_way() const
Returns the way to construct the reduced tree.
Definition: NewMultipoleMethod.h:386
basic.h
Basic declarations, included by all source files.
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:92
ogdf::energybased::fmmm::NewMultipoleMethod::max_power_of_2_index
const int max_power_of_2_index
holds max.
Definition: NewMultipoleMethod.h:94
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:88
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:51
ogdf::energybased::fmmm::NewMultipoleMethod::boxlength
double boxlength
length of drawing box
Definition: NewMultipoleMethod.h:91
ogdf::energybased::fmmm::NewMultipoleMethod::tree_construction_way
void tree_construction_way(FMMMOptions::ReducedTreeConstruction rtc)
Definition: NewMultipoleMethod.h:390
ogdf::energybased::fmmm::NewMultipoleMethod::find_sm_cell
void find_sm_cell(FMMMOptions::SmallestCellFinding scf)
Definition: NewMultipoleMethod.h:398
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:80