Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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