Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

EmbedderMaxFaceBiconnectedGraphsLayers.h
Go to the documentation of this file.
1 
33 #pragma once
34 
36 
37 namespace ogdf {
38 
40 
52 template<class T>
54 {
55 public:
57  static void embed(
58  Graph& G,
59  adjEntry& adjExternal,
60  const NodeArray<T>& nodeLength,
61  const EdgeArray<T>& edgeLength,
62  const node& n = nullptr);
63 
66 
67 private:
70 
71  /* \brief Computes recursively the thickness of the skeleton graph of all
72  * nodes in the SPQR-tree.
73  *
74  * \param spqrTree The SPQR-tree of the treated graph.
75  * \param mu a node in the SPQR-tree.
76  * \param thickness saving the computed results - the thickness of each
77  * skeleton graph.
78  * \param nodeLength is saving for each node of the original graph \p G its
79  * length.
80  * \param edgeLength is saving the edge lengths of all edges in each skeleton
81  * graph of all tree nodes.
82  */
83  static void bottomUpThickness(
84  const StaticSPQRTree& spqrTree,
85  const node& mu,
86  NodeArray<T>& thickness,
87  const NodeArray<T>& nodeLength,
88  const NodeArray< EdgeArray<T> >& edgeLength);
89 
90  /* \brief ExpandEdge embeds all edges in the skeleton graph \a S into an
91  * existing embedding and calls recursively itself for all virtual edges
92  * in S.
93  *
94  * \param spqrTree The SPQR-tree of the treated graph.
95  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
96  * whether it was already treated by any call of ExpandEdge or not. Every
97  * \p mu should only be treated once.
98  * \param mu is a node in the SPQR-tree.
99  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
100  * in the embedding
101  * \param nodeLength is an array saving the lengths of the nodes of \p G.
102  * \param edgeLength is saving the edge lengths of all edges in each skeleton
103  * graph of all tree nodes.
104  * \param thickness of each skeleton graph.
105  * \param newOrder is saving for each node \p n in \p G the new adjacency
106  * list. This is an output parameter.
107  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
108  * of the skeleton of mu the adjacency entry, before which new entries have
109  * to be inserted.
110  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
111  * of the skeleton of mu the adjacency entry, before which new entries have
112  * to be inserted.
113  * \param delta_u the distance from the second adjacent face of the reference edge
114  * except the external face to the external face of G.
115  * \param delta_d the distance from the external face to the external face of G.
116  * \param adjExternal is an adjacency entry in the external face.
117  * \param n is only set, if ExpandEdge is called for the first time, because
118  * then there is no virtual edge which has to be expanded, but the max face
119  * has to contain a certain node \p n.
120  */
121  static void expandEdge(
122  const StaticSPQRTree& spqrTree,
123  NodeArray<bool>& treeNodeTreated,
124  const node& mu,
125  const node& leftNode,
126  const NodeArray<T>& nodeLength,
127  const NodeArray< EdgeArray<T> >& edgeLength,
128  const NodeArray<T>& thickness,
129  NodeArray< List<adjEntry> >& newOrder,
130  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
131  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
132  const T& delta_u,
133  const T& delta_d,
134  adjEntry& adjExternal,
135  const node& n = nullptr);
136 
137  /* \brief Embeds all edges in the skeleton graph \a S of an S-node of the
138  * SPQR-tree into an existing embedding and calls recursively itself for
139  * all virtual edges in S.
140  *
141  * \param spqrTree The SPQR-tree of the treated graph.
142  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
143  * whether it was already treated by any call of ExpandEdge or not. Every
144  * \p mu should only be treated once.
145  * \param mu is a node in the SPQR-tree.
146  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
147  * in the embedding
148  * \param nodeLength is an array saving the lengths of the nodes of \p G.
149  * \param edgeLength is saving the edge lengths of all edges in each skeleton
150  * graph of all tree nodes.
151  * \param thickness of each skeleton graph.
152  * \param newOrder is saving for each node \p n in \p G the new adjacency
153  * list. This is an output parameter.
154  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
155  * of the skeleton of mu the adjacency entry, before which new entries have
156  * to be inserted.
157  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
158  * of the skeleton of mu the adjacency entry, before which new entries have
159  * to be inserted.
160  * \param delta_u the distance from the second adjacent face of the reference edge
161  * except the external face to the external face of G.
162  * \param delta_d the distance from the external face to the external face of G.
163  * \param adjExternal is an adjacency entry in the external face.
164  */
165  static void expandEdgeSNode(
166  const StaticSPQRTree& spqrTree,
167  NodeArray<bool>& treeNodeTreated,
168  const node& mu,
169  const node& leftNode,
170  const NodeArray<T>& nodeLength,
171  const NodeArray< EdgeArray<T> >& edgeLength,
172  const NodeArray<T>& thickness,
173  NodeArray< List<adjEntry> >& newOrder,
174  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
175  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
176  const T& delta_u,
177  const T& delta_d,
178  adjEntry& adjExternal);
179 
180  /* \brief Embeds all edges in the skeleton graph \a S of an P-node of the
181  * SPQR-tree into an existing embedding and calls recursively itself for
182  * all virtual edges in S.
183  *
184  * \param spqrTree The SPQR-tree of the treated graph.
185  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
186  * whether it was already treated by any call of ExpandEdge or not. Every
187  * \p mu should only be treated once.
188  * \param mu is a node in the SPQR-tree.
189  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
190  * in the embedding
191  * \param nodeLength is an array saving the lengths of the nodes of \p G.
192  * \param edgeLength is saving the edge lengths of all edges in each skeleton
193  * graph of all tree nodes.
194  * \param thickness of each skeleton graph.
195  * \param newOrder is saving for each node \p n in \p G the new adjacency
196  * list. This is an output parameter.
197  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
198  * of the skeleton of mu the adjacency entry, before which new entries have
199  * to be inserted.
200  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
201  * of the skeleton of mu the adjacency entry, before which new entries have
202  * to be inserted.
203  * \param delta_u the distance from the second adjacent face of the reference edge
204  * except the external face to the external face of G.
205  * \param delta_d the distance from the external face to the external face of G.
206  * \param adjExternal is an adjacency entry in the external face.
207  */
208  static void expandEdgePNode(
209  const StaticSPQRTree& spqrTree,
210  NodeArray<bool>& treeNodeTreated,
211  const node& mu,
212  const node& leftNode,
213  const NodeArray<T>& nodeLength,
214  const NodeArray< EdgeArray<T> >& edgeLength,
215  const NodeArray<T>& thickness,
216  NodeArray< List<adjEntry> >& newOrder,
217  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
218  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
219  const T& delta_u,
220  const T& delta_d,
221  adjEntry& adjExternal);
222 
223  /* \brief Embeds all edges in the skeleton graph \a S of an R-node of the
224  * SPQR-tree into an existing embedding and calls recursively itself for
225  * all virtual edges in S.
226  *
227  * \param spqrTree The SPQR-tree of the treated graph.
228  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
229  * whether it was already treated by any call of ExpandEdge or not. Every
230  * \p mu should only be treated once.
231  * \param mu is a node in the SPQR-tree.
232  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
233  * in the embedding
234  * \param nodeLength is an array saving the lengths of the nodes of \p G.
235  * \param edgeLength is saving the edge lengths of all edges in each skeleton
236  * graph of all tree nodes.
237  * \param thickness of each skeleton graph.
238  * \param newOrder is saving for each node \p n in \p G the new adjacency
239  * list. This is an output parameter.
240  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
241  * of the skeleton of mu the adjacency entry, before which new entries have
242  * to be inserted.
243  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
244  * of the skeleton of mu the adjacency entry, before which new entries have
245  * to be inserted.
246  * \param delta_u the distance from the second adjacent face of the reference edge
247  * except the external face to the external face of G.
248  * \param delta_d the distance from the external face to the external face of G.
249  * \param adjExternal is an adjacency entry in the external face.
250  * \param n is only set, if ExpandEdge is called for the first time, because
251  * then there is no virtual edge which has to be expanded, but the max face
252  * has to contain a certain node \p n.
253  */
254  static void expandEdgeRNode(
255  const StaticSPQRTree& spqrTree,
256  NodeArray<bool>& treeNodeTreated,
257  const node& mu,
258  const node& leftNode,
259  const NodeArray<T>& nodeLength,
260  const NodeArray< EdgeArray<T> >& edgeLength,
261  const NodeArray<T>& thickness,
262  NodeArray< List<adjEntry> >& newOrder,
263  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
264  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
265  const T& delta_u,
266  const T& delta_d,
267  adjEntry& adjExternal,
268  const node& n = nullptr);
269 
270  /* \brief Writes a given adjacency entry into the newOrder. If the edge
271  * belonging to ae is a virtual edge, it is expanded.
272  *
273  * \param ae is the adjacency entry which has to be expanded.
274  * \param before is the adjacency entry of the node in \p G, before
275  * which ae has to be inserted.
276  * \param spqrTree The SPQR-tree of the treated graph.
277  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
278  * whether it was already treated by any call of ExpandEdge or not. Every
279  * \p mu should only be treated once.
280  * \param mu is a node in the SPQR-tree.
281  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
282  * in the embedding
283  * \param nodeLength is an array saving the lengths of the nodes of \p G.
284  * \param edgeLength is saving the edge lengths of all edges in each skeleton
285  * graph of all tree nodes.
286  * \param thickness of each skeleton graph.
287  * \param newOrder is saving for each node \p n in \p G the new adjacency
288  * list. This is an output parameter.
289  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
290  * of the skeleton of mu the adjacency entry, before which new entries have
291  * to be inserted.
292  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
293  * of the skeleton of mu the adjacency entry, before which new entries have
294  * to be inserted.
295  * \param delta_u the distance from the second adjacent face of the reference edge
296  * except the external face to the external face of G.
297  * \param delta_d the distance from the external face to the external face of G.
298  * \param adjExternal is an adjacency entry in the external face.
299  */
300  static void adjEntryForNode(
301  adjEntry& ae,
303  const StaticSPQRTree& spqrTree,
304  NodeArray<bool>& treeNodeTreated,
305  const node& mu,
306  const node& leftNode,
307  const NodeArray<T>& nodeLength,
308  const NodeArray< EdgeArray<T> >& edgeLength,
309  const NodeArray<T>& thickness,
310  NodeArray< List<adjEntry> >& newOrder,
311  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
312  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
313  const T& delta_u,
314  const T& delta_d,
315  adjEntry& adjExternal);
316 
317  /* \brief Single source shortest path.
318  *
319  * \param G directed graph
320  * \param s source node
321  * \param length length of an edge
322  * \param d contains shortest path distances after call
323  */
324  static bool sssp(
325  const Graph& G,
326  const node& s,
327  const EdgeArray<T>& length,
328  NodeArray<T>& d);
329 };
330 
331 
332 template<class T>
334  Graph& G,
335  adjEntry& adjExternal,
336  const NodeArray<T>& nodeLength,
337  const EdgeArray<T>& edgeLength,
338  const node& n /* = 0*/)
339 {
340  //Base cases (SPQR-Tree-implementatioin would crash with these inputs):
341  OGDF_ASSERT(G.numberOfNodes() >= 2);
342  if (G.numberOfEdges() <= 2)
343  {
344  edge e = G.firstEdge();
345  adjExternal = e->adjSource();
346  return;
347  }
348 
349  //First step: calculate maximum face and edge lengths for virtual edges
350  StaticSPQRTree spqrTree(G);
351  NodeArray< EdgeArray<T> > edgeLengthSkel;
352  compute(G, nodeLength, edgeLength, &spqrTree, edgeLengthSkel);
353 
354  //Second step: Embed G
355  T biggestFace = -1;
356  node bigFaceMu;
357  if (n == nullptr)
358  {
359  for(node mu : spqrTree.tree().nodes)
360  {
361  //Expand all faces in skeleton(mu) and get size of the largest of them:
362  T sizeMu = largestFaceInSkeleton(spqrTree, mu, nodeLength, edgeLengthSkel);
363  if (sizeMu > biggestFace)
364  {
365  biggestFace = sizeMu;
366  bigFaceMu = mu;
367  }
368  }
369  }
370  else
371  {
372  node* mus = new node[n->degree()];
373  int i = 0;
374  for(adjEntry adj : n->adjEntries) {
375  mus[i] = spqrTree.skeletonOfReal(adj->theEdge()).treeNode();
376  bool alreadySeenMu = false;
377  for (int j = 0; j < i && !alreadySeenMu; j++)
378  {
379  if (mus[i] == mus[j])
380  alreadySeenMu = true;
381  }
382  if (alreadySeenMu)
383  {
384  i++;
385  continue;
386  }
387  else
388  {
389  //Expand all faces in skeleton(mu) containing n and get size of
390  //the largest of them:
391  T sizeInMu = largestFaceContainingNode(spqrTree, mus[i], n, nodeLength, edgeLengthSkel);
392  if (sizeInMu > biggestFace)
393  {
394  biggestFace = sizeInMu;
395  bigFaceMu = mus[i];
396  }
397 
398  i++;
399  }
400  }
401  delete[] mus;
402  }
403 
404  bigFaceMu = spqrTree.rootTreeAt(bigFaceMu);
405 
406  NodeArray<T> thickness(spqrTree.tree());
407  bottomUpThickness(spqrTree, bigFaceMu, thickness, nodeLength, edgeLengthSkel);
408 
409  NodeArray< List<adjEntry> > newOrder(G);
410  NodeArray<bool> treeNodeTreated(spqrTree.tree(), false);
412  adjExternal = nullptr;
413  NodeArray< ListIterator<adjEntry> > adjBeforeNodeArraySource(spqrTree.tree());
414  NodeArray< ListIterator<adjEntry> > adjBeforeNodeArrayTarget(spqrTree.tree());
415  expandEdge(spqrTree, treeNodeTreated, bigFaceMu, nullptr, nodeLength,
416  edgeLengthSkel, thickness, newOrder, adjBeforeNodeArraySource,
417  adjBeforeNodeArrayTarget, 0, 0, adjExternal, n);
418 
419  for(node v : G.nodes)
420  G.sort(v, newOrder[v]);
421 }
422 
423 
424 template<class T>
426  adjEntry& ae,
428  const StaticSPQRTree& spqrTree,
429  NodeArray<bool>& treeNodeTreated,
430  const node& mu,
431  const node& leftNode,
432  const NodeArray<T>& nodeLength,
433  const NodeArray< EdgeArray<T> >& edgeLength,
434  const NodeArray<T>& thickness,
435  NodeArray< List<adjEntry> >& newOrder,
436  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
437  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
438  const T& delta_u,
439  const T& delta_d,
440  adjEntry& adjExternal)
441 {
442  Skeleton& S = spqrTree.skeleton(mu);
443  edge referenceEdge = S.referenceEdge();
444  if (S.isVirtual(ae->theEdge()))
445  {
446  edge twinE = S.twinEdge(ae->theEdge());
447  node twinNT = S.twinTreeNode(ae->theEdge());
448 #if 0
449  Skeleton& twinS = spqrTree.skeleton(twinNT);
450 #endif
451 
452  if (!treeNodeTreated[twinNT])
453  {
454  node m_leftNode;
455  if (ae->theEdge()->source() == leftNode)
456  m_leftNode = twinE->source();
457  else
458  m_leftNode = twinE->target();
459 
460  if (ae->theEdge()->source() == ae->theNode())
461  adjBeforeNodeArraySource[twinNT] = before;
462  else
463  adjBeforeNodeArrayTarget[twinNT] = before;
464 
465  //recursion call:
466  expandEdge(spqrTree, treeNodeTreated, twinNT, m_leftNode,
467  nodeLength, edgeLength, thickness, newOrder,
468  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
469  delta_u, delta_d, adjExternal);
470  }
471 
472  if (ae->theEdge() == referenceEdge)
473  {
474  if (ae->theNode() == ae->theEdge()->source())
475  {
476  ListIterator<adjEntry> tmpBefore = adjBeforeNodeArraySource[mu];
477  adjBeforeNodeArraySource[mu] = before;
478  before = tmpBefore;
479  }
480  else
481  {
482  ListIterator<adjEntry> tmpBefore = adjBeforeNodeArrayTarget[mu];
483  adjBeforeNodeArrayTarget[mu] = before;
484  before = tmpBefore;
485  }
486  }
487  else
488  {
489  if (ae->theNode() == ae->theEdge()->source())
490  before = adjBeforeNodeArraySource[twinNT];
491  else
492  before = adjBeforeNodeArrayTarget[twinNT];
493  }
494  }
495  else
496  {
497  node origNode = S.original(ae->theNode());
498  edge origEdge = S.realEdge(ae->theEdge());
499 
500  if (origNode == origEdge->source())
501  {
502  if (!before.valid())
503  before = newOrder[origNode].pushBack(origEdge->adjSource());
504  else
505  before = newOrder[origNode].insertBefore(origEdge->adjSource(), before);
506  }
507  else
508  {
509  if (!before.valid())
510  before = newOrder[origNode].pushBack(origEdge->adjTarget());
511  else
512  before = newOrder[origNode].insertBefore(origEdge->adjTarget(), before);
513  }
514  }
515 }
516 
517 
518 template<class T>
520  const StaticSPQRTree& spqrTree,
521  NodeArray<bool>& treeNodeTreated,
522  const node& mu,
523  const node& leftNode,
524  const NodeArray<T>& nodeLength,
525  const NodeArray< EdgeArray<T> >& edgeLength,
526  const NodeArray<T>& thickness,
527  NodeArray< List<adjEntry> >& newOrder,
528  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
529  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
530  const T& delta_u,
531  const T& delta_d,
532  adjEntry& adjExternal,
533  const node& n /*= 0*/)
534 {
535  treeNodeTreated[mu] = true;
536 
537  switch(spqrTree.typeOf(mu))
538  {
540  expandEdgeSNode(spqrTree, treeNodeTreated, mu, leftNode,
541  nodeLength, edgeLength, thickness, newOrder, adjBeforeNodeArraySource,
542  adjBeforeNodeArrayTarget, delta_u, delta_d, adjExternal);
543  break;
545  expandEdgePNode(spqrTree, treeNodeTreated, mu, leftNode,
546  nodeLength, edgeLength, thickness, newOrder, adjBeforeNodeArraySource,
547  adjBeforeNodeArrayTarget, delta_u, delta_d, adjExternal);
548  break;
550  expandEdgeRNode(spqrTree, treeNodeTreated, mu, leftNode,
551  nodeLength, edgeLength, thickness, newOrder, adjBeforeNodeArraySource,
552  adjBeforeNodeArrayTarget, delta_u, delta_d, adjExternal, n);
553  break;
554  default:
555  OGDF_ASSERT(false);
556  }
557 }
558 
559 
560 template<class T>
562  const StaticSPQRTree& spqrTree,
563  NodeArray<bool>& treeNodeTreated,
564  const node& mu,
565  const node& leftNode,
566  const NodeArray<T>& nodeLength,
567  const NodeArray< EdgeArray<T> >& edgeLength,
568  const NodeArray<T>& thickness,
569  NodeArray< List<adjEntry> >& newOrder,
570  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
571  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
572  const T& delta_u,
573  const T& delta_d,
574  adjEntry& adjExternal)
575 {
576  Skeleton& S = spqrTree.skeleton(mu);
577  edge referenceEdge = S.referenceEdge();
578  adjEntry startAdjEntry = nullptr;
579  if (leftNode == nullptr)
580  {
581  for(edge e : S.getGraph().edges)
582  {
583  if (!S.isVirtual(e))
584  {
585  startAdjEntry = e->adjSource();
586  break;
587  }
588  }
589  OGDF_ASSERT(startAdjEntry != nullptr);
590  }
591  else if (leftNode->firstAdj()->theEdge() == referenceEdge)
592  startAdjEntry = leftNode->lastAdj();
593  else
594  startAdjEntry = leftNode->firstAdj();
595 
596  adjEntry ae = startAdjEntry;
597  if (adjExternal == nullptr)
598  {
599  edge orgEdge = S.realEdge(ae->theEdge());
600  if (orgEdge->source() == S.original(ae->theNode()))
601  adjExternal = orgEdge->adjSource()->twin();
602  else
603  adjExternal = orgEdge->adjTarget()->twin();
604  }
605 
607  if (referenceEdge && leftNode == referenceEdge->source())
608  before = adjBeforeNodeArraySource[mu];
609  else if (referenceEdge)
610  before = adjBeforeNodeArrayTarget[mu];
611  ListIterator<adjEntry> beforeSource;
612 
613  bool firstStep = true;
614  while (firstStep || ae != startAdjEntry)
615  {
616  //first treat ae with ae->theNode() is left node, then treat its twin:
617  node m_leftNode = ae->theNode();
618 
619  if (ae->theEdge() == referenceEdge)
620  {
621  if (ae->theNode() == referenceEdge->source())
622  adjBeforeNodeArraySource[mu] = before;
623  else
624  adjBeforeNodeArrayTarget[mu] = before;
625  }
626  else
627  {
628  if (S.isVirtual(ae->theEdge()) && referenceEdge)
629  {
630  node twinTN = S.twinTreeNode(ae->theEdge());
631  if (ae->theEdge()->source() == ae->theNode())
632  {
633  if (ae->theEdge()->target() == referenceEdge->source())
634  adjBeforeNodeArrayTarget[twinTN] = adjBeforeNodeArraySource[mu];
635  else if (ae->theEdge()->target() == referenceEdge->target())
636  adjBeforeNodeArrayTarget[twinTN] = adjBeforeNodeArrayTarget[mu];
637  }
638  else
639  {
640  if (ae->theEdge()->source() == referenceEdge->source())
641  adjBeforeNodeArraySource[twinTN] = adjBeforeNodeArraySource[mu];
642  else if (ae->theEdge()->source() == referenceEdge->target())
643  adjBeforeNodeArraySource[twinTN] = adjBeforeNodeArrayTarget[mu];
644  }
645  }
646 
647  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
648  m_leftNode, nodeLength, edgeLength, thickness, newOrder,
649  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
650  delta_u, delta_d, adjExternal);
651  }
652 
653  if (firstStep) {
654  beforeSource = before;
655  firstStep = false;
656  }
657 
658  ae = ae->twin();
659  if (!referenceEdge)
660  before = nullptr;
661  else if (ae->theNode() == referenceEdge->source())
662  before = adjBeforeNodeArraySource[mu];
663  else if (ae->theNode() == referenceEdge->target())
664  before = adjBeforeNodeArrayTarget[mu];
665  else
666  before = nullptr;
667  if (ae->theEdge() == referenceEdge)
668  {
669  if (ae->theNode() == referenceEdge->source())
670  adjBeforeNodeArraySource[mu] = beforeSource;
671  else
672  adjBeforeNodeArrayTarget[mu] = beforeSource;
673  }
674  else
675  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
676  m_leftNode, nodeLength, edgeLength, thickness, newOrder,
677  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
678  delta_u, delta_d, adjExternal);
679 
680  //set new adjacency entry pair (ae and its twin):
681  if (ae->theNode()->firstAdj() == ae)
682  ae = ae->theNode()->lastAdj();
683  else
684  ae = ae->theNode()->firstAdj();
685  }
686 }
687 
688 
689 template<class T>
691  const StaticSPQRTree& spqrTree,
692  NodeArray<bool>& treeNodeTreated,
693  const node& mu,
694  const node& leftNode,
695  const NodeArray<T>& nodeLength,
696  const NodeArray< EdgeArray<T> >& edgeLength,
697  const NodeArray<T>& thickness,
698  NodeArray< List<adjEntry> >& newOrder,
699  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
700  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
701  const T& delta_u,
702  const T& delta_d,
703  adjEntry& adjExternal)
704 {
705  //Choose face defined by virtual edge and the longest edge different from it.
706  Skeleton& S = spqrTree.skeleton(mu);
707  edge referenceEdge = S.referenceEdge();
708  edge altReferenceEdge = nullptr;
709 
710  node m_leftNode = leftNode;
711  if (!m_leftNode) {
712  List<node> nodeList;
713  S.getGraph().allNodes(nodeList);
714  m_leftNode = *(nodeList.begin());
715  }
716  node m_rightNode = m_leftNode->firstAdj()->twinNode();
717 
718  if (referenceEdge == nullptr)
719  {
720  for(edge e : S.getGraph().edges)
721  {
722  if (!S.isVirtual(e))
723  {
724  altReferenceEdge = e;
725  edge orgEdge = S.realEdge(e);
726  if (orgEdge->source() == S.original(m_leftNode))
727  adjExternal = orgEdge->adjSource();
728  else
729  adjExternal = orgEdge->adjTarget();
730  break;
731  }
732  }
733  }
734 
735  //sort edges by length:
736  List<edge> graphEdges;
737  for(edge e : S.getGraph().edges)
738  {
739  if (e == referenceEdge || e == altReferenceEdge)
740  continue;
741 
742  if (!graphEdges.begin().valid())
743  graphEdges.pushBack(e);
744  else
745  {
746  for (ListIterator<edge> it = graphEdges.begin(); it.valid(); ++it)
747  {
748  if (edgeLength[mu][e] > edgeLength[mu][*it])
749  {
750  graphEdges.insertBefore(e, it);
751  break;
752  }
753  ListIterator<edge> next = it;
754  ++next;
755  if (!next.valid())
756  {
757  graphEdges.pushBack(e);
758  break;
759  }
760  }
761  }
762  }
763 
764  List<edge> rightEdgeOrder;
765  ListIterator<adjEntry> beforeAltRefEdge;
766  ListIterator<adjEntry> beforeLeft;
767 
768  //begin with left node and longest edge:
769  for (int i = 0; i < 2; ++i) {
771  node n;
772  if (i == 0)
773  n = m_leftNode;
774  else {
775  n = m_rightNode;
776  before = beforeAltRefEdge;
777  }
778 
779  if (referenceEdge) {
780  if (n == referenceEdge->source())
781  before = adjBeforeNodeArraySource[mu];
782  else
783  before = adjBeforeNodeArrayTarget[mu];
784  }
785 
786  adjEntry ae;
787 
788  //all edges except reference edge:
789  if (i == 0) {
790  ListIterator<edge> lastPos;
791  ListIterator<adjEntry> beforeRight;
792  if (referenceEdge) {
793  if (referenceEdge->source() == m_rightNode)
794  beforeRight = adjBeforeNodeArraySource[mu];
795  else //referenceEdge->target() == rightnode
796  beforeRight = adjBeforeNodeArrayTarget[mu];
797  }
798  bool insertBeforeLast = false;
799  bool oneEdgeInE_a = false;
800  T sum_E_a = 0;
801  T sum_E_b = 0;
802 
803  for (int looper = 0; looper < graphEdges.size(); looper++)
804  {
805  edge e = *(graphEdges.get(looper));
806 
807  if (!lastPos.valid())
808  lastPos = rightEdgeOrder.pushBack(e);
809  else if (insertBeforeLast)
810  lastPos = rightEdgeOrder.insertBefore(e, lastPos);
811  else
812  lastPos = rightEdgeOrder.insertAfter(e, lastPos);
813 
814  //decide whether to choose face f_a or f_b as f_{mu, mu'}:
815  if (delta_u + sum_E_a < delta_d + sum_E_b)
816  {
817  ListIterator<adjEntry> beforeU = before;
818 
819  if (e->source() == n)
820  ae = e->adjSource();
821  else
822  ae = e->adjTarget();
823 
824  if (S.isVirtual(e))
825  {
826  node nu = S.twinTreeNode(e);
827 
828  T delta_u_nu = delta_u + sum_E_a;
829  T delta_d_nu = delta_d + sum_E_b;
830 
831  //buffer computed embedding:
832  NodeArray< List<adjEntry> > tmp_newOrder(spqrTree.originalGraph());
833  ListIterator<adjEntry> tmp_before;
834 
835  adjEntryForNode(ae, tmp_before, spqrTree, treeNodeTreated, mu,
836  m_leftNode, nodeLength, edgeLength, thickness,
837  tmp_newOrder, adjBeforeNodeArraySource,
838  adjBeforeNodeArrayTarget, delta_d_nu, delta_u_nu, adjExternal);
839 
840  //copy buffered embedding reversed into newOrder:
841  node leftOrg = S.original(m_leftNode);
842  node rightOrg = S.original(m_rightNode);
843  for(node nOG : spqrTree.originalGraph().nodes)
844  {
845  List<adjEntry> nOG_tmp_adjList = tmp_newOrder[nOG];
846  if (nOG_tmp_adjList.size() == 0)
847  continue;
848 
849  ListIterator<adjEntry>* m_before;
850  if (nOG == leftOrg)
851  m_before = &beforeU;
852  else if (nOG == rightOrg && referenceEdge)
853  m_before = &beforeRight;
854  else
855  m_before = new ListIterator<adjEntry>();
856 
857  for (ListIterator<adjEntry> ae_it = nOG_tmp_adjList.begin(); ae_it.valid(); ++ae_it) {
858  adjEntry adjaEnt = *ae_it;
859  if (!m_before->valid())
860  *m_before = newOrder[nOG].pushBack(adjaEnt);
861  else
862  *m_before = newOrder[nOG].insertBefore(adjaEnt, *m_before);
863 
864  if (nOG == leftOrg || nOG == rightOrg)
865  {
866  if (S.original(e->source()) == nOG)
867  adjBeforeNodeArraySource[nu] = *m_before;
868  else
869  adjBeforeNodeArrayTarget[nu] = *m_before;
870  }
871  }
872 
873  if (nOG != leftOrg && (nOG != rightOrg || !referenceEdge))
874  delete m_before;
875  }
876 
877  sum_E_a += thickness[nu];
878  }
879  else
880  {
881  adjEntryForNode(ae, beforeU, spqrTree, treeNodeTreated, mu,
882  m_leftNode, nodeLength, edgeLength, thickness,
883  newOrder, adjBeforeNodeArraySource,
884  adjBeforeNodeArrayTarget, 0, 0, adjExternal);
885 
886  sum_E_a += 1;
887  }
888 
889  insertBeforeLast = false;
890  if (!oneEdgeInE_a)
891  {
892  beforeLeft = beforeU;
893  oneEdgeInE_a = true;
894  }
895  }
896  else
897  {
898  if (S.isVirtual(e)) {
899  node nu = S.twinTreeNode(e);
900  if (referenceEdge) {
901  if (e->source() == n)
902  adjBeforeNodeArrayTarget[nu] = beforeRight;
903  else
904  adjBeforeNodeArraySource[nu] = beforeRight;
905  }
906  }
907 
908  T delta_u_nu = delta_u + sum_E_a;
909  T delta_d_nu = delta_d + sum_E_b;
910 
911  if (e->source() == n)
912  ae = e->adjSource();
913  else
914  ae = e->adjTarget();
915 
916  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
917  m_leftNode, nodeLength, edgeLength, thickness, newOrder,
918  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
919  delta_u_nu, delta_d_nu, adjExternal);
920 
921  if (S.isVirtual(e))
922  sum_E_b += thickness[S.twinTreeNode(e)];
923  else
924  sum_E_b += 1;
925 
926  insertBeforeLast = true;
927  if (!oneEdgeInE_a)
928  beforeLeft = before;
929  }
930  }
931  }
932  else
933  {
934  for (ListIterator<edge> it = rightEdgeOrder.begin(); it.valid(); ++it)
935  {
936  if ((*it)->source() == n)
937  ae = (*it)->adjSource();
938  else
939  ae = (*it)->adjTarget();
940 
941  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
942  m_leftNode, nodeLength, edgeLength, thickness, newOrder,
943  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
944  0, 0, adjExternal);
945  }
946  }
947 
948  //(alternative) reference edge at last:
949  if (referenceEdge) {
950  if (i == 0) {
951  if (n == referenceEdge->source())
952  adjBeforeNodeArraySource[mu] = beforeLeft;
953  else
954  adjBeforeNodeArrayTarget[mu] = beforeLeft;
955  }
956  else
957  {
958  if (n == referenceEdge->source())
959  adjBeforeNodeArraySource[mu] = before;
960  else
961  adjBeforeNodeArrayTarget[mu] = before;
962  }
963  }
964  else
965  {
966  if (altReferenceEdge->source() == n)
967  ae = altReferenceEdge->adjSource();
968  else
969  ae = altReferenceEdge->adjTarget();
970 
971  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
972  m_leftNode, nodeLength, edgeLength, thickness, newOrder,
973  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
974  0, 0, adjExternal);
975  }
976  }
977 }
978 
979 
980 template<class T>
982  const StaticSPQRTree& spqrTree,
983  NodeArray<bool>& treeNodeTreated,
984  const node& mu,
985  const node& leftNode,
986  const NodeArray<T>& nodeLength,
987  const NodeArray< EdgeArray<T> >& edgeLength,
988  const NodeArray<T>& thickness,
989  NodeArray< List<adjEntry> >& newOrder,
990  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
991  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
992  const T& delta_u,
993  const T& delta_d,
994  adjEntry& adjExternal,
995  const node& n /* = 0 */)
996 {
997  Skeleton& S = spqrTree.skeleton(mu);
998  edge referenceEdge = S.referenceEdge();
999 
1000  //compute biggest face containing the reference edge:
1001  face maxFaceContEdge = nullptr;
1002  List<node> maxFaceNodes;
1003  planarEmbed(S.getGraph());
1004  CombinatorialEmbedding combinatorialEmbedding(S.getGraph());
1005  T bigFaceSize = -1;
1006  adjEntry m_adjExternal = nullptr;
1007  for(face f : combinatorialEmbedding.faces)
1008  {
1009  bool containsVirtualEdgeOrN = false;
1010  adjEntry this_m_adjExternal = nullptr;
1011  T sizeOfFace = 0;
1012  List<node> faceNodes;
1013  for(adjEntry ae : f->entries)
1014  {
1015  faceNodes.pushBack(ae->theNode());
1016  if ((n == nullptr && (ae->theEdge() == referenceEdge || !referenceEdge))
1017  || S.original(ae->theNode()) == n) {
1018  containsVirtualEdgeOrN = true;
1019  if (referenceEdge)
1020  this_m_adjExternal = ae;
1021  }
1022 
1023  if (!referenceEdge && !S.isVirtual(ae->theEdge()))
1024  this_m_adjExternal = ae;
1025 
1026  sizeOfFace += edgeLength[mu][ae->theEdge()]
1027  + nodeLength[S.original(ae->theNode())];
1028  }
1029 
1030  if (containsVirtualEdgeOrN && this_m_adjExternal && sizeOfFace > bigFaceSize) {
1031  maxFaceNodes = faceNodes;
1032  bigFaceSize = sizeOfFace;
1033  maxFaceContEdge = f;
1034  m_adjExternal = this_m_adjExternal;
1035  }
1036  }
1037  OGDF_ASSERT(maxFaceContEdge);
1038 
1039  if (!adjExternal) {
1040  edge orgEdge = S.realEdge(m_adjExternal->theEdge());
1041  if (orgEdge->source() == S.original(m_adjExternal->theNode()))
1042  adjExternal = orgEdge->adjSource();
1043  else
1044  adjExternal = orgEdge->adjTarget();
1045  }
1046 
1047  adjEntry adjMaxFace = m_adjExternal;
1048 
1049  //if embedding is mirror symmetrical embedding of desired embedding,
1050  //invert adjacency list of all nodes:
1051  if (referenceEdge) {
1052  //successor of adjEntry of virtual edge in adjacency list of leftNode:
1053  adjEntry succ_virtualEdge_leftNode;
1054  if (leftNode == referenceEdge->source())
1055  succ_virtualEdge_leftNode = referenceEdge->adjSource()->succ();
1056  else
1057  succ_virtualEdge_leftNode = referenceEdge->adjTarget()->succ();
1058  if (!succ_virtualEdge_leftNode)
1059  succ_virtualEdge_leftNode = leftNode->firstAdj();
1060 
1061  bool succVELNAEInExtFace = false;
1062  for(adjEntry aeExtFace : maxFaceContEdge->entries)
1063  {
1064  if (aeExtFace->theEdge() == succ_virtualEdge_leftNode->theEdge())
1065  {
1066  succVELNAEInExtFace = true;
1067  break;
1068  }
1069  }
1070 
1071  if (!succVELNAEInExtFace)
1072  {
1073  for(node v : S.getGraph().nodes)
1074  {
1075  List<adjEntry> newAdjOrder;
1076  for (adjEntry ae = v->firstAdj(); ae; ae = ae->succ())
1077  newAdjOrder.pushFront(ae);
1078  S.getGraph().sort(v, newAdjOrder);
1079  }
1080  adjMaxFace = adjMaxFace->twin();
1081  }
1082  }
1083 
1084  NodeArray<bool> nodeTreated(S.getGraph(), false);
1085  adjEntry start_ae;
1086  if (referenceEdge) {
1087  start_ae = adjMaxFace;
1088  do
1089  {
1090  if (start_ae->theEdge() == referenceEdge) {
1091  start_ae = start_ae->faceCycleSucc();
1092  break;
1093  }
1094  start_ae = start_ae->faceCycleSucc();
1095  } while(start_ae != adjMaxFace);
1096  }
1097  else
1098  start_ae = adjMaxFace;
1099 
1100  //For every edge a buffer saving adjacency entries written in embedding step
1101  //for nodes on the maximum face, needed in step for other nodes.
1102  EdgeArray< List<adjEntry> > buffer(S.getGraph());
1103 
1104  bool firstStep = true;
1105  bool after_start_ae = true;
1106  for (adjEntry ae = start_ae;
1107  firstStep || ae != start_ae;
1108  after_start_ae = after_start_ae && ae->succ(),
1109  ae = after_start_ae ? ae->faceCycleSucc()
1110  : (!ae->faceCycleSucc() ? adjMaxFace : ae->faceCycleSucc()))
1111  {
1112  firstStep = false;
1113 #if 0
1114  node nodeG = S.original(ae->theNode());
1115 #endif
1116  nodeTreated[ae->theNode()] = true;
1117 
1118  //copy adjacency list of nodes into newOrder:
1120  edge vE = (ae->theEdge() == referenceEdge) ? referenceEdge : ae->theEdge();
1121  node nu = (ae->theEdge() == referenceEdge) ? mu : S.twinTreeNode(ae->theEdge());
1122  if (S.isVirtual(vE)) {
1123  if (ae->theNode() == vE->source())
1124  before = adjBeforeNodeArraySource[nu];
1125  else
1126  before = adjBeforeNodeArrayTarget[nu];
1127  }
1128 
1129  bool after_ae = true;
1130  adjEntry m_start_ae;
1131  if (referenceEdge) {
1132  if (ae->theNode() == referenceEdge->source())
1133  m_start_ae = referenceEdge->adjSource();
1134  else if (ae->theNode() == referenceEdge->target())
1135  m_start_ae = referenceEdge->adjTarget();
1136  else
1137  m_start_ae = ae;
1138  }
1139  else
1140  m_start_ae = ae;
1141 
1142  adjEntry m_stop_ae;
1143  bool hit_stop_twice = false;
1144  int numOfHits = 0;
1145  if (referenceEdge
1146  && (ae->theNode() == referenceEdge->source()
1147  || ae->theNode() == referenceEdge->target())) {
1148  if (m_start_ae->succ())
1149  m_stop_ae = m_start_ae->succ();
1150  else {
1151  m_stop_ae = m_start_ae->theNode()->firstAdj();
1152  hit_stop_twice = true;
1153  }
1154  }
1155  else
1156  m_stop_ae = m_start_ae;
1157 
1158  for (adjEntry aeN = m_start_ae;
1159  after_ae || (hit_stop_twice && numOfHits != 2) || aeN != m_stop_ae;
1160  after_ae = after_ae && aeN->succ(),
1161  aeN = after_ae ? aeN->succ()
1162  : (!aeN->succ() ? ae->theNode()->firstAdj() : aeN->succ()),
1163  numOfHits = (aeN == m_stop_ae) ? numOfHits + 1 : numOfHits) {
1164  node m_leftNode = nullptr;
1165  if (S.isVirtual(aeN->theEdge()) && aeN->theEdge() != referenceEdge)
1166  {
1167  //Compute left node of aeN->theNode(). First get adjacency entry in ext. face
1168  //(if edge is in ext. face) and compare face cycle successor with successor
1169  //in node adjacency list. If it is the same, it is the right node, otherwise
1170  //the left.
1171  adjEntry aeExtFace = nullptr;
1172  bool succInExtFace = false;
1173  bool aeNInExtFace = false;
1174  adjEntry aeNSucc = (aeN->succ()) ? aeN->succ() : ae->theNode()->firstAdj();
1175  aeExtFace = adjMaxFace;
1176  do
1177  {
1178  if (aeExtFace->theEdge() == aeNSucc->theEdge())
1179  {
1180  succInExtFace = true;
1181  if (aeNInExtFace)
1182  break;
1183  }
1184  if (aeExtFace->theEdge() == aeN->theEdge())
1185  {
1186  aeNInExtFace = true;
1187  if (succInExtFace)
1188  break;
1189  }
1190  aeExtFace = aeExtFace->faceCycleSucc();
1191  } while(aeExtFace != adjMaxFace);
1192  if (aeNInExtFace && succInExtFace)
1193  m_leftNode = aeN->twinNode();
1194  else
1195  m_leftNode = aeN->theNode();
1196 
1197  node twinTN = S.twinTreeNode(aeN->theEdge());
1198  if (referenceEdge) {
1199  if (aeN->theEdge()->source() == aeN->theNode()) {
1200  if (aeN->theEdge()->target() == referenceEdge->source())
1201  adjBeforeNodeArrayTarget[twinTN] = adjBeforeNodeArraySource[mu];
1202  else if (aeN->theEdge()->target() == referenceEdge->target())
1203  adjBeforeNodeArrayTarget[twinTN] = adjBeforeNodeArrayTarget[mu];
1204  }
1205  else
1206  {
1207  if (aeN->theEdge()->source() == referenceEdge->source())
1208  adjBeforeNodeArraySource[twinTN] = adjBeforeNodeArraySource[mu];
1209  else if (aeN->theEdge()->source() == referenceEdge->target())
1210  adjBeforeNodeArraySource[twinTN] = adjBeforeNodeArrayTarget[mu];
1211  }
1212  }
1213  }
1214 
1215  adjEntryForNode(aeN, before, spqrTree, treeNodeTreated, mu,
1216  m_leftNode, nodeLength, edgeLength, thickness, newOrder,
1217  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
1218  0, 0, adjExternal);
1219 
1220  //if the other node adjacent to the current treated edge is not in the
1221  //max face, put written edges into an buffer and clear the adjacency
1222  //list of that node.
1223  if (!maxFaceNodes.search(aeN->twinNode()).valid())
1224  {
1225  node orig_aeN_twin_theNode = S.original(aeN->twinNode());
1226  buffer[aeN->theEdge()] = newOrder[orig_aeN_twin_theNode];
1227  newOrder[orig_aeN_twin_theNode].clear();
1228  }
1229  }
1230  }
1231 
1232  //Copy of not treated node's adjacency lists (internal nodes). Setting
1233  //of left node depending on minimal distance to external face of the
1234  //face defined by left node.
1235  bool DGcomputed = false;
1236  int f_ext_id = 0;
1237  int f_ref_id = 0;
1238  Graph DG;
1239  ArrayBuffer<node> fPG_to_nDG;
1240  NodeArray< List<adjEntry> > adjacencyList;
1241  List< List<adjEntry> > faces;
1242  NodeArray<T> dist_f_ref;
1243  NodeArray<T> dist_f_ext;
1244  AdjEntryArray<int> ae_to_face;
1245 
1246  for(node v : S.getGraph().nodes)
1247  {
1248  if (nodeTreated[v])
1249  continue;
1250 
1251  node v_original = S.original(v);
1252  nodeTreated[v] = true;
1254  for (adjEntry ae = v->firstAdj(); ae; ae = ae->succ())
1255  {
1256  if (buffer[ae->theEdge()].empty())
1257  {
1258  T delta_u_nu = 0;
1259  T delta_d_nu = 0;
1260  bool frauenlinks = false;
1261  if (S.isVirtual(ae->theEdge()))
1262  {
1263  if (!DGcomputed) {
1264  ae_to_face.init(S.getGraph());
1265  EdgeArray<T> edgeLengthDG(DG);
1266  DGcomputed = true;
1267 
1268  //compute dual graph of skeleton graph:
1269  adjacencyList.init(S.getGraph());
1270  for(node nBG : S.getGraph().nodes)
1271  {
1272  for(adjEntry ae_nBG : nBG->adjEntries)
1273  adjacencyList[nBG].pushBack(ae_nBG);
1274  }
1275 
1276  NodeArray< List<adjEntry> > adjEntryTreated(S.getGraph());
1277  for(node nBG : S.getGraph().nodes)
1278  {
1279  for(adjEntry adj : nBG->adjEntries)
1280  {
1281  if (adjEntryTreated[nBG].search(adj).valid())
1282  continue;
1283 
1284  List<adjEntry> newFace;
1285  adjEntry adj2 = adj;
1286  do {
1287  newFace.pushBack(adj2);
1288  ae_to_face[adj2] = faces.size();
1289  adjEntryTreated[adj2->theNode()].pushBack(adj2);
1290  List<adjEntry> &ladj = adjacencyList[adj2->twinNode()];
1291  adj2 = *ladj.cyclicPred(ladj.search(adj2->twin()));
1292  } while (adj2 != adj);
1293  faces.pushBack(newFace);
1294  }
1295  }
1296 
1297  for (ListIterator< List<adjEntry> > it = faces.begin(); it.valid(); ++it) {
1298  fPG_to_nDG.push(DG.newNode());
1299  }
1300 
1301  NodeArray< List<node> > adjFaces(DG);
1302  int i = 0;
1303  for (ListIterator< List<adjEntry> > it = faces.begin(); it.valid(); ++it) {
1304  int f1_id = i;
1305  for (ListIterator<adjEntry> it2 = (*it).begin(); it2.valid(); ++it2) {
1306  int f2_id = 0;
1307  int j = 0;
1308  for (ListIterator< List<adjEntry> > it3 = faces.begin(); it3.valid(); ++it3)
1309  {
1310  bool do_break = false;
1311  for (ListIterator<adjEntry> it4 = (*it3).begin(); it4.valid(); ++it4)
1312  {
1313  if ((*it4) == (*it2)->twin())
1314  {
1315  f2_id = j;
1316  do_break = true;
1317  break;
1318  }
1319  }
1320  if (do_break)
1321  break;
1322  j++;
1323  }
1324 
1325  if (f1_id != f2_id
1326  && !adjFaces[fPG_to_nDG[f1_id]].search(fPG_to_nDG[f2_id]).valid()
1327  && !adjFaces[fPG_to_nDG[f2_id]].search(fPG_to_nDG[f1_id]).valid())
1328  {
1329  adjFaces[fPG_to_nDG[f1_id]].pushBack(fPG_to_nDG[f2_id]);
1330  edge e1 = DG.newEdge(fPG_to_nDG[f1_id], fPG_to_nDG[f2_id]);
1331  edge e2 = DG.newEdge(fPG_to_nDG[f2_id], fPG_to_nDG[f1_id]);
1332 
1333  //set edge length:
1334  T e_length = -1;
1335  for (auto f1 : *it) {
1336  edge e = f1->theEdge();
1337  for (auto f2 : *faces.get(f2_id)) {
1338  if (f2->theEdge() == e
1339  && (e_length == -1
1340  || edgeLength[mu][e] < e_length)) {
1341  e_length = edgeLength[mu][e];
1342  }
1343  }
1344  }
1345  edgeLengthDG[e1] = e_length;
1346  edgeLengthDG[e2] = e_length;
1347  }
1348 
1349  if (*it2 == adjMaxFace)
1350  f_ext_id = f1_id;
1351  if (referenceEdge && *it2 == adjMaxFace->twin())
1352  f_ref_id = f1_id;
1353  }
1354  i++;
1355  }
1356 
1357  //compute shortest path from every face to the external face:
1358  node f_ext_DG = fPG_to_nDG[f_ext_id];
1359  dist_f_ext.init(DG);
1360  sssp(DG, f_ext_DG, edgeLengthDG, dist_f_ext);
1361  if (referenceEdge) {
1362  node f_ref_DG = fPG_to_nDG[f_ref_id];
1363  dist_f_ref.init(DG);
1364  sssp(DG, f_ref_DG, edgeLengthDG, dist_f_ref);
1365  }
1366  }
1367 
1368  //choose face with minimal shortest path:
1369  T min1, min2;
1370  T pi_f_0_f_ext = dist_f_ext[fPG_to_nDG[ae_to_face[ae]]];
1371  T pi_f_1_f_ext = dist_f_ext[fPG_to_nDG[ae_to_face[ae->twin()]]];
1372  if (referenceEdge) {
1373  T pi_f_0_f_ref = dist_f_ref[fPG_to_nDG[ae_to_face[ae]]];
1374  T pi_f_1_f_ref = dist_f_ref[fPG_to_nDG[ae_to_face[ae->twin()]]];
1375 
1376  if (delta_u + pi_f_0_f_ref < delta_d + pi_f_0_f_ext)
1377  min1 = delta_u + pi_f_0_f_ref;
1378  else
1379  min1 = delta_d + pi_f_0_f_ext;
1380 
1381  if (delta_u + pi_f_1_f_ref < delta_d + pi_f_1_f_ext)
1382  min2 = delta_u + pi_f_1_f_ref;
1383  else
1384  min2 = delta_d + pi_f_1_f_ext;
1385 
1386  if (min1 > min2)
1387  {
1388  delta_u_nu = delta_u;
1389  if (pi_f_0_f_ref < pi_f_0_f_ext)
1390  delta_u_nu += pi_f_0_f_ref;
1391  else
1392  delta_u_nu += pi_f_0_f_ext;
1393  delta_d_nu = delta_d;
1394  if (pi_f_1_f_ref < pi_f_1_f_ext)
1395  delta_d_nu += pi_f_1_f_ref;
1396  else
1397  delta_d_nu += pi_f_1_f_ext;
1398  }
1399  else
1400  {
1401  frauenlinks = true;
1402  delta_u_nu = delta_u;
1403  if (pi_f_1_f_ref < pi_f_1_f_ext)
1404  delta_u_nu += pi_f_1_f_ref;
1405  else
1406  delta_u_nu += pi_f_1_f_ext;
1407  delta_d_nu = delta_d;
1408  if (pi_f_0_f_ref < pi_f_0_f_ext)
1409  delta_d_nu += pi_f_0_f_ref;
1410  else
1411  delta_d_nu += pi_f_0_f_ext;
1412  }
1413  }
1414  else
1415  {
1416  min1 = delta_d + pi_f_0_f_ext;
1417  min2 = delta_d + pi_f_1_f_ext;
1418 
1419  if (min1 > min2)
1420  {
1421  delta_u_nu = delta_u + pi_f_0_f_ext;
1422  delta_d_nu = delta_d + pi_f_1_f_ext;
1423  }
1424  else
1425  {
1426  frauenlinks = true;
1427  delta_u_nu = delta_u + pi_f_1_f_ext;
1428  delta_d_nu = delta_d + pi_f_0_f_ext;
1429  }
1430  }
1431  }
1432 
1433  if (frauenlinks)
1434  {
1435  node nu = S.twinTreeNode(ae->theEdge());
1436 
1437  //buffer computed embedding:
1438  NodeArray< List<adjEntry> > tmp_newOrder(spqrTree.originalGraph());
1439  ListIterator<adjEntry> tmp_before;
1440 
1442  ae, tmp_before, spqrTree, treeNodeTreated, mu,
1443  v, nodeLength, edgeLength, thickness, tmp_newOrder,
1444  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
1445  delta_u_nu, delta_d_nu, adjExternal);
1446 
1447  //copy buffered embedding reversed into newOrder:
1448 #if 0
1449  node m_leftNode = v;
1450 #endif
1451  node m_rightNode = ae->twinNode();
1452  node leftOrg = v_original;
1453  node rightOrg = S.original(m_rightNode);
1454  for(node nOG : spqrTree.originalGraph().nodes)
1455  {
1456  List<adjEntry> nOG_tmp_adjList = tmp_newOrder[nOG];
1457  if (nOG_tmp_adjList.size() == 0)
1458  continue;
1459 
1460  ListIterator<adjEntry>* m_before;
1461  if (nOG == leftOrg)
1462  m_before = &before;
1463  else
1464  m_before = new ListIterator<adjEntry>();
1465 
1466  for (ListIterator<adjEntry> ae_it = nOG_tmp_adjList.begin(); ae_it.valid(); ++ae_it)
1467  {
1468  adjEntry adjaEnt = *ae_it;
1469  if (!m_before->valid())
1470  *m_before = newOrder[nOG].pushBack(adjaEnt);
1471  else
1472  *m_before = newOrder[nOG].insertBefore(adjaEnt, *m_before);
1473 
1474  if (nOG == leftOrg || nOG == rightOrg)
1475  {
1476  if (S.original(ae->theEdge()->source()) == nOG)
1477  adjBeforeNodeArraySource[nu] = *m_before;
1478  else
1479  adjBeforeNodeArrayTarget[nu] = *m_before;
1480  }
1481  }
1482 
1483  if (nOG != leftOrg)
1484  delete m_before;
1485  }
1486  }
1487  else
1488  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
1489  v, nodeLength, edgeLength, thickness, newOrder,
1490  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
1491  delta_u_nu, delta_d_nu, adjExternal);
1492 
1493  if (!nodeTreated[ae->twinNode()])
1494  {
1495  node orig_ae_twin_theNode = S.original(ae->twinNode());
1496  buffer[ae->theEdge()] = newOrder[orig_ae_twin_theNode];
1497  newOrder[orig_ae_twin_theNode].clear();
1498  }
1499  }
1500  else
1501  {
1502  buffer[ae->theEdge()].reverse();
1503  for (ListIterator<adjEntry> it = buffer[ae->theEdge()].begin(); it.valid(); ++it)
1504  {
1505  if (!before.valid())
1506  before = newOrder[v_original].pushFront(*it);
1507  else
1508  before = newOrder[v_original].insertBefore(*it, before);
1509  }
1510  }
1511  }
1512  }
1513 }
1514 
1515 template<class T>
1517  const StaticSPQRTree& spqrTree,
1518  const node& mu,
1519  NodeArray<T>& thickness,
1520  const NodeArray<T>& nodeLength,
1521  const NodeArray< EdgeArray<T> >& edgeLength)
1522 {
1523  //recursion:
1524  for(adjEntry adj : mu->adjEntries) {
1525  edge e_mu_to_nu = adj->theEdge();
1526  if (e_mu_to_nu->source() != mu)
1527  continue;
1528  else
1529  {
1530  node nu = e_mu_to_nu->target();
1531  bottomUpThickness(spqrTree, nu, thickness, nodeLength, edgeLength);
1532  }
1533  }
1534 
1535  Skeleton& S = spqrTree.skeleton(mu);
1536  edge referenceEdge = S.referenceEdge();
1537 
1538  if (!referenceEdge) { //root of SPQR-tree
1539  thickness[mu] = 0;
1540  return;
1541  }
1542 
1543  //set dLengths for all edges in skeleton graph:
1544  EdgeArray<T> dLength(S.getGraph());
1545  for(edge eSG : S.getGraph().edges)
1546  {
1547  if (eSG == referenceEdge)
1548  continue;
1549 
1550  if (S.isVirtual(eSG))
1551  {
1552  node twinTN = S.twinTreeNode(eSG);
1553  dLength[eSG] = thickness[twinTN];
1554  }
1555  else
1556  dLength[eSG] = edgeLength[mu][eSG];
1557  }
1558 
1559  //compute thickness of skeleton(mu):
1560  switch (spqrTree.typeOf(mu))
1561  {
1563  {
1564  //thickness(mu) = min_{edges e != referenceEdge} dLength(e)
1565  T min_dLength = -1;
1566  for(edge eSG : S.getGraph().edges)
1567  {
1568  if (eSG == referenceEdge)
1569  continue;
1570  if (min_dLength == -1 || dLength[eSG] < min_dLength)
1571  min_dLength = dLength[eSG];
1572  }
1573  thickness[mu] = min_dLength;
1574  } break;
1576  {
1577  //thickness(mu) = sum_{edges e != referenceEdge} dLength(e)
1578  T sumof_dLength = 0;
1579  for(edge eSG : S.getGraph().edges)
1580  {
1581  if (eSG == referenceEdge)
1582  continue;
1583  sumof_dLength += dLength[eSG];
1584  }
1585  thickness[mu] = sumof_dLength;
1586  } break;
1588  {
1589  /* Let f^ref_0, ... , f^ref_k be the faces sharing at least one edge with
1590  * f_ref - the face adjacent to the reference edge not equal to the
1591  * external face f_ext. Compute the dual graph and set edge lengths for
1592  * two faces f_i, f_j, i != j, with at least one shared edge, to the
1593  * minimal dLength of the shared edges of f_i and f_j. Remove the node
1594  * related to face f_ref. thickness(mu) is then the length of the shortest
1595  * path from any of the faces f^ref_0, ... , f^ref_k to f_ext plus 1.
1596  */
1598  adjEntry ae_f_ext = referenceEdge->adjSource();
1599  adjEntry ae_f_ref = referenceEdge->adjTarget();
1600  T faceSize_f_ext = 0;
1601  adjEntry ae_f_ext_walker = ae_f_ext;
1602  do
1603  {
1604  faceSize_f_ext += nodeLength[S.original(ae_f_ext_walker->theNode())]
1605  + edgeLength[mu][ae_f_ext_walker->theEdge()];
1606  ae_f_ext_walker = ae_f_ext_walker->faceCycleSucc();
1607  } while (ae_f_ext_walker != ae_f_ext);
1608  T faceSize_f_ref = 0;
1609  adjEntry ae_f_ref_walker = ae_f_ref;
1610  do
1611  {
1612  faceSize_f_ref += nodeLength[S.original(ae_f_ref_walker->theNode())]
1613  + edgeLength[mu][ae_f_ref_walker->theEdge()];
1614  ae_f_ref_walker = ae_f_ref_walker->faceCycleSucc();
1615  } while (ae_f_ref_walker != ae_f_ref);
1616  if (faceSize_f_ext < faceSize_f_ref)
1617  {
1618  adjEntry ae_tmp = ae_f_ext;
1619  ae_f_ext = ae_f_ref;
1620  ae_f_ref = ae_tmp;
1621  }
1622 
1623  //compute dual graph:
1624  Graph DG;
1625  ArrayBuffer<node> fPG_to_nDG;
1626  NodeArray< List<adjEntry> > adjacencyList(S.getGraph());
1627  List< List<adjEntry> > faces;
1628  NodeArray<int> distances;
1629  EdgeArray<T> edgeLengthDG(DG);
1630  int f_ref_id = -1;
1631  int f_ext_id = -1;
1632 
1633  for(node nBG : S.getGraph().nodes)
1634  {
1635  for(adjEntry ae_nBG : nBG->adjEntries)
1636  adjacencyList[nBG].pushBack(ae_nBG);
1637  }
1638 
1639  NodeArray< List<adjEntry> > adjEntryTreated(S.getGraph());
1640  for(node nBG : S.getGraph().nodes)
1641  {
1642  for(adjEntry adj : nBG->adjEntries)
1643  {
1644  if (adjEntryTreated[nBG].search(adj).valid())
1645  continue;
1646 
1647  List<adjEntry> newFace;
1648  adjEntry adj2 = adj;
1649  do {
1650  newFace.pushBack(adj2);
1651  adjEntryTreated[adj2->theNode()].pushBack(adj2);
1652  List<adjEntry> &ladj = adjacencyList[adj2->twinNode()];
1653  adj2 = *ladj.cyclicPred(ladj.search(adj2->twin()));
1654  } while (adj2 != adj);
1655  faces.pushBack(newFace);
1656  }
1657  }
1658 
1659  for (ListIterator< List<adjEntry> > it = faces.begin(); it.valid(); ++it) {
1660  fPG_to_nDG.push(DG.newNode());
1661  }
1662 
1663  NodeArray< List<node> > adjFaces(DG);
1664  int i = 0;
1665  for (ListIterator< List<adjEntry> > it = faces.begin(); it.valid(); ++it)
1666  {
1667  int f1_id = i;
1668  for (ListIterator<adjEntry> it2 = (*it).begin(); it2.valid(); ++it2)
1669  {
1670  int f2_id = 0;
1671  int j = 0;
1672  for (ListIterator< List<adjEntry> > it3 = faces.begin(); it3.valid(); ++it3)
1673  {
1674  bool do_break = false;
1675  for (ListIterator<adjEntry> it4 = (*it3).begin(); it4.valid(); ++it4)
1676  {
1677  if ((*it4) == (*it2)->twin())
1678  {
1679  f2_id = j;
1680  do_break = true;
1681  break;
1682  }
1683  }
1684  if (do_break)
1685  break;
1686  j++;
1687  }
1688 
1689  if (f1_id != f2_id
1690  && !adjFaces[fPG_to_nDG[f1_id]].search(fPG_to_nDG[f2_id]).valid()
1691  && !adjFaces[fPG_to_nDG[f2_id]].search(fPG_to_nDG[f1_id]).valid())
1692  {
1693  adjFaces[fPG_to_nDG[f1_id]].pushBack(fPG_to_nDG[f2_id]);
1694  adjFaces[fPG_to_nDG[f2_id]].pushBack(fPG_to_nDG[f1_id]);
1695  edge e1 = DG.newEdge(fPG_to_nDG[f1_id], fPG_to_nDG[f2_id]);
1696  edge e2 = DG.newEdge(fPG_to_nDG[f2_id], fPG_to_nDG[f1_id]);
1697 
1698  //set edge length:
1699  T e_length = -1;
1700  for (ListIterator<adjEntry> it_f1 = (*it).begin(); it_f1.valid(); ++it_f1)
1701  {
1702  edge e = (*it_f1)->theEdge();
1703  for (ListIterator<adjEntry> it_f2 = (*(faces.get(f2_id))).begin();
1704  it_f2.valid();
1705  ++it_f2)
1706  {
1707  if ((*it_f2)->theEdge() == e
1708  && (e_length == -1
1709  || edgeLength[mu][e] < e_length)) {
1710  e_length = edgeLength[mu][e];
1711  }
1712  }
1713  }
1714  edgeLengthDG[e1] = e_length;
1715  edgeLengthDG[e2] = e_length;
1716  }
1717 
1718  if (*it2 == ae_f_ext)
1719  f_ext_id = f1_id;
1720  if (*it2 == ae_f_ref)
1721  f_ref_id = f1_id;
1722  }
1723  i++;
1724  }
1725 
1726  //the faces sharing at least one edge with f_ref:
1727  node nDG_f_ref = fPG_to_nDG[f_ref_id];
1728  List<node>& f_ref_adj_faces = adjFaces[nDG_f_ref];
1729 
1730  //remove node related to f_ref from dual graph:
1731  DG.delNode(fPG_to_nDG[f_ref_id]);
1732 
1733  //compute shortest path and set thickness:
1734  NodeArray<T> dist(DG);
1735  node nDG_f_ext = fPG_to_nDG[f_ext_id];
1736  sssp(DG, nDG_f_ext, edgeLengthDG, dist);
1737  T minDist = -1;
1738  for (ListIterator<node> it_adj_faces = f_ref_adj_faces.begin();
1739  it_adj_faces.valid();
1740  ++it_adj_faces)
1741  {
1742  node fDG = *it_adj_faces;
1743  if (fDG != nDG_f_ext)
1744  {
1745  T d = dist[fDG];
1746  if (minDist == -1 || d < minDist)
1747  minDist = d;
1748  }
1749  }
1750  thickness[mu] = minDist + 1;
1751  } break;
1752  default:
1753  OGDF_ASSERT(false);
1754  }
1755 }
1756 
1757 
1758 template<class T>
1760  const Graph& G,
1761  const node& s,
1762  const EdgeArray<T>& length,
1763  NodeArray<T>& d)
1764 {
1765  const T infinity = 20000000; // big number. danger. think about it.
1766 
1767  //Initialize-Single-Source(G, s):
1768  d.init(G);
1769  for(node v : G.nodes)
1770  d[v] = infinity;
1771 
1772  d[s] = 0;
1773  for (int i = 1; i < G.numberOfNodes(); ++i)
1774  {
1775  for(edge e : G.edges)
1776  {
1777  //relax(u, v, w): // e == (u, v), length == w
1778  if (d[e->target()] > d[e->source()] + length[e])
1779  d[e->target()] = d[e->source()] + length[e];
1780  }
1781  }
1782 
1783  //check for negative cycle:
1784  for(edge e : G.edges)
1785  {
1786  if (d[e->target()] > d[e->source()] + length[e])
1787  return false;
1788  }
1789 
1790  return true;
1791 }
1792 
1793 }
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:328
virtual edge realEdge(edge e) const =0
Returns the real edge that corresponds to skeleton edge e.
virtual node twinTreeNode(edge e) const =0
Returns the tree node in T containing the twin edge of skeleton edge e.
static T largestFaceInSkeleton(const StaticSPQRTree &spqrTree, const node &mu, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength)
Computes the size of a maximum face in the skeleton graph of mu.
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:96
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:1373
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
virtual void delNode(node v)
Removes node v and all incident edges from the graph.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition: Graph_d.h:333
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
Definition: Graph_d.h:1051
void init()
Reinitializes the array. Associates the array with no graph.
Definition: NodeArray.h:255
static void compute(const Graph &G, const NodeArray< T > &nodeLength, const EdgeArray< T > &edgeLength, StaticSPQRTree *spqrTree, NodeArray< EdgeArray< T > > &edgeLengthSkel)
Computes the component lengths of all virtual edges in spqrTree.
const Graph & getGraph() const
Returns a reference to the skeleton graph M.
Definition: Skeleton.h:99
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:210
const Skeleton & skeletonOfReal(edge e) const override
Returns the skeleton that contains the real edge e.
iterator begin()
Returns an iterator to the first element of the list.
Definition: List.h:352
const Graph & originalGraph() const override
Returns a reference to the original graph G.
iterator insertAfter(const E &x, iterator it)
Inserts element x after it.
Definition: List.h:1398
void push(E e)
Puts a new element in the buffer.
Definition: ArrayBuffer.h:102
virtual node original(node v) const =0
Returns the vertex in the original graph G that corresponds to v.
node rootTreeAt(edge e) override
Roots T at edge e and returns the new root node of T.
static bool sssp(const Graph &G, const node &s, const EdgeArray< T > &length, NodeArray< T > &d)
An array that keeps track of the number of inserted elements; also usable as an efficient stack...
Definition: Array.h:45
const_iterator cyclicPred(const_iterator it) const
Returns a const iterator to the cyclic predecessor of it.
Definition: List.h:462
Embedder that maximizes the external face (plus layers approach).
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
static void expandEdgePNode(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, const NodeArray< T > &thickness, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, const T &delta_u, const T &delta_d, adjEntry &adjExternal)
edge referenceEdge() const
Returns the reference edge of S in M.
Definition: Skeleton.h:94
Skeleton graphs of nodes in an SPQR-tree.
Definition: Skeleton.h:61
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:124
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition: Graph_d.h:142
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:568
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:601
static T largestFaceContainingNode(const StaticSPQRTree &spqrTree, const node &mu, const node &n, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength)
Computes the size of a maximum face in the skeleton graph of mu containing n.
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
bool planarEmbed(Graph &G)
Returns true, if G is planar, false otherwise. If true is returned, G will be planarly embedded...
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
Definition: List.h:1360
NodeType typeOf(node v) const override
Returns the type of node v.
edge firstEdge() const
Returns the first edge in the list of all edges.
Definition: Graph_d.h:623
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
internal::FaceAdjContainer entries
Container maintaining the adjacency entries in the face.
Faces in a combinatorial embedding.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Definition: Graph_d.h:108
Class for the representation of edges.
Definition: Graph_d.h:292
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:105
const_iterator get(int pos) const
Returns a const iterator pointing to the element at position pos.
Definition: List.h:310
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
Definition: Graph_d.h:215
Class for the representation of nodes.
Definition: Graph_d.h:169
static void adjEntryForNode(adjEntry &ae, ListIterator< adjEntry > &before, const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, const NodeArray< T > &thickness, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, const T &delta_u, const T &delta_d, adjEntry &adjExternal)
bool valid() const
Returns true iff the array is associated with a graph.
Definition: NodeArray.h:157
Encapsulates a pointer to a list element.
Definition: List.h:42
virtual edge twinEdge(edge e) const =0
Returns the twin edge of skeleton edge e.
Skeleton & skeleton(node v) const override
Returns the skeleton of node v.
static void bottomUpThickness(const StaticSPQRTree &spqrTree, const node &mu, NodeArray< T > &thickness, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength)
Linear-time implementation of static SPQR-trees.
Declares ogdf::EmbedderMaxFaceBiconnectedGraphs.
static void expandEdgeSNode(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, const NodeArray< T > &thickness, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, const T &delta_u, const T &delta_d, adjEntry &adjExternal)
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:148
static void expandEdgeRNode(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, const NodeArray< T > &thickness, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, const T &delta_u, const T &delta_d, adjEntry &adjExternal, const node &n=nullptr)
int size() const
Returns the number of elements in the list.
Definition: List.h:1312
iterator begin()
Returns an iterator to the first entry in the node array.
Definition: NodeArray.h:215
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
Definition: Graph_d.h:651
void init()
Reinitializes the array. Associates the array with no graph.
static void embed(Graph &G, adjEntry &adjExternal, const NodeArray< T > &nodeLength, const EdgeArray< T > &edgeLength, const node &n=nullptr)
Embeds G by computing and extending a maximum face in G containing n.
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:326
iterator insertBefore(const E &x, iterator it)
Inserts element x before it.
Definition: List.h:1392
Embedder that maximizing the external face.
The namespace for all OGDF objects.
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:598
node newNode()
Creates a new node and returns it.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:565
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:213
static void expandEdge(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, const NodeArray< T > &thickness, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, const T &delta_u, const T &delta_d, adjEntry &adjExternal, const node &n=nullptr)
Combinatorial embeddings of planar graphs with modification functionality.
ListConstIterator< E > search(const E &e) const
Scans the list for the specified element and returns an iterator to the first occurrence in the list...
Definition: List.h:1118
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition: Graph_d.h:335
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:100
Class for adjacency list elements.
Definition: Graph_d.h:79
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
const Graph & tree() const override
Returns a reference to the tree T.
virtual bool isVirtual(edge e) const =0
Returns true iff e is a virtual edge.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition: Graph_d.h:200