Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

DTreeEmbedder.h
Go to the documentation of this file.
1 
29 #pragma once
30 
33 
34 namespace ogdf {
35 namespace energybased {
36 namespace dtree {
37 
38 template<int Dim>
40 public:
42  explicit DTreeEmbedder(const Graph& graph);
43 
45  virtual ~DTreeEmbedder();
46 
48  double position(node v, int d) const;
49 
51  void setPosition(node v, int d, double coord);
52 
54  double mass(node v) const;
55 
57  void setMass(node v, double mass);
58 
60  double edgeWeight(edge e) const;
61 
63  void setEdgeWeight(edge e, double weight);
64 
66  void resetForces();
67 
69  template<typename ForceFunc, bool UseForcePrime>
70  void computeRepForces(ForceFunc forceFunc);
71 
73  template<typename ForceFunc, bool UseForcePrime>
74  void computeRepForcesExact(ForceFunc forceFunc);
75 
77  template<typename ForceFunc, bool UseForcePrime>
78  void computeRepForcesApprox(ForceFunc forceFunc);
79 
81  template<typename AttrForceFunc, bool UseForcePrime>
82  void computeEdgeForces(AttrForceFunc attrForceFunc);
83 
84 #if 0
85  void computeEdgeForcesSq();
87 #endif
88 
90  double moveNodes(double timeStep);
91  double moveNodesByForcePrime();
92 
93 #if 0
94  template<typename RepForceFunc>
96  double doIteration(RepForceFunc repForceFunc);
97 
99  double doIteration() { return doIteration(RepForceFunctionInvDist<Dim>); };
100 
102  template<typename RepForceFunc>
103  void doIterations(int numIterations, double epsilon, RepForceFunc repForceFunc);
104 
106  template<typename RepForceFunc>
107  void doIterations(int numIterations, double epsilon);
108 #endif
109 
111  template<typename RepForceFunc, typename AttrForceFunc, bool UseForcePrime>
112  void doIterationsTempl(int numIterations, double epsilon, RepForceFunc repForceFunc,
113  AttrForceFunc attrForceFunc);
114 
115  template<typename RepForceFunc, typename AttrForceFunc>
116  void doIterationsStandard(int numIterations, double epsilon, RepForceFunc repForceFunc,
117  AttrForceFunc attrForceFunc);
118 
119  template<typename RepForceFunc, typename AttrForceFunc>
120  void doIterationsNewton(int numIterations, double epsilon, RepForceFunc repForceFunc,
121  AttrForceFunc attrForceFunc);
122 
123 #if 0
124  template<typename RepForceFunc>
125  void doIterationsAdaptive(int numIterations, double epsilon, RepForceFunc repForceFunc);
126 #endif
127 
129  const Graph& graph() const;
130 
132  void centerNodesAt(double centerBBox[Dim]);
133 
135  void scaleNodes(double scaleFactor);
136 
137 private:
139  struct NodeInfo {
141  double position[Dim];
142 
144  double force[Dim];
145 
147  double force_prime;
148 
150  double mass;
151  };
152 
154  const Graph& m_graph;
155 
158 
161 
164 
166 
168 };
169 
172 
173 template<int Dim>
174 DTreeEmbedder<Dim>::DTreeEmbedder(const Graph& graph) : m_graph(graph) {
176  m_nodeInfo.init(m_graph);
177  for (node v = m_graph.firstNode(); v; v = v->succ()) {
178  m_nodeInfo[v].mass = 1.0;
179  }
180 
181  m_edgeWeight.init(m_graph, 1.0);
183  m_defaultTimeStep = 0.125;
184 }
185 
186 template<int Dim>
188  delete m_pTreeForce;
189 }
190 
191 template<int Dim>
192 template<typename ForceFunc, bool UseForcePrime>
193 void DTreeEmbedder<Dim>::computeRepForcesExact(ForceFunc forceFunc) {
194  double delta[Dim];
195  double force;
196  double force_prime;
197  for (node s = m_graph.firstNode(); s; s = s->succ()) {
198  for (node t = s->succ(); t; t = t->succ()) {
199  double dist = computeDeltaAndDistance<Dim>(m_nodeInfo[s].position,
200  m_nodeInfo[t].position, delta);
201 
202  // evaluate the force function
203  forceFunc(dist, force, force_prime);
204 
205  force = force / dist * mass(s) * mass(t);
206 
207  // add the force to the existing
208  for (int d = 0; d < Dim; d++) {
209  m_nodeInfo[s].force[d] += force * delta[d];
210  m_nodeInfo[t].force[d] -= force * delta[d];
211  }
212 
213  if (UseForcePrime) {
214  force_prime = force_prime * mass(s) * mass(t);
215  m_nodeInfo[s].force_prime += force_prime;
216  m_nodeInfo[t].force_prime += force_prime;
217  }
218  }
219  }
220 }
221 
222 #if 0
223 template<int Dim>
224 template<typename ForceFunc>
225 void DTreeEmbedder<Dim>::computeRepForcesExact(ForceFunc forceFunc)
226 {
227  double delta[Dim];
228  double force;
229  for (node s = m_graph.firstNode(); s; s = s->succ()) {
230  for (node t = s->succ(); t; t = t->succ()) {
231  double dist = computeDeltaAndDistance<Dim>(m_nodeInfo[s].position, m_nodeInfo[t].position, delta);
232 
233  // evaluate the force function
234  forceFunc(dist, force);
235 
236  force = force / dist * mass(s) * mass(t);
237 
238  // add the force to the existing
239  for (int d = 0; d < Dim; d++) {
240  m_nodeInfo[s].force[d] += force * delta[d];
241  m_nodeInfo[s].force[d] += force * delta[d];
242  }
243  }
244  }
245 }
246 #endif
247 
248 template<int Dim>
249 template<typename ForceFunc, bool UseForcePrime>
251  int currIndex = 0;
252  // loop over all nodes
253  for (node v = m_graph.firstNode(); v; v = v->succ()) {
254  // update the node pos in the tree data structure
255  for (int d = 0; d < Dim; d++) {
256  m_pTreeForce->setPosition(currIndex, d, m_nodeInfo[v].position[d]);
257  }
258 
259  // update the mass
260  m_pTreeForce->setMass(currIndex, m_nodeInfo[v].mass);
261  currIndex++;
262  }
263 
264  // run the approximation
265  m_pTreeForce->template computeForces<ForceFunc, UseForcePrime>(forceFunc);
266 
267  // reset the index
268  currIndex = 0;
269 
270  // loop over all nodes
271  for (node v = m_graph.firstNode(); v; v = v->succ()) {
272  // read back the forces
273  for (int d = 0; d < Dim; d++) {
274  m_nodeInfo[v].force[d] += m_pTreeForce->force(currIndex, d);
275  }
276 
277  if (UseForcePrime) {
278  m_nodeInfo[v].force_prime += m_pTreeForce->force_prime(currIndex);
279  }
280 
281  currIndex++;
282  }
283 }
284 
285 #if 0
286 template<int Dim>
287 template<typename ForceFunc>
288 void DTreeEmbedder<Dim>::computeRepForcesApproxNewton(ForceFunc forceFunc)
289 {
290  int currIndex = 0;
291  // loop over all nodes
292  for (node v = m_graph.firstNode(); v; v = v->succ()) {
293  // update the node pos in the tree data structure
294  for (int d = 0; d < Dim; d++) {
295  m_pTreeForce->setPosition(currIndex, d, m_nodeInfo[v].position[d]);
296  }
297 
298  // update the mass
299  m_pTreeForce->setMass(currIndex, m_nodeInfo[v].mass);
300  currIndex++;
301  }
302 
303  // run the approximation
304  m_pTreeForce->template computeForces<ForceFunc, true>(forceFunc);
305 
306  // reset the index
307  currIndex = 0;
308 
309  // loop over all nodes
310  for (node v = m_graph.firstNode(); v; v = v->succ()) {
311  // read back the forces
312  for (int d = 0; d < Dim; d++) {
313  m_nodeInfo[v].force[d] += m_pTreeForce->force(currIndex, d);
314  }
315 
316  currIndex++;
317  }
318 }
319 #endif
320 
321 template<int Dim>
322 template<typename ForceFunc, bool UseForcePrime>
323 void DTreeEmbedder<Dim>::computeRepForces(ForceFunc forceFunc) {
324  if (m_graph.numberOfNodes() <= m_maxNumNodesExactRepForces) {
325  computeRepForcesExact<ForceFunc, UseForcePrime>(forceFunc);
326  } else {
327  computeRepForcesApprox<ForceFunc, UseForcePrime>(forceFunc);
328  }
329 }
330 
331 #if 0
332 template<int Dim>
333 template<typename ForceFunc>
334 void DTreeEmbedder<Dim>::computeRepForcesNewton(ForceFunc forceFunc)
335 {
336  if (m_graph.numberOfNodes() <= m_maxNumNodesExactRepForces) {
337  computeRepForcesExactNewton(forceFunc);
338  } else {
339  computeRepForcesApproxNewton(forceFunc);
340  }
341 }
342 #endif
343 
344 template<int Dim>
345 template<typename AttrForceFunc, bool UseForcePrime>
346 void DTreeEmbedder<Dim>::computeEdgeForces(AttrForceFunc attrForceFunc) {
347  // for all edges
348  for (edge e = m_graph.firstEdge(); e; e = e->succ()) {
349  node s = e->source();
350  node t = e->target();
351 
352  // check if this is a self loop
353  if (s == t) {
354  continue;
355  }
356 
357  // s t delta vector
358  double delta[Dim];
359 
360  // var for the squared distance of s and t
361  double dist_sq = 0.0;
362 
363  // compute delta and sum up dist_sq
364  for (int d = 0; d < Dim; d++) {
365  delta[d] = m_nodeInfo[t].position[d] - m_nodeInfo[s].position[d];
366  dist_sq += delta[d] * delta[d];
367  }
368 
369  // we take the log of the squared distance here
370 #if 0
371  double f = log(dist_sq) * 0.5;
372 #endif
373  double dist = (sqrt(dist_sq));
374 
375  double f;
376  double f_prime;
377 
378  if (UseForcePrime) {
379  attrForceFunc(dist, f, f_prime);
380 
381  f_prime *= m_edgeWeight[e];
382 
383  m_nodeInfo[s].force_prime += f_prime;
384  m_nodeInfo[t].force_prime += f_prime;
385  } else {
386  attrForceFunc(dist, f, f_prime);
387  }
388 
389  f *= m_edgeWeight[e];
390 
391  // compute delta and sum up dist_sq
392  for (int d = 0; d < Dim; d++) {
393  m_nodeInfo[s].force[d] += f * delta[d] / dist; // * s_scale;
394  m_nodeInfo[t].force[d] -= f * delta[d] / dist; // * t_scale;
395  }
396  }
397 }
398 
399 #if 0
400 template<int Dim>
401 template<typename AttrForceFunc>
402 void DTreeEmbedder<Dim>::computeEdgeForces(AttrForceFunc attrForceFunc)
403 {
404  // for all edges
405  for (edge e = m_graph.firstEdge(); e; e = e->succ()) {
406  node s = e->source();
407  node t = e->target();
408 
409  // check if this is a self loop
410  if (s == t) {
411  continue;
412  }
413 
414  // s t delta vector
415  double delta[Dim];
416 
417  // var for the squared distance of s and t
418  double dist_sq = 0.0;
419 
420  // compute delta and sum up dist_sq
421  for (int d = 0; d < Dim; d++) {
422  delta[d] = m_nodeInfo[t].position[d] - m_nodeInfo[s].position[d];
423  dist_sq += delta[d] * delta[d];
424  }
425 
426  // we take the log of the squared distance here
427 # if 0
428  double f = log(dist_sq) * 0.5;
429 # endif
430  double dist = (sqrt(dist_sq));
431  double f = (dist) * (dist) * m_edgeWeight[e];
432  double f_prime = 2.0 * dist * m_edgeWeight[e];
433  // for scaling the force accordingly
434 # if 0
435  double s_scale = 1.0/(double)s->degree();
436  double t_scale = 1.0/(double)t->degree();
437 # endif
438 
439  m_nodeInfo[s].force_prime += f_prime;
440  m_nodeInfo[t].force_prime += f_prime;
441 
442  // compute delta and sum up dist_sq
443  for (int d = 0; d < Dim; d++) {
444  m_nodeInfo[s].force[d] += f * delta[d] / dist;// * s_scale;
445  m_nodeInfo[t].force[d] -= f * delta[d] / dist;// * t_scale;
446  }
447  }
448 }
449 
450 template<int Dim>
451 void DTreeEmbedder<Dim>::computeEdgeForcesSq()
452 {
453  for (node s = m_graph.firstNode(); s; s = s->succ()) {
454  double sum_f[Dim];
455  double sum_df[Dim];
456 
457  double sum_ddf = 0.0;
458  // compute delta and sum up dist_sq
459  for (int d = 0; d < Dim; d++) {
460  sum_f[d] = 0.0;
461  sum_df[d] = 0.0;
462  }
463 
464  for (adjEntry adj = s->firstAdj(); adj; adj = adj->succ()) {
465  node t = adj->twinNode();
466 
467  // check if this is a self loop
468  if (s == t)
469  continue;
470 
471  // s t delta vector
472  double delta[Dim];
473 
474  // var for the squared distance of s and t
475  double dist_sq = 0.0;
476 
477  // compute delta and sum up dist_sq
478  for (int d = 0; d < Dim; d++) {
479  delta[d] = m_nodeInfo[t].position[d] - m_nodeInfo[s].position[d];
480  dist_sq += delta[d] * delta[d];
481  }
482 
483  double dist = sqrt(dist_sq);
484 
485  double f = 1.0;
486  double df = 1.0;
487  // compute delta and sum up dist_sq
488  for (int d = 0; d < Dim; d++) {
489  sum_f[d] += f * delta[d] / dist;
490 
491  }
492  sum_ddf += df;
493  }
494  for (int d = 0; d < Dim; d++) {
495  m_nodeInfo[s].force[d] = m_nodeInfo[s].force[d] + sum_f[d] / sum_ddf;
496  }
497  }
498 }
499 #endif
500 
501 template<int Dim>
503  // the maximum displacement
504  double maxDispl = 0.0;
505 
506  // loop over all nodes
507  for (node v = m_graph.firstNode(); v; v = v->succ()) {
508  double displ_sq = 0.0;
509  // update the position by the force vec
510  for (int d = 0; d < Dim; d++) {
511  double displ = m_nodeInfo[v].force[d] / m_nodeInfo[v].force_prime;
512  m_nodeInfo[v].position[d] += displ;
513  displ_sq += displ * displ;
514  }
515 
516  // we compare the square of the distance to save the sqrt here
517  if (maxDispl < displ_sq) {
518  maxDispl = displ_sq;
519  }
520  }
521  Logger::slout() << "sqrt(maxDispl)=" << sqrt(maxDispl) << std::endl;
522  return sqrt(maxDispl);
523 }
524 
525 template<int Dim>
526 double DTreeEmbedder<Dim>::moveNodes(double timeStep) {
527  // the maximum displacement
528  double maxDispl = 0.0;
529 
530  // loop over all nodes
531  for (node v = m_graph.firstNode(); v; v = v->succ()) {
532  double displ_sq = 0.0;
533  // update the position by the force vec
534  for (int d = 0; d < Dim; d++) {
535  double displ = m_nodeInfo[v].force[d] * timeStep;
536  m_nodeInfo[v].position[d] += displ;
537  displ_sq += displ * displ;
538  }
539 
540  // we compare the square of the distance to save the sqrt here
541  if (maxDispl < displ_sq) {
542  maxDispl = displ_sq;
543  }
544  }
545 
546  Logger::slout() << "sqrt(maxDispl)=" << sqrt(maxDispl) << std::endl;
547  return sqrt(maxDispl);
548 }
549 
550 template<int Dim>
552  // loop over all nodes
553  for (node v = m_graph.firstNode(); v; v = v->succ()) {
554  // reset the force vector
555  for (int d = 0; d < Dim; d++) {
556  m_nodeInfo[v].force[d] = 0.0;
557  }
558  m_nodeInfo[v].force_prime = 0.0;
559  }
560 }
561 
562 #if 0
563 template<int Dim>
564 template<typename RepForceFunc, bool>
565 double DTreeEmbedder<Dim>::doIteration(RepForceFunc repForceFunc)
566 {
567  // reset forces
568  resetForces();
569 
570  // the repulsive forces
571  computeRepForces(repForceFunc);
572 
573  // edge forces
574  computeEdgeForces();
575 
576  // move the nodes
577  return moveNodes(m_defaultTimeStep);
578 }
579 
580 template<int Dim>
581 template<typename RepForceFunc>
582 void DTreeEmbedder<Dim>::doIterations(int numIterations, double epsilon, RepForceFunc repForceFunc)
583 {
584  // init the error with epsilon
585  double maxDisplacement = epsilon;
586 
587  // while error too big and we have iterations left
588  for (int i = 0; i < numIterations && maxDisplacement >= epsilon; ++i) {
589  // run it
590  maxDisplacement = doIteration(repForceFunc);
591  }
592 }
593 
594 template<int Dim>
595 template<typename RepForceFunc>
596 void DTreeEmbedder<Dim>::doIterationsAdaptive(int numIterations, double epsilon, RepForceFunc repForceFunc)
597 {
598  int iterationsUsed = 0;
599  // the current timeStep
600 
601  double maxTimeStep = 1.0;
602  double timeStep = m_defaultTimeStep;
603 
604  int progress = 0;
605  // scaling factor for the adaptive timeStep
606  double t = 0.99;
607 
608  // init the error with epsilon
609  double maxDisplacement = 100000000.0;
610 
611  // value that keeps track of the displacement
612  double lastMaxDisplacement = 0.0;
613 
614  // while error too big and we have iterations left
615  for (int i = 0; i < numIterations && maxDisplacement >= epsilon; ++i) {
616  // reset forces
617  resetForces();
618 
619  // the repulsive forces
620  computeRepForces(repForceFunc);
621 
622  // edge forces
623  computeEdgeForces();
624 
625  // move the nodes
626  maxDisplacement = moveNodes(timeStep);
627 
628  // if this is not the first iteration
629  if (i > 0) {
630  if (maxDisplacement < lastMaxDisplacement * t) {
631  progress++;
632  timeStep = std::min(timeStep / t, maxTimeStep);
633  } else if (maxDisplacement > lastMaxDisplacement / t) {
634  timeStep = timeStep * t;
635  }
636  }
637  // save the maxDisplacement
638  lastMaxDisplacement = maxDisplacement;
639  iterationsUsed++;
640 # if 0
641  Logger::slout() << maxDisplacement << std::endl;
642 # endif
643  }
644  Logger::slout() << "IterationsUsed: " << iterationsUsed << " of " << numIterations << " energy: " << lastMaxDisplacement << std::endl;
645 }
646 
647 template<int Dim>
648 struct MyVec
649 {
650  double x[Dim];
651 };
652 #endif
653 
654 template<int Dim>
655 template<typename RepForceFunc, typename AttrForceFunc, bool UseForcePrime>
656 void DTreeEmbedder<Dim>::doIterationsTempl(int numIterations, double epsilon,
657  RepForceFunc repForceFunc, AttrForceFunc attrForceFunc) {
658  if (m_graph.numberOfNodes() < 2) {
659  return;
660  }
661 
662  int numIterationsUsed = 0;
663  Logger::slout()
664  << "doIterationsNewton: V = " << m_graph.numberOfNodes()
665  << " E = " << m_graph.numberOfEdges() << " Iterations " << numIterations << std::endl;
666 
667  // init the error with epsilon
668  double maxDisplacement = 10000.0;
669 
670  // while error too big and we have iterations left
671  for (int i = 0; i < numIterations && maxDisplacement > epsilon; ++i) {
672  numIterationsUsed++;
673  // reset forces
674  resetForces();
675 
676  // the repulsive forces
677  computeRepForces<RepForceFunc, UseForcePrime>(repForceFunc);
678 
679  // edge forces
680  computeEdgeForces<AttrForceFunc, UseForcePrime>(attrForceFunc);
681 
682  // move the nodes
683  if (UseForcePrime) {
684  maxDisplacement = moveNodesByForcePrime();
685  } else {
686  maxDisplacement = moveNodes(0.1);
687  }
688  }
689 
690  Logger::slout() << "Needed " << numIterationsUsed << " of " << numIterations << std::endl;
691 }
692 
693 template<int Dim>
694 template<typename RepForceFunc, typename AttrForceFunc>
695 void DTreeEmbedder<Dim>::doIterationsStandard(int numIterations, double epsilon,
696  RepForceFunc repForceFunc, AttrForceFunc attrForceFunc) {
697  doIterationsTempl<RepForceFunc, AttrForceFunc, false>(numIterations, epsilon, repForceFunc,
698  attrForceFunc);
699 }
700 
701 template<int Dim>
702 template<typename RepForceFunc, typename AttrForceFunc>
703 void DTreeEmbedder<Dim>::doIterationsNewton(int numIterations, double epsilon,
704  RepForceFunc repForceFunc, AttrForceFunc attrForceFunc) {
705  doIterationsTempl<RepForceFunc, AttrForceFunc, true>(numIterations, epsilon, repForceFunc,
706  attrForceFunc);
707 }
708 
709 template<int Dim>
710 void DTreeEmbedder<Dim>::centerNodesAt(double centerBBox[Dim]) {
711  double bboxMin[Dim];
712  double bboxMax[Dim];
713 
714  // initial values
715  for (int d = 0; d < Dim; d++) {
716  bboxMin[d] = bboxMax[d] = position(m_graph.firstEdge(), d);
717  }
718 
719  // no magic here
720  for (node v = m_graph.firstNode(); v; v = v->succ()) {
721  for (int d = 0; d < Dim; d++) {
722  bboxMin[d] = std::min(bboxMin[d], position(v, d));
723  bboxMax[d] = std::max(bboxMax[d], position(v, d));
724  }
725  }
726 
727  double delta[Dim];
728  for (int d = 0; d < Dim; d++) {
729  delta[d] = -(bboxMin[d] + bboxMax[d]) * 0.5;
730  }
731 
732  for (node v = m_graph.firstNode(); v; v = v->succ()) {
733  for (int d = 0; d < Dim; d++) {
734  setPosition(v, d, delta[d]);
735  }
736  }
737 }
738 
739 template<int Dim>
740 void DTreeEmbedder<Dim>::scaleNodes(double scaleFactor) {
741  for (node v = m_graph.firstNode(); v; v = v->succ()) {
742  for (int d = 0; d < Dim; d++) {
743  setPosition(v, d, position(v, d) * scaleFactor);
744  }
745  }
746 }
747 
748 template<int Dim>
749 double DTreeEmbedder<Dim>::position(node v, int d) const {
750  return m_nodeInfo[v].position[d];
751 }
752 
753 template<int Dim>
754 void DTreeEmbedder<Dim>::setPosition(node v, int d, double coord) {
755  m_nodeInfo[v].position[d] = coord;
756 }
757 
758 template<int Dim>
760  return m_nodeInfo[v].mass;
761 }
762 
763 template<int Dim>
764 void DTreeEmbedder<Dim>::setMass(node v, double mass) {
765  m_nodeInfo[v].mass = mass;
766 }
767 
768 template<int Dim>
770  return m_graph;
771 }
772 
773 template<int Dim>
774 void DTreeEmbedder<Dim>::setEdgeWeight(edge e, double weight) {
775  m_edgeWeight[e] = weight;
776 }
777 
778 template<int Dim>
780  return m_edgeWeight[e];
781 }
782 
783 }
784 }
785 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::energybased::dtree::DTreeEmbedder::NodeInfo::force
double force[Dim]
the forces on a node
Definition: DTreeEmbedder.h:144
ogdf::energybased::dtree::DTreeEmbedder::m_maxNumNodesExactRepForces
int m_maxNumNodesExactRepForces
Definition: DTreeEmbedder.h:165
ogdf::energybased::dtree::DTreeEmbedder::setEdgeWeight
void setEdgeWeight(edge e, double weight)
sets the weight of an edge
Definition: DTreeEmbedder.h:774
ogdf::energybased::dtree::DTreeEmbedder::scaleNodes
void scaleNodes(double scaleFactor)
changes the position of nodes according to a given scale factor
Definition: DTreeEmbedder.h:740
ogdf::energybased::dtree::DTreeEmbedder::NodeInfo::force_prime
double force_prime
sum of the derivs
Definition: DTreeEmbedder.h:147
ogdf::energybased::dtree::DTreeEmbedder
Definition: DTreeEmbedder.h:39
ogdf::energybased::dtree::DTreeEmbedder::computeRepForcesExact
void computeRepForcesExact(ForceFunc forceFunc)
computes the repulsive forces for one iteration in O(n^2)
Definition: DTreeEmbedder.h:193
ogdf::energybased::dtree::DTreeEmbedder::doIterationsTempl
void doIterationsTempl(int numIterations, double epsilon, RepForceFunc repForceFunc, AttrForceFunc attrForceFunc)
does multiple iterations using the given repulsive force function
Definition: DTreeEmbedder.h:656
ogdf::energybased::dtree::DTreeEmbedder::NodeInfo
node state
Definition: DTreeEmbedder.h:139
ogdf::energybased::dtree::DTreeEmbedder::computeRepForces
void computeRepForces(ForceFunc forceFunc)
computes the repulsive forces
Definition: DTreeEmbedder.h:323
ogdf::energybased::dtree::DTreeEmbedder::DTreeEmbedder
DTreeEmbedder(const Graph &graph)
constructor with a given graph, allocates memory and does initialization
Definition: DTreeEmbedder.h:174
ogdf::energybased::dtree::DTreeEmbedder::edgeWeight
double edgeWeight(edge e) const
returns the edge weight
Definition: DTreeEmbedder.h:779
ogdf::energybased::dtree::DTreeEmbedder::resetForces
void resetForces()
sets the forces of all nodes to 0
Definition: DTreeEmbedder.h:551
ogdf::adjEntry
AdjElement * adjEntry
The type of adjacency entries.
Definition: Graph_d.h:71
ogdf::energybased::dtree::DTreeForce
Definition: DTreeForce.h:42
ogdf::energybased::dtree::DTreeEmbedder::computeRepForcesApprox
void computeRepForcesApprox(ForceFunc forceFunc)
uses the tree code to approximate the repulsive forces in O(nlogn) for one iteration
Definition: DTreeEmbedder.h:250
ogdf::energybased::dtree::DTreeEmbedder::position
double position(node v, int d) const
returns the d-th coordinate of node v
Definition: DTreeEmbedder.h:749
ogdf::energybased::dtree::DTreeEmbedder::m_nodeInfo
NodeArray< NodeInfo > m_nodeInfo
node states of all nodes
Definition: DTreeEmbedder.h:157
ogdf::energybased::dtree::DTreeEmbedder::computeEdgeForces
void computeEdgeForces(AttrForceFunc attrForceFunc)
computes the edge forces for one iteration
Definition: DTreeEmbedder.h:346
ogdf::energybased::dtree::DTreeEmbedder::m_graph
const Graph & m_graph
the graph
Definition: DTreeEmbedder.h:154
ogdf::energybased::dtree::DTreeEmbedder::m_edgeWeight
EdgeArray< double > m_edgeWeight
the weight of the edges
Definition: DTreeEmbedder.h:160
ogdf::energybased::dtree::DTreeEmbedder::moveNodes
double moveNodes(double timeStep)
moves the nodes by the computed force vector
Definition: DTreeEmbedder.h:526
ogdf::NodeElement::degree
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:276
ogdf::Graph::numberOfNodes
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:974
ogdf::energybased::dtree::DTreeEmbedder::graph
const Graph & graph() const
returns the graph
Definition: DTreeEmbedder.h:769
ogdf::energybased::dtree::DTreeEmbedder::m_pTreeForce
DTreeForce< Dim > * m_pTreeForce
the tree force approx
Definition: DTreeEmbedder.h:163
ogdf::energybased::dtree::DTreeEmbedder::doIterationsStandard
void doIterationsStandard(int numIterations, double epsilon, RepForceFunc repForceFunc, AttrForceFunc attrForceFunc)
Definition: DTreeEmbedder.h:695
ogdf::AdjElement::succ
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:211
ogdf::energybased::dtree::DTreeEmbedder::m_defaultTimeStep
double m_defaultTimeStep
Definition: DTreeEmbedder.h:167
ogdf::MeasureEnum::log
@ log
ogdf::Graph::firstNode
node firstNode() const
Returns the first node in the list of all nodes.
Definition: Graph_d.h:989
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::energybased::dtree::DTreeEmbedder::setPosition
void setPosition(node v, int d, double coord)
sets the d-th coordinate of node v to coord
Definition: DTreeEmbedder.h:754
ogdf::energybased::dtree::DTreeEmbedder::~DTreeEmbedder
virtual ~DTreeEmbedder()
destructor
Definition: DTreeEmbedder.h:187
ogdf::energybased::dtree::DTreeEmbedder::setMass
void setMass(node v, double mass)
sets the mass of a node v
Definition: DTreeEmbedder.h:764
DTreeForce.h
ogdf::energybased::dtree::DTreeEmbedder::doIterationsNewton
void doIterationsNewton(int numIterations, double epsilon, RepForceFunc repForceFunc, AttrForceFunc attrForceFunc)
Definition: DTreeEmbedder.h:703
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:279
ogdf::NodeElement::succ
node succ() const
Returns the successor in the list of all nodes.
Definition: Graph_d.h:285
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
GalaxyLevel.h
ogdf::EdgeElement::succ
edge succ() const
Returns the successor in the list of all edges.
Definition: Graph_d.h:426
ogdf::energybased::dtree::DTreeEmbedder::moveNodesByForcePrime
double moveNodesByForcePrime()
Definition: DTreeEmbedder.h:502
ogdf::energybased::dtree::DTreeEmbedder::centerNodesAt
void centerNodesAt(double centerBBox[Dim])
computes the bounding box and all nodes are translated such that bbox center is at centerBBox
Definition: DTreeEmbedder.h:710
ogdf::energybased::dtree::DTreeEmbedder::mass
double mass(node v) const
returns the mass of node v
Definition: DTreeEmbedder.h:759
ogdf::energybased::dtree::DTreeEmbedder::NodeInfo::position
double position[Dim]
position of a node
Definition: DTreeEmbedder.h:141
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::energybased::dtree::DTreeEmbedder::NodeInfo::mass
double mass
the mass of this node
Definition: DTreeEmbedder.h:150
ogdf::Logger::slout
static std::ostream & slout(Level level=Level::Default)
stream for logging-output (global)
Definition: Logger.h:191
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709