Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

EmbedderMaxFaceBiconnectedGraphs.h
Go to the documentation of this file.
1 
32 #pragma once
33 
37 
38 
39 namespace ogdf {
40 
42 
48 template<class T>
50 {
51 public:
62  static void embed(
63  Graph& G,
64  adjEntry& adjExternal,
65  const NodeArray<T>& nodeLength,
66  const EdgeArray<T>& edgeLength,
67  const node& n = nullptr);
68 
78  static void compute(
79  const Graph& G,
80  const NodeArray<T>& nodeLength,
81  const EdgeArray<T>& edgeLength,
82  StaticSPQRTree *spqrTree,
83  NodeArray< EdgeArray<T> >& edgeLengthSkel);
84 
93  static T computeSize(
94  const Graph& G,
95  const node& n,
96  const NodeArray<T>& nodeLength,
97  const EdgeArray<T>& edgeLength);
98 
110  static T computeSize(
111  const Graph& G,
112  const node& n,
113  const NodeArray<T>& nodeLength,
114  const EdgeArray<T>& edgeLength,
115  StaticSPQRTree *spqrTree);
116 
130  static T computeSize(
131  const Graph& G,
132  const node& n,
133  const NodeArray<T>& nodeLength,
134  const EdgeArray<T>& edgeLength,
135  StaticSPQRTree *spqrTree,
136  const NodeArray< EdgeArray<T> >& edgeLengthSkel);
137 
145  static T computeSize(
146  const Graph& G,
147  const NodeArray<T>& nodeLength,
148  const EdgeArray<T>& edgeLength);
149 
163  static T computeSize(
164  const Graph& G,
165  const NodeArray<T>& nodeLength,
166  const EdgeArray<T>& edgeLength,
167  StaticSPQRTree *spqrTree,
168  NodeArray< EdgeArray<T> >& edgeLengthSkel);
169 
170 protected:
181  static void bottomUpTraversal(
182  StaticSPQRTree& spqrTree,
183  const node& mu,
184  const NodeArray<T>& nodeLength,
185  NodeArray< EdgeArray<T> >& edgeLength);
186 
197  static void topDownTraversal(
198  StaticSPQRTree& spqrTree,
199  const node& mu,
200  const NodeArray<T>& nodeLength,
201  NodeArray< EdgeArray<T> >& edgeLength);
202 
214  static T largestFaceContainingNode(
215  const StaticSPQRTree& spqrTree,
216  const node& mu,
217  const node& n,
218  const NodeArray<T>& nodeLength,
219  const NodeArray< EdgeArray<T> >& edgeLength);
220 
230  static T largestFaceInSkeleton(
231  const StaticSPQRTree& spqrTree,
232  const node& mu,
233  const NodeArray<T>& nodeLength,
234  const NodeArray< EdgeArray<T> >& edgeLength);
235 
236  /* \brief ExpandEdge embeds all edges in the skeleton graph \a S into an
237  * existing embedding and calls recursively itself for all virtual edges
238  * in S.
239  *
240  * \param spqrTree The SPQR-tree of the treated graph.
241  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
242  * whether it was already treated by any call of ExpandEdge or not. Every
243  * \p mu should only be treated once.
244  * \param mu is a node in the SPQR-tree.
245  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
246  * in the embedding
247  * \param nodeLength is an array saving the lengths of the nodes of \p G.
248  * \param edgeLength is saving the edge lengths of all edges in each skeleton
249  * graph of all tree nodes.
250  * \param newOrder is saving for each node \p n in \p G the new adjacency
251  * list. This is an output parameter.
252  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
253  * of the skeleton of mu the adjacency entry, before which new entries have
254  * to be inserted.
255  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
256  * of the skeleton of mu the adjacency entry, before which new entries have
257  * to be inserted.
258  * \param adjExternal is an adjacency entry in the external face.
259  * \param n is only set, if ExpandEdge is called for the first time, because
260  * then there is no virtual edge which has to be expanded, but the max face
261  * has to contain a certain node \p n.
262  */
263  static void expandEdge(
264  const StaticSPQRTree& spqrTree,
265  NodeArray<bool>& treeNodeTreated,
266  const node& mu,
267  const node& leftNode,
268  const NodeArray<T>& nodeLength,
269  const NodeArray< EdgeArray<T> >& edgeLength,
270  NodeArray< List<adjEntry> >& newOrder,
271  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
272  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
273  adjEntry& adjExternal,
274  const node& n = nullptr);
275 
276  /* \brief Embeds all edges in the skeleton graph \a S of an S-node of the
277  * SPQR-tree into an existing embedding and calls recursively itself for
278  * all virtual edges in S.
279  *
280  * \param spqrTree The SPQR-tree of the treated graph.
281  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
282  * whether it was already treated by any call of ExpandEdge or not. Every
283  * \p mu should only be treated once.
284  * \param mu is a node in the SPQR-tree.
285  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
286  * in the embedding
287  * \param nodeLength is an array saving the lengths of the nodes of \p G.
288  * \param edgeLength is saving the edge lengths of all edges in each skeleton
289  * graph of all tree nodes.
290  * \param newOrder is saving for each node \p n in \p G the new adjacency
291  * list. This is an output parameter.
292  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
293  * of the skeleton of mu the adjacency entry, before which new entries have
294  * to be inserted.
295  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
296  * of the skeleton of mu the adjacency entry, before which new entries have
297  * to be inserted.
298  * \param adjExternal is an adjacency entry in the external face.
299  */
300  static void expandEdgeSNode(
301  const StaticSPQRTree& spqrTree,
302  NodeArray<bool>& treeNodeTreated,
303  const node& mu,
304  const node& leftNode,
305  const NodeArray<T>& nodeLength,
306  const NodeArray< EdgeArray<T> >& edgeLength,
307  NodeArray< List<adjEntry> >& newOrder,
308  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
309  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
310  adjEntry& adjExternal);
311 
312  /* \brief Embeds all edges in the skeleton graph \a S of an P-node of the
313  * SPQR-tree into an existing embedding and calls recursively itself for
314  * all virtual edges in S.
315  *
316  * \param spqrTree The SPQR-tree of the treated graph.
317  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
318  * whether it was already treated by any call of ExpandEdge or not. Every
319  * \p mu should only be treated once.
320  * \param mu is a node in the SPQR-tree.
321  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
322  * in the embedding
323  * \param nodeLength is an array saving the lengths of the nodes of \p G.
324  * \param edgeLength is saving the edge lengths of all edges in each skeleton
325  * graph of all tree nodes.
326  * \param newOrder is saving for each node \p n in \p G the new adjacency
327  * list. This is an output parameter.
328  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
329  * of the skeleton of mu the adjacency entry, before which new entries have
330  * to be inserted.
331  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
332  * of the skeleton of mu the adjacency entry, before which new entries have
333  * to be inserted.
334  * \param adjExternal is an adjacency entry in the external face.
335  */
336  static void expandEdgePNode(
337  const StaticSPQRTree& spqrTree,
338  NodeArray<bool>& treeNodeTreated,
339  const node& mu,
340  const node& leftNode,
341  const NodeArray<T>& nodeLength,
342  const NodeArray< EdgeArray<T> >& edgeLength,
343  NodeArray< List<adjEntry> >& newOrder,
344  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
345  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
346  adjEntry& adjExternal);
347 
348  /* \brief Embeds all edges in the skeleton graph \a S of an R-node of the
349  * SPQR-tree into an existing embedding and calls recursively itself for
350  * all virtual edges in S.
351  *
352  * \param spqrTree The SPQR-tree of the treated graph.
353  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
354  * whether it was already treated by any call of ExpandEdge or not. Every
355  * \p mu should only be treated once.
356  * \param mu is a node in the SPQR-tree.
357  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
358  * in the embedding
359  * \param nodeLength is an array saving the lengths of the nodes of \p G.
360  * \param edgeLength is saving the edge lengths of all edges in each skeleton
361  * graph of all tree nodes.
362  * \param newOrder is saving for each node \p n in \p G the new adjacency
363  * list. This is an output parameter.
364  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
365  * of the skeleton of mu the adjacency entry, before which new entries have
366  * to be inserted.
367  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
368  * of the skeleton of mu the adjacency entry, before which new entries have
369  * to be inserted.
370  * \param adjExternal is an adjacency entry in the external face.
371  * \param n is only set, if ExpandEdge is called for the first time, because
372  * then there is no virtual edge which has to be expanded, but the max face
373  * has to contain a certain node \p n.
374  */
375  static void expandEdgeRNode(
376  const StaticSPQRTree& spqrTree,
377  NodeArray<bool>& treeNodeTreated,
378  const node& mu,
379  const node& leftNode,
380  const NodeArray<T>& nodeLength,
381  const NodeArray< EdgeArray<T> >& edgeLength,
382  NodeArray< List<adjEntry> >& newOrder,
383  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
384  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
385  adjEntry& adjExternal,
386  const node& n);
387 
388  /* \brief Writes a given adjacency entry into the newOrder. If the edge
389  * belonging to ae is a virtual edge, it is expanded.
390  *
391  * \param ae is the adjacency entry which has to be expanded.
392  * \param before is the adjacency entry of the node in \p G, before
393  * which ae has to be inserted.
394  * \param spqrTree The SPQR-tree of the treated graph.
395  * \param treeNodeTreated is an array saving for each SPQR-tree node \p mu
396  * whether it was already treated by any call of ExpandEdge or not. Every
397  * \p mu should only be treated once.
398  * \param mu is a node in the SPQR-tree.
399  * \param leftNode is the node adjacent to referenceEdge, which should be "left"
400  * in the embedding
401  * \param nodeLength is an array saving the lengths of the nodes of \p G.
402  * \param edgeLength is saving the edge lengths of all edges in each skeleton
403  * graph of all tree nodes.
404  * \param newOrder is saving for each node \p n in \p G the new adjacency
405  * list. This is an output parameter.
406  * \param adjBeforeNodeArraySource is saving for the source of the reference edge
407  * of the skeleton of mu the adjacency entry, before which new entries have
408  * to be inserted.
409  * \param adjBeforeNodeArrayTarget is saving for the target of the reference edge
410  * of the skeleton of mu the adjacency entry, before which new entries have
411  * to be inserted.
412  * \param adjExternal is an adjacency entry in the external face.
413  */
414  static void adjEntryForNode(
415  adjEntry& ae,
417  const StaticSPQRTree& spqrTree,
418  NodeArray<bool>& treeNodeTreated,
419  const node& mu,
420  const node& leftNode,
421  const NodeArray<T>& nodeLength,
422  const NodeArray< EdgeArray<T> >& edgeLength,
423  NodeArray< List<adjEntry> >& newOrder,
424  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
425  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
426  adjEntry& adjExternal);
427 };
428 
429 
430 template<class T>
432  Graph& G,
433  adjEntry& adjExternal,
434  const NodeArray<T>& nodeLength,
435  const EdgeArray<T>& edgeLength,
436  const node& n /* = 0*/)
437 {
438  //Base cases (SPQR-Tree implementation would crash with these inputs):
439  OGDF_ASSERT(G.numberOfNodes() >= 2);
440  if (G.numberOfEdges() <= 2)
441  {
442  edge e = G.firstEdge();
443  adjExternal = e->adjSource();
444  return;
445  }
446 
447  //First step: calculate maximum face and edge lengths for virtual edges
448  StaticSPQRTree spqrTree(G);
449  NodeArray< EdgeArray<T> > edgeLengthSkel;
450  compute(G, nodeLength, edgeLength, &spqrTree, edgeLengthSkel);
451 
452  //Second step: Embed G
453  T biggestFace = -1;
454  node bigFaceMu;
455  if (n == nullptr)
456  {
457  for(node mu : spqrTree.tree().nodes)
458  {
459  //Expand all faces in skeleton(mu) and get size of the largest of them:
460  T sizeMu = largestFaceInSkeleton(spqrTree, mu, nodeLength, edgeLengthSkel);
461  if (sizeMu > biggestFace)
462  {
463  biggestFace = sizeMu;
464  bigFaceMu = mu;
465  }
466  }
467  }
468  else
469  {
470  node* mus = new node[n->degree()];
471  int i = 0;
472  for(adjEntry adj : n->adjEntries) {
473  edge nAdjEdge = adj->theEdge();
474  mus[i] = spqrTree.skeletonOfReal(nAdjEdge).treeNode();
475  bool alreadySeenMu = false;
476  for (int j = 0; j < i && !alreadySeenMu; j++)
477  {
478  if (mus[i] == mus[j])
479  alreadySeenMu = true;
480  }
481  if (alreadySeenMu)
482  {
483  i++;
484  continue;
485  }
486  else
487  {
488  //Expand all faces in skeleton(mu) containing n and get size of
489  //the largest of them:
490  T sizeInMu = largestFaceContainingNode(spqrTree, mus[i], n,
491  nodeLength, edgeLengthSkel);
492  if (sizeInMu > biggestFace)
493  {
494  biggestFace = sizeInMu;
495  bigFaceMu = mus[i];
496  }
497 
498  i++;
499  }
500  }
501  delete[] mus;
502  }
503 
504  bigFaceMu = spqrTree.rootTreeAt(bigFaceMu);
505 
506  NodeArray< List<adjEntry> > newOrder(G);
507  NodeArray<bool> treeNodeTreated(spqrTree.tree(), false);
509  adjExternal = nullptr;
510  NodeArray< ListIterator<adjEntry> > adjBeforeNodeArraySource(spqrTree.tree());
511  NodeArray< ListIterator<adjEntry> > adjBeforeNodeArrayTarget(spqrTree.tree());
512  expandEdge(spqrTree, treeNodeTreated, bigFaceMu, nullptr, nodeLength,
513  edgeLengthSkel, newOrder, adjBeforeNodeArraySource,
514  adjBeforeNodeArrayTarget, adjExternal, n);
515 
516  for(node v : G.nodes)
517  G.sort(v, newOrder[v]);
518 }
519 
520 
521 template<class T>
523  adjEntry& ae,
525  const StaticSPQRTree& spqrTree,
526  NodeArray<bool>& treeNodeTreated,
527  const node& mu,
528  const node& leftNode,
529  const NodeArray<T>& nodeLength,
530  const NodeArray< EdgeArray<T> >& edgeLength,
531  NodeArray< List<adjEntry> >& newOrder,
532  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
533  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
534  adjEntry& adjExternal)
535 {
536  Skeleton& S = spqrTree.skeleton(mu);
537  edge referenceEdge = S.referenceEdge();
538  if (S.isVirtual(ae->theEdge()))
539  {
540  edge twinE = S.twinEdge(ae->theEdge());
541  node twinNT = S.twinTreeNode(ae->theEdge());
542 #if 0
543  Skeleton& twinS = spqrTree.skeleton(twinNT);
544 #endif
545 
546  if (!treeNodeTreated[twinNT])
547  {
548  node m_leftNode;
549  if (ae->theEdge()->source() == leftNode)
550  m_leftNode = twinE->source();
551  else
552  m_leftNode = twinE->target();
553 
554  if (ae->theEdge()->source() == ae->theNode())
555  adjBeforeNodeArraySource[twinNT] = before;
556  else
557  adjBeforeNodeArrayTarget[twinNT] = before;
558 
559  //recursion call:
560  expandEdge(spqrTree, treeNodeTreated, twinNT, m_leftNode,
561  nodeLength, edgeLength, newOrder,
562  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
563  adjExternal);
564  }
565 
566  if (ae->theEdge() == referenceEdge)
567  {
568  if (ae->theNode() == ae->theEdge()->source())
569  {
570  ListIterator<adjEntry> tmpBefore = adjBeforeNodeArraySource[mu];
571  adjBeforeNodeArraySource[mu] = before;
572  before = tmpBefore;
573  }
574  else
575  {
576  ListIterator<adjEntry> tmpBefore = adjBeforeNodeArrayTarget[mu];
577  adjBeforeNodeArrayTarget[mu] = before;
578  before = tmpBefore;
579  }
580  }
581  else
582  {
583  if (ae->theNode() == ae->theEdge()->source())
584  before = adjBeforeNodeArraySource[twinNT];
585  else
586  before = adjBeforeNodeArrayTarget[twinNT];
587  }
588  }
589  else
590  {
591  node origNode = S.original(ae->theNode());
592  edge origEdge = S.realEdge(ae->theEdge());
593  if (origNode == origEdge->source())
594  {
595  if (!before.valid())
596  before = newOrder[origNode].pushBack(origEdge->adjSource());
597  else
598  before = newOrder[origNode].insertBefore(origEdge->adjSource(), before);
599  }
600  else
601  {
602  if (!before.valid())
603  before = newOrder[origNode].pushBack(origEdge->adjTarget());
604  else
605  before = newOrder[origNode].insertBefore(origEdge->adjTarget(), before);
606  }
607  }
608 }
609 
610 
611 template<class T>
613  const StaticSPQRTree& spqrTree,
614  NodeArray<bool>& treeNodeTreated,
615  const node& mu,
616  const node& leftNode,
617  const NodeArray<T>& nodeLength,
618  const NodeArray< EdgeArray<T> >& edgeLength,
619  NodeArray< List<adjEntry> >& newOrder,
620  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
621  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
622  adjEntry& adjExternal,
623  const node& n /*= 0*/)
624 {
625  treeNodeTreated[mu] = true;
626 
627  switch(spqrTree.typeOf(mu))
628  {
630  expandEdgeSNode(spqrTree, treeNodeTreated, mu, leftNode,
631  nodeLength, edgeLength, newOrder, adjBeforeNodeArraySource,
632  adjBeforeNodeArrayTarget, adjExternal);
633  break;
635  expandEdgePNode(spqrTree, treeNodeTreated, mu, leftNode,
636  nodeLength, edgeLength, newOrder, adjBeforeNodeArraySource,
637  adjBeforeNodeArrayTarget, adjExternal);
638  break;
640  expandEdgeRNode(spqrTree, treeNodeTreated, mu, leftNode,
641  nodeLength, edgeLength, newOrder, adjBeforeNodeArraySource,
642  adjBeforeNodeArrayTarget, adjExternal, n);
643  break;
644  default:
645  OGDF_ASSERT(false);
646  }
647 }
648 
649 
650 template<class T>
652  const StaticSPQRTree& spqrTree,
653  NodeArray<bool>& treeNodeTreated,
654  const node& mu,
655  const node& leftNode,
656  const NodeArray<T>& nodeLength,
657  const NodeArray< EdgeArray<T> >& edgeLength,
658  NodeArray< List<adjEntry> >& newOrder,
659  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
660  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
661  adjEntry& adjExternal)
662 {
663  Skeleton& S = spqrTree.skeleton(mu);
664  edge referenceEdge = S.referenceEdge();
665  adjEntry startAdjEntry = nullptr;
666  if (!leftNode)
667  {
668  for(edge e : S.getGraph().edges)
669  {
670  if (!S.isVirtual(e))
671  {
672  startAdjEntry = e->adjSource();
673  break;
674  }
675  }
676  OGDF_ASSERT(startAdjEntry);
677  }
678  else if (leftNode->firstAdj()->theEdge() == referenceEdge)
679  startAdjEntry = leftNode->lastAdj();
680  else
681  startAdjEntry = leftNode->firstAdj();
682 
683  adjEntry ae = startAdjEntry;
684  if (!adjExternal)
685  {
686  edge orgEdge = S.realEdge(ae->theEdge());
687  if (orgEdge->source() == S.original(ae->theNode()))
688  adjExternal = orgEdge->adjSource()->twin();
689  else
690  adjExternal = orgEdge->adjTarget()->twin();
691  }
692 
694  if (referenceEdge && leftNode == referenceEdge->source())
695  before = adjBeforeNodeArraySource[mu];
696  else if (referenceEdge)
697  before = adjBeforeNodeArrayTarget[mu];
698  ListIterator<adjEntry> beforeSource;
699 
700  bool firstStep = true;
701  while (firstStep || ae != startAdjEntry)
702  {
703  //first treat ae with ae->theNode() is left node, then treat its twin:
704  node m_leftNode = ae->theNode();
705 
706  if (ae->theEdge() == referenceEdge)
707  {
708  if (ae->theNode() == referenceEdge->source())
709  adjBeforeNodeArraySource[mu] = before;
710  else
711  adjBeforeNodeArrayTarget[mu] = before;
712  }
713  else
714  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
715  m_leftNode, nodeLength, edgeLength, newOrder,
716  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
717  adjExternal);
718 
719  if (firstStep)
720  {
721  beforeSource = before;
722  firstStep = false;
723  }
724 
725  ae = ae->twin();
726  before = nullptr;
727  if (ae->theEdge() == referenceEdge)
728  {
729  if (ae->theNode() == referenceEdge->source())
730  adjBeforeNodeArraySource[mu] = beforeSource;
731  else
732  adjBeforeNodeArrayTarget[mu] = beforeSource;
733  }
734  else
735  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
736  m_leftNode, nodeLength, edgeLength, newOrder,
737  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
738  adjExternal);
739 
740  //set new adjacency entry pair (ae and its twin):
741  if (ae->theNode()->firstAdj() == ae)
742  ae = ae->theNode()->lastAdj();
743  else
744  ae = ae->theNode()->firstAdj();
745  }
746 }
747 
748 
749 template<class T>
751  const StaticSPQRTree& spqrTree,
752  NodeArray<bool>& treeNodeTreated,
753  const node& mu,
754  const node& leftNode,
755  const NodeArray<T>& nodeLength,
756  const NodeArray< EdgeArray<T> >& edgeLength,
757  NodeArray< List<adjEntry> >& newOrder,
758  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
759  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
760  adjEntry& adjExternal)
761 {
762  //Choose face defined by virtual edge and the longest edge different from it.
763  Skeleton& S = spqrTree.skeleton(mu);
764  edge referenceEdge = S.referenceEdge();
765  edge altReferenceEdge = nullptr;
766 
767  node m_leftNode = leftNode;
768  if (!m_leftNode) {
769  List<node> nodeList;
770  S.getGraph().allNodes(nodeList);
771  m_leftNode = *(nodeList.begin());
772  }
773  node m_rightNode = m_leftNode->firstAdj()->twinNode();
774 
775  if (!referenceEdge)
776  {
777  for(edge e : S.getGraph().edges)
778  {
779  if (!S.isVirtual(e))
780  {
781  altReferenceEdge = e;
782  edge orgEdge = S.realEdge(e);
783  if (orgEdge->source() == S.original(m_leftNode))
784  adjExternal = orgEdge->adjSource();
785  else
786  adjExternal = orgEdge->adjTarget();
787 
788  break;
789  }
790  }
791  }
792 
793  edge longestEdge = nullptr;
794  for(edge e : S.getGraph().edges)
795  {
796  if (e == referenceEdge || e == altReferenceEdge)
797  continue;
798  if (!longestEdge || edgeLength[mu][e] > edgeLength[mu][longestEdge])
799  longestEdge = e;
800  }
801 
802  List<edge> rightEdgeOrder;
803  ListIterator<adjEntry> beforeAltRefEdge;
804 
805  //begin with left node and longest edge:
806  for (int i = 0; i < 2; ++i) {
808  node n;
809  if (i == 0)
810  n = m_leftNode;
811  else
812  {
813  n = m_rightNode;
814  before = beforeAltRefEdge;
815  }
816 
817  if (referenceEdge) {
818  if (n == referenceEdge->source())
819  before = adjBeforeNodeArraySource[mu];
820  else
821  before = adjBeforeNodeArrayTarget[mu];
822  }
823 
824  List<edge> edgeList;
825  S.getGraph().allEdges(edgeList);
826  adjEntry ae;
827 
828  //if left node, longest edge at first:
829  if (i == 0) {
830  if (longestEdge->source() == n)
831  ae = longestEdge->adjSource();
832  else
833  ae = longestEdge->adjTarget();
834 
835  if (referenceEdge && S.isVirtual(longestEdge))
836  {
837  node nu = S.twinTreeNode(longestEdge);
838  if (longestEdge->source() == n)
839  {
840  if (referenceEdge->source() == n)
841  adjBeforeNodeArrayTarget[nu] = adjBeforeNodeArrayTarget[mu];
842  else
843  adjBeforeNodeArrayTarget[nu] = adjBeforeNodeArraySource[mu];
844  }
845  else
846  {
847  if (referenceEdge->source() == n)
848  adjBeforeNodeArraySource[nu] = adjBeforeNodeArrayTarget[mu];
849  else
850  adjBeforeNodeArraySource[nu] = adjBeforeNodeArraySource[mu];
851  }
852  }
853 
854  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
855  m_leftNode, nodeLength, edgeLength, newOrder,
856  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
857  adjExternal);
858  }
859 
860  //all edges except reference edge and longest edge:
861  if (i == 0)
862  {
863  //all virtual edges
864  for (edge e : edgeList)
865  {
866  if (e == referenceEdge || e == longestEdge || e == altReferenceEdge || !S.isVirtual(e))
867  continue;
868 
869  node nu = S.twinTreeNode(e);
870  if (referenceEdge != nullptr && e->source() == n)
871  {
872  if (referenceEdge->source() == n)
873  adjBeforeNodeArrayTarget[nu] = adjBeforeNodeArrayTarget[mu];
874  else
875  adjBeforeNodeArrayTarget[nu] = adjBeforeNodeArraySource[mu];
876  }
877  else if (referenceEdge) {
878  if (referenceEdge->source() == n)
879  adjBeforeNodeArraySource[nu] = adjBeforeNodeArrayTarget[mu];
880  else
881  adjBeforeNodeArraySource[nu] = adjBeforeNodeArraySource[mu];
882  }
883 
884  rightEdgeOrder.pushFront(e);
885 
886  if (e->source() == n)
887  ae = e->adjSource();
888  else
889  ae = e->adjTarget();
890 
891  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
892  m_leftNode, nodeLength, edgeLength, newOrder,
893  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
894  adjExternal);
895  }
896 
897  //all real edges
898  for (edge e : edgeList)
899  {
900  if (e == referenceEdge || e == longestEdge || e == altReferenceEdge || S.isVirtual(e))
901  continue;
902 
903  rightEdgeOrder.pushFront(e);
904 
905  if (e->source() == n)
906  ae = e->adjSource();
907  else
908  ae = e->adjTarget();
909 
910  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
911  m_leftNode, nodeLength, edgeLength, newOrder,
912  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
913  adjExternal);
914  }
915  }
916  else
917  {
918  for (edge e : rightEdgeOrder)
919  {
920  if (e->source() == n)
921  ae = e->adjSource();
922  else
923  ae = e->adjTarget();
924 
925  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
926  m_leftNode, nodeLength, edgeLength, newOrder,
927  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
928  adjExternal);
929  }
930  }
931 
932  //if not left node, longest edge:
933  if (i == 1)
934  {
935  if (longestEdge->source() == n)
936  ae = longestEdge->adjSource();
937  else
938  ae = longestEdge->adjTarget();
939 
940  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
941  m_leftNode, nodeLength, edgeLength, newOrder,
942  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
943  adjExternal);
944  }
945 
946  //(alternative) reference edge at last:
947  if (referenceEdge) {
948  if (n == referenceEdge->source())
949  adjBeforeNodeArraySource[mu] = before;
950  else
951  adjBeforeNodeArrayTarget[mu] = before;
952  }
953  else
954  {
955  node newLeftNode;
956  if (i == 0)
957  newLeftNode = m_leftNode->firstAdj()->twinNode();
958  else
959  newLeftNode = m_leftNode;
960 
961  if (altReferenceEdge->source() == n)
962  ae = altReferenceEdge->adjSource();
963  else
964  ae = altReferenceEdge->adjTarget();
965 
966  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
967  newLeftNode, nodeLength, edgeLength, newOrder,
968  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
969  adjExternal);
970 
971  if (i == 0 && S.isVirtual(altReferenceEdge))
972  {
973  node nu = S.twinTreeNode(altReferenceEdge);
974  if (altReferenceEdge->source() == n)
975  beforeAltRefEdge = adjBeforeNodeArrayTarget[nu];
976  else
977  beforeAltRefEdge = adjBeforeNodeArraySource[nu];
978  }
979  }
980  }
981 }
982 
983 
984 template<class T>
986  const StaticSPQRTree& spqrTree,
987  NodeArray<bool>& treeNodeTreated,
988  const node& mu,
989  const node& leftNode,
990  const NodeArray<T>& nodeLength,
991  const NodeArray< EdgeArray<T> >& edgeLength,
992  NodeArray< List<adjEntry> >& newOrder,
993  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArraySource,
994  NodeArray< ListIterator<adjEntry> >& adjBeforeNodeArrayTarget,
995  adjEntry& adjExternal,
996  const node& n /* = 0 */)
997 {
998  Skeleton& S = spqrTree.skeleton(mu);
999  edge referenceEdge = S.referenceEdge();
1000 
1001  //compute biggest face containing the reference edge:
1002  face maxFaceContEdge = nullptr;
1003  List<node> maxFaceNodes;
1004  planarEmbed(S.getGraph());
1005  CombinatorialEmbedding combinatorialEmbedding(S.getGraph());
1006  T bigFaceSize = -1;
1007  adjEntry m_adjExternal = nullptr;
1008  for(face f : combinatorialEmbedding.faces)
1009  {
1010  bool containsVirtualEdgeOrN = false;
1011  adjEntry this_m_adjExternal = nullptr;
1012  T sizeOfFace = 0;
1013  List<node> faceNodes;
1014  for(adjEntry ae : f->entries)
1015  {
1016  faceNodes.pushBack(ae->theNode());
1017  if ((n == nullptr && (ae->theEdge() == referenceEdge || !referenceEdge))
1018  || S.original(ae->theNode()) == n) {
1019  containsVirtualEdgeOrN = true;
1020  if (referenceEdge)
1021  this_m_adjExternal = ae;
1022  }
1023 
1024  if (!referenceEdge && !S.isVirtual(ae->theEdge()))
1025  this_m_adjExternal = ae;
1026 
1027  sizeOfFace += edgeLength[mu][ae->theEdge()]
1028  + nodeLength[S.original(ae->theNode())];
1029  }
1030 
1031  if (containsVirtualEdgeOrN && this_m_adjExternal && sizeOfFace > bigFaceSize) {
1032  maxFaceNodes = faceNodes;
1033  bigFaceSize = sizeOfFace;
1034  maxFaceContEdge = f;
1035  m_adjExternal = this_m_adjExternal;
1036  }
1037  }
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  OGDF_ASSERT(maxFaceContEdge);
1048  adjEntry adjMaxFace = maxFaceContEdge->firstAdj();
1049 
1050  //if embedding is mirror symmetrical embedding of desired embedding,
1051  //invert adjacency list of all nodes:
1052  if (referenceEdge) {
1053  //successor of adjEntry of virtual edge in adjacency list of leftNode:
1054  adjEntry succ_virtualEdge_leftNode;
1055  if (leftNode == referenceEdge->source())
1056  succ_virtualEdge_leftNode = referenceEdge->adjSource()->succ();
1057  else
1058  succ_virtualEdge_leftNode = referenceEdge->adjTarget()->succ();
1059  if (!succ_virtualEdge_leftNode)
1060  succ_virtualEdge_leftNode = leftNode->firstAdj();
1061 
1062  bool succVELNAEInExtFace = false;
1063  for(adjEntry aeExtFace : maxFaceContEdge->entries)
1064  {
1065  if (aeExtFace->theEdge() == succ_virtualEdge_leftNode->theEdge())
1066  {
1067  succVELNAEInExtFace = true;
1068  break;
1069  }
1070  }
1071 
1072  if (!succVELNAEInExtFace)
1073  {
1074  for(node v : S.getGraph().nodes)
1075  {
1076  List<adjEntry> newAdjOrder;
1077  for (adjEntry ae = v->firstAdj(); ae; ae = ae->succ())
1078  newAdjOrder.pushFront(ae);
1079  S.getGraph().sort(v, newAdjOrder);
1080  }
1081  adjMaxFace = adjMaxFace->twin();
1082  }
1083  }
1084 
1085  NodeArray<bool> nodeTreated(S.getGraph(), false);
1086  adjEntry start_ae;
1087  if (referenceEdge) {
1088  start_ae = adjMaxFace;
1089  do
1090  {
1091  if (start_ae->theEdge() == referenceEdge)
1092  {
1093  start_ae = start_ae->faceCycleSucc();
1094  break;
1095  }
1096  start_ae = start_ae->faceCycleSucc();
1097  } while(start_ae != adjMaxFace);
1098  }
1099  else
1100  start_ae = adjMaxFace;
1101 
1102  //For every edge a buffer saving adjacency entries written in embedding step
1103  //for nodes on the maximum face, needed in step for other nodes.
1104  EdgeArray< List<adjEntry> > buffer(S.getGraph());
1105 
1106  bool firstStep = true;
1107  bool after_start_ae = true;
1108  for (adjEntry ae = start_ae;
1109  firstStep || ae != start_ae;
1110  after_start_ae = after_start_ae && ae->succ(),
1111  ae = after_start_ae ? ae->faceCycleSucc()
1112  : (!ae->faceCycleSucc() ? adjMaxFace : ae->faceCycleSucc()))
1113  {
1114  firstStep = false;
1115 #if 0
1116  node nodeG = S.original(ae->theNode());
1117 #endif
1118  nodeTreated[ae->theNode()] = true;
1119 
1120  //copy adjacency list of nodes into newOrder:
1122  edge vE = (ae->theEdge() == referenceEdge) ? referenceEdge : ae->theEdge();
1123  node nu = (ae->theEdge() == referenceEdge) ? mu : S.twinTreeNode(ae->theEdge());
1124  if (S.isVirtual(vE))
1125  {
1126  if (ae->theNode() == vE->source())
1127  before = adjBeforeNodeArraySource[nu];
1128  else
1129  before = adjBeforeNodeArrayTarget[nu];
1130  }
1131 
1132  bool after_ae = true;
1133  adjEntry m_start_ae;
1134  if (ae->theEdge() == referenceEdge)
1135  {
1136  if (ae->succ())
1137  m_start_ae = ae->succ();
1138  else
1139  m_start_ae = ae->theNode()->firstAdj();
1140  }
1141  else
1142  m_start_ae = ae;
1143 
1144  for (adjEntry aeN = m_start_ae;
1145  after_ae || aeN != m_start_ae;
1146  after_ae = after_ae && aeN->succ(),
1147  aeN = after_ae ? aeN->succ() : (!aeN->succ() ? ae->theNode()->firstAdj() : aeN->succ())
1148  )
1149  {
1150  node m_leftNode = nullptr;
1151  if (S.isVirtual(aeN->theEdge()) && aeN->theEdge() != referenceEdge)
1152  {
1153  //Compute left node of aeN->theNode(). First get adjacency entry in ext. face
1154  //(if edge is in ext. face) and compare face cycle successor with successor
1155  //in node adjacency list. If it is the same, it is the right node, otherwise
1156  //the left.
1157  adjEntry aeExtFace = nullptr;
1158  bool succInExtFace = false;
1159  bool aeNInExtFace = false;
1160  adjEntry aeNSucc = (aeN->succ()) ? aeN->succ() : ae->theNode()->firstAdj();
1161  aeExtFace = adjMaxFace;
1162  do
1163  {
1164  if (aeExtFace->theEdge() == aeNSucc->theEdge())
1165  {
1166  succInExtFace = true;
1167  if (aeNInExtFace)
1168  break;
1169  }
1170  if (aeExtFace->theEdge() == aeN->theEdge())
1171  {
1172  aeNInExtFace = true;
1173  if (succInExtFace)
1174  break;
1175  }
1176  aeExtFace = aeExtFace->faceCycleSucc();
1177  } while(aeExtFace != adjMaxFace);
1178  if (aeNInExtFace && succInExtFace)
1179  m_leftNode = aeN->twinNode();
1180  else
1181  m_leftNode = aeN->theNode();
1182 
1183  node twinTN = S.twinTreeNode(aeN->theEdge());
1184  if (referenceEdge) {
1185  if (aeN->theEdge()->source() == aeN->theNode())
1186  {
1187  if (aeN->theEdge()->target() == referenceEdge->source())
1188  adjBeforeNodeArrayTarget[twinTN] = adjBeforeNodeArraySource[mu];
1189  else if (aeN->theEdge()->target() == referenceEdge->target())
1190  adjBeforeNodeArrayTarget[twinTN] = adjBeforeNodeArrayTarget[mu];
1191  }
1192  else
1193  {
1194  if (aeN->theEdge()->source() == referenceEdge->source())
1195  adjBeforeNodeArraySource[twinTN] = adjBeforeNodeArraySource[mu];
1196  else if (aeN->theEdge()->source() == referenceEdge->target())
1197  adjBeforeNodeArraySource[twinTN] = adjBeforeNodeArrayTarget[mu];
1198  }
1199  }
1200  }
1201 
1202  adjEntryForNode(aeN, before, spqrTree, treeNodeTreated, mu,
1203  m_leftNode, nodeLength, edgeLength, newOrder,
1204  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
1205  adjExternal);
1206 
1207  //if the other node adjacent to the current treated edge is not in the
1208  //max face, put written edges into an buffer and clear the adjacency
1209  //list of that node.
1210  if (!maxFaceNodes.search(aeN->twinNode()).valid())
1211  {
1212  node orig_aeN_twin_theNode = S.original(aeN->twinNode());
1213  buffer[aeN->theEdge()] = newOrder[orig_aeN_twin_theNode];
1214  newOrder[orig_aeN_twin_theNode].clear();
1215  }
1216  }
1217  }
1218 
1219  //Simple copy of not treated node's adjacency lists (internal nodes). Setting
1220  //of left node not necessary, because all nodes are not in external face.
1221  for(node v : S.getGraph().nodes)
1222  {
1223  if (nodeTreated[v])
1224  continue;
1225 
1226  node v_original = S.original(v);
1227  nodeTreated[v] = true;
1229  for (adjEntry ae = v->firstAdj(); ae; ae = ae->succ())
1230  {
1231  if (buffer[ae->theEdge()].empty())
1232  {
1233  adjEntryForNode(ae, before, spqrTree, treeNodeTreated, mu,
1234  ae->theNode(), nodeLength, edgeLength, newOrder,
1235  adjBeforeNodeArraySource, adjBeforeNodeArrayTarget,
1236  adjExternal);
1237 
1238  if (!nodeTreated[ae->twinNode()])
1239  {
1240  node orig_ae_twin_theNode = S.original(ae->twinNode());
1241  buffer[ae->theEdge()] = newOrder[orig_ae_twin_theNode];
1242  newOrder[orig_ae_twin_theNode].clear();
1243  }
1244  }
1245  else
1246  {
1247  buffer[ae->theEdge()].reverse();
1248  for (ListIterator<adjEntry> it = buffer[ae->theEdge()].begin(); it.valid(); ++it)
1249  {
1250  if (!before.valid())
1251  before = newOrder[v_original].pushFront(*it);
1252  else
1253  before = newOrder[v_original].insertBefore(*it, before);
1254  }
1255  }
1256  }
1257  }
1258 }
1259 
1260 
1261 template<class T>
1263  const Graph& G,
1264  const NodeArray<T>& nodeLength,
1265  const EdgeArray<T>& edgeLength,
1266  StaticSPQRTree *spqrTree,
1267  NodeArray< EdgeArray<T> >& edgeLengthSkel)
1268 {
1269  //base cases (SPQR-tree implementation would crash for such graphs):
1270  if (G.numberOfNodes() <= 1 || G.numberOfEdges() <= 2)
1271  return;
1272 
1273  //set length for all real edges in skeletons to length of the original edge
1274  //and initialize edge lengths for virtual edges with 0:
1275  edgeLengthSkel.init(spqrTree->tree());
1276  for(node v : spqrTree->tree().nodes)
1277  {
1278  edgeLengthSkel[v].init(spqrTree->skeleton(v).getGraph());
1279  for(edge e : spqrTree->skeleton(v).getGraph().edges)
1280  {
1281  if (spqrTree->skeleton(v).isVirtual(e))
1282  edgeLengthSkel[v][e] = 0;
1283  else
1284  edgeLengthSkel[v][e] = edgeLength[spqrTree->skeleton(v).realEdge(e)];
1285  }
1286  }
1287 
1288  //set component-length for all non-reference edges:
1289  bottomUpTraversal(*spqrTree, spqrTree->rootNode(), nodeLength, edgeLengthSkel);
1290  //set component length for all reference edges:
1291  topDownTraversal(*spqrTree, spqrTree->rootNode(), nodeLength, edgeLengthSkel);
1292 }
1293 
1294 
1295 template<class T>
1297  const Graph& G,
1298  const NodeArray<T>& nodeLength,
1299  const EdgeArray<T>& edgeLength)
1300 {
1301  //base cases (SPQR-tree implementation would crash for such graphs):
1302  OGDF_ASSERT(G.numberOfNodes() >= 2);
1303  if (G.numberOfEdges() == 1)
1304  {
1305  edge e = G.firstEdge();
1306  return edgeLength[e] + nodeLength[e->source()]+ nodeLength[e->target()];
1307  }
1308  if (G.numberOfEdges() == 2)
1309  {
1310  edge e1 = G.firstEdge();
1311  edge e2 = e1->succ();
1312  return edgeLength[e1] + edgeLength[e2] + nodeLength[e1->source()] + nodeLength[e1->target()];
1313  }
1314  StaticSPQRTree spqrTree(G);
1315  NodeArray< EdgeArray<T> > edgeLengthSkel;
1316  return computeSize(G, nodeLength, edgeLength, spqrTree, edgeLengthSkel);
1317 }
1318 
1319 
1320 template<class T>
1322  const Graph& G,
1323  const NodeArray<T>& nodeLength,
1324  const EdgeArray<T>& edgeLength,
1325  StaticSPQRTree *spqrTree,
1326  NodeArray< EdgeArray<T> >& edgeLengthSkel)
1327 {
1328  //base cases (SPQR-tree implementation would crash for such graphs):
1329  OGDF_ASSERT(G.numberOfNodes() >= 2);
1330  if (G.numberOfEdges() == 1)
1331  {
1332  edge e = G.firstEdge();
1333  return edgeLength[e] + nodeLength[e->source()]+ nodeLength[e->target()];
1334  }
1335  if (G.numberOfEdges() == 2)
1336  {
1337  edge e1 = G.firstEdge();
1338  edge e2 = e1->succ();
1339  return edgeLength[e1] + edgeLength[e2] + nodeLength[e1->source()] + nodeLength[e1->target()];
1340  }
1341 
1342  //set length for all real edges in skeletons to length of the original edge
1343  //and initialize edge lengths for virtual edges with 0:
1344  edgeLengthSkel.init(spqrTree->tree());
1345  for(node v : spqrTree->tree().nodes)
1346  {
1347  edgeLengthSkel[v].init(spqrTree->skeleton(v).getGraph());
1348  for(edge e : spqrTree->skeleton(v).getGraph().edges)
1349  {
1350  if (spqrTree->skeleton(v).isVirtual(e))
1351  edgeLengthSkel[v][e] = 0;
1352  else
1353  edgeLengthSkel[v][e] = edgeLength[spqrTree->skeleton(v).realEdge(e)];
1354  }
1355  }
1356 
1357  //set component-length for all non-reference edges:
1358  bottomUpTraversal(*spqrTree, spqrTree->rootNode(), nodeLength, edgeLengthSkel);
1359  //set component length for all reference edges:
1360  topDownTraversal(*spqrTree, spqrTree->rootNode(), nodeLength, edgeLengthSkel);
1361 
1362  T biggestFace = -1;
1363  for(node mu : spqrTree->tree().nodes)
1364  {
1365  //Expand all faces in skeleton(mu) and get size of the largest of them:
1366  T sizeMu = largestFaceInSkeleton(*spqrTree, mu, nodeLength, edgeLengthSkel);
1367  if (sizeMu > biggestFace)
1368  biggestFace = sizeMu;
1369  }
1370 
1371  return biggestFace;
1372 }
1373 
1374 
1375 template<class T>
1377  const Graph& G,
1378  const node& n,
1379  const NodeArray<T>& nodeLength,
1380  const EdgeArray<T>& edgeLength)
1381 {
1382  //base cases (SPQR-tree implementation would crash for such graphs):
1383  OGDF_ASSERT(G.numberOfNodes() >= 2);
1384  if (G.numberOfEdges() == 1)
1385  {
1386  edge e = G.firstEdge();
1387  return edgeLength[e] + nodeLength[e->source()] + nodeLength[e->target()];
1388  }
1389  if (G.numberOfEdges() == 2)
1390  {
1391  edge e1 = G.firstEdge();
1392  edge e2 = e1->succ();
1393  return edgeLength[e1] + edgeLength[e2] + nodeLength[e1->source()] + nodeLength[e1->target()];
1394  }
1395  StaticSPQRTree spqrTree(G);
1396  NodeArray< EdgeArray<T> > edgeLengthSkel;
1397  compute(G, nodeLength, edgeLength, &spqrTree, edgeLengthSkel);
1398  return computeSize(G, n, nodeLength, edgeLength, &spqrTree, edgeLengthSkel);
1399 }
1400 
1401 
1402 template<class T>
1404  const Graph& G,
1405  const node& n,
1406  const NodeArray<T>& nodeLength,
1407  const EdgeArray<T>& edgeLength,
1408  StaticSPQRTree *spqrTree)
1409 {
1410  NodeArray< EdgeArray<T> > edgeLengthSkel;
1411  compute(G, nodeLength, edgeLength, spqrTree, edgeLengthSkel);
1412  return computeSize(G, n, nodeLength, edgeLength, spqrTree, edgeLengthSkel);
1413 }
1414 
1415 
1416 template<class T>
1418  const Graph& G,
1419  const node& n,
1420  const NodeArray<T>& nodeLength,
1421  const EdgeArray<T>& edgeLength,
1422  StaticSPQRTree *spqrTree,
1423  const NodeArray< EdgeArray<T> >& edgeLengthSkel)
1424 {
1425  //base cases (SPQR-tree implementation would crash for such graphs):
1426  OGDF_ASSERT(G.numberOfNodes() >= 2);
1427  if (G.numberOfEdges() == 1)
1428  {
1429  edge e = G.firstEdge();
1430  return edgeLength[e] + nodeLength[e->source()] + nodeLength[e->target()];
1431  }
1432  else if (G.numberOfEdges() == 2)
1433  {
1434  edge e1 = G.firstEdge();
1435  edge e2 = e1->succ();
1436  return edgeLength[e1] + edgeLength[e2] + nodeLength[e1->source()] + nodeLength[e1->target()];
1437  }
1438 
1439  node* mus = new node[n->degree()];
1440  int i = 0;
1441  T biggestFace = -1;
1442  for(adjEntry adj : n->adjEntries) {
1443  mus[i] = spqrTree->skeletonOfReal(adj->theEdge()).treeNode();
1444  bool alreadySeenMu = false;
1445  for (int j = 0; j < i && !alreadySeenMu; j++)
1446  {
1447  if (mus[i] == mus[j])
1448  alreadySeenMu = true;
1449  }
1450  if (alreadySeenMu)
1451  {
1452  i++;
1453  continue;
1454  }
1455  else
1456  {
1457  //Expand all faces in skeleton(mu) containing n and get size of the largest of them:
1458  T sizeInMu = largestFaceContainingNode(*spqrTree, mus[i], n, nodeLength, edgeLengthSkel);
1459  if (sizeInMu > biggestFace)
1460  biggestFace = sizeInMu;
1461 
1462  i++;
1463  }
1464  }
1465  delete[] mus;
1466 
1467  return biggestFace;
1468 }
1469 
1470 
1471 template<class T>
1473  StaticSPQRTree& spqrTree,
1474  const node& mu,
1475  const NodeArray<T>& nodeLength,
1476  NodeArray< EdgeArray<T> >& edgeLength)
1477 {
1478  //Recursion:
1479  for(adjEntry adj : mu->adjEntries)
1480  {
1481  edge ed = adj->theEdge();
1482  if (ed->source() == mu)
1483  bottomUpTraversal(spqrTree, ed->target(), nodeLength, edgeLength);
1484  }
1485 
1486  for(edge e : spqrTree.skeleton(mu).getGraph().edges)
1487  {
1488  //do not treat real edges here and do not treat reference edges:
1489  if (!spqrTree.skeleton(mu).isVirtual(e) || e == spqrTree.skeleton(mu).referenceEdge())
1490  continue;
1491 
1492  //pertinent node of e in the SPQR-tree:
1493  node nu = spqrTree.skeleton(mu).twinTreeNode(e);
1494  //reference edge of nu (virtual edge in nu associated with mu):
1495  edge er = spqrTree.skeleton(nu).referenceEdge();
1496  //sum of the lengths of the two poles of mu:
1497  node refEdgeSource = spqrTree.skeleton(nu).referenceEdge()->source();
1498  node origRefEdgeSource = spqrTree.skeleton(nu).original(refEdgeSource);
1499  node refEdgeTarget = spqrTree.skeleton(nu).referenceEdge()->target();
1500  node origRefEdgeTarget = spqrTree.skeleton(nu).original(refEdgeTarget);
1501  T ell = nodeLength[origRefEdgeSource] + nodeLength[origRefEdgeTarget];
1502 
1503  if (spqrTree.typeOf(nu) == SPQRTree::NodeType::SNode)
1504  {
1505  //size of a face in skeleton(nu) minus ell
1506  T sizeOfFace = 0;
1507  for(node nS : spqrTree.skeleton(nu).getGraph().nodes)
1508  sizeOfFace += nodeLength[spqrTree.skeleton(nu).original(nS)];
1509 
1510  for(edge eS : spqrTree.skeleton(nu).getGraph().edges)
1511  sizeOfFace += edgeLength[nu][eS];
1512 
1513  edgeLength[mu][e] = sizeOfFace - ell;
1514  }
1515  else if (spqrTree.typeOf(nu) == SPQRTree::NodeType::PNode)
1516  {
1517  //length of the longest edge different from er in skeleton(nu)
1518  edge longestEdge = nullptr;
1519  for(edge ed : spqrTree.skeleton(nu).getGraph().edges)
1520  {
1521  if (ed != er
1522  && (!longestEdge || edgeLength[nu][ed] > edgeLength[nu][longestEdge])) {
1523  longestEdge = ed;
1524  }
1525  }
1526  edgeLength[mu][e] = edgeLength[nu][longestEdge];
1527  }
1528  else if (spqrTree.typeOf(nu) == SPQRTree::NodeType::RNode)
1529  {
1530  //size of the largest face containing er in skeleton(nu) minus ell
1531  //Calculate an embedding of the graph (it exists only two which are
1532  //mirror-symmetrical):
1533  planarEmbed(spqrTree.skeleton(nu).getGraph());
1534  CombinatorialEmbedding combinatorialEmbedding(spqrTree.skeleton(nu).getGraph());
1535  T biggestFaceSize = -1;
1536  for(face f : combinatorialEmbedding.faces)
1537  {
1538  T sizeOfFace = 0;
1539  bool containsEr = false;
1540  for(adjEntry ae : f->entries)
1541  {
1542  if (ae->theEdge() == er)
1543  containsEr = true;
1544  sizeOfFace += edgeLength[nu][ae->theEdge()]
1545  + nodeLength[spqrTree.skeleton(nu).original(ae->theNode())];
1546  }
1547 
1548  if (containsEr && sizeOfFace > biggestFaceSize)
1549  biggestFaceSize = sizeOfFace;
1550  }
1551 
1552  edgeLength[mu][e] = biggestFaceSize - ell;
1553  }
1554  else //should never happen
1555  edgeLength[mu][e] = 1;
1556  }
1557 }
1558 
1559 
1560 template<class T>
1562  StaticSPQRTree& spqrTree,
1563  const node& mu,
1564  const NodeArray<T>& nodeLength,
1565  NodeArray< EdgeArray<T> >& edgeLength)
1566 {
1567  //S: skeleton of mu
1568  Skeleton& S = spqrTree.skeleton(mu);
1569 
1570  //Get all reference edges of the children nu of mu and set their component length:
1571  for(adjEntry adj : mu->adjEntries) {
1572  edge ed = adj->theEdge();
1573  if (ed->source() != mu)
1574  continue;
1575 
1576  node nu = ed->target();
1577  edge referenceEdgeOfNu = spqrTree.skeleton(nu).referenceEdge();
1578  edge eSnu = spqrTree.skeleton(nu).twinEdge(referenceEdgeOfNu);
1579  if (spqrTree.typeOf(mu) == SPQRTree::NodeType::SNode)
1580  {
1581  //Let L be the sum of the length of all vertices and edges in S. The component
1582  //length of the reference edge of nu is L minus the length of e_{S, nu} minus
1583  //the lengths of the two vertices incident to e_{S, nu}.
1584  T L = 0;
1585  for(edge ed2 : S.getGraph().edges)
1586  L += edgeLength[mu][ed2];
1587  for(node no : S.getGraph().nodes)
1588  L += nodeLength[S.original(no)];
1589 
1590  edgeLength[nu][referenceEdgeOfNu] =
1591  L - edgeLength[mu][eSnu] - nodeLength[S.original(eSnu->source())] - nodeLength[S.original(eSnu->target())];
1592  }
1593  else if (spqrTree.typeOf(mu) == SPQRTree::NodeType::PNode)
1594  {
1595  //The component length of the reference edge of nu is the length of the longest
1596  //edge in S different from e_{S, nu}.
1597  edge longestEdge = nullptr;
1598  for(edge ed2 : S.getGraph().edges)
1599  {
1600  if (ed2 != eSnu && (!longestEdge || edgeLength[mu][ed2] > edgeLength[mu][longestEdge])) {
1601  longestEdge = ed2;
1602  }
1603  }
1604  edgeLength[nu][referenceEdgeOfNu] = edgeLength[mu][longestEdge];
1605  }
1606  else if (spqrTree.typeOf(mu) == SPQRTree::NodeType::RNode)
1607  {
1608  //Let f be the largest face in S containing e_{S, nu}. The component length of
1609  //the reference edge of nu is the size of f minus the length of e_{S, nu} minus
1610  //the lengths of the two vertices incident to e_{S, nu}.
1611 
1612  //Calculate an embedding of the graph (it exists only two which are
1613  //mirror-symmetrical):
1614  planarEmbed(S.getGraph());
1615  CombinatorialEmbedding combinatorialEmbedding(S.getGraph());
1616  T biggestFaceSize = -1;
1617  for(face f : combinatorialEmbedding.faces)
1618  {
1619  T sizeOfFace = 0;
1620  bool containsESnu = false;
1621  for(adjEntry ae : f->entries)
1622  {
1623  if (ae->theEdge() == eSnu)
1624  containsESnu = true;
1625  sizeOfFace += edgeLength[mu][ae->theEdge()]
1626  + nodeLength[S.original(ae->theNode())];
1627  }
1628  if (containsESnu && sizeOfFace > biggestFaceSize)
1629  biggestFaceSize = sizeOfFace;
1630  }
1631  edgeLength[nu][referenceEdgeOfNu] =
1632  biggestFaceSize - edgeLength[mu][eSnu]
1633  - nodeLength[S.original(eSnu->source())]
1634  - nodeLength[S.original(eSnu->target())];
1635  }
1636  else //should never happen
1637  edgeLength[nu][referenceEdgeOfNu] = 0;
1638 
1639  //Recursion:
1640  topDownTraversal(spqrTree, ed->target(), nodeLength, edgeLength);
1641  }
1642 }
1643 
1644 
1645 template<class T>
1647  const StaticSPQRTree& spqrTree,
1648  const node& mu,
1649  const node& n,
1650  const NodeArray<T>& nodeLength,
1651  const NodeArray< EdgeArray<T> >& edgeLength)
1652 {
1653  bool containsARealEdge = false;
1654  if (spqrTree.typeOf(mu) == SPQRTree::NodeType::RNode)
1655  {
1656  //The largest face containing n is the largest face containg n in any embedding of S.
1657  planarEmbed(spqrTree.skeleton(mu).getGraph());
1658  CombinatorialEmbedding combinatorialEmbedding(spqrTree.skeleton(mu).getGraph());
1659  T biggestFaceSize = -1;
1660  for(face f : combinatorialEmbedding.faces)
1661  {
1662  T sizeOfFace = 0;
1663  bool containingN = false;
1664  bool m_containsARealEdge = false;
1665  for(adjEntry ae : f->entries)
1666  {
1667  if (spqrTree.skeleton(mu).original(ae->theNode()) == n)
1668  containingN = true;
1669  if (!spqrTree.skeleton(mu).isVirtual(ae->theEdge()))
1670  m_containsARealEdge = true;
1671  sizeOfFace += edgeLength[mu][ae->theEdge()];
1672  sizeOfFace += nodeLength[spqrTree.skeleton(mu).original(ae->theNode())];
1673  }
1674  if (containingN && sizeOfFace > biggestFaceSize)
1675  {
1676  biggestFaceSize = sizeOfFace;
1677  containsARealEdge = m_containsARealEdge;
1678  }
1679  }
1680 
1681  if (!containsARealEdge)
1682  return -1;
1683  return biggestFaceSize;
1684  }
1685  else if (spqrTree.typeOf(mu) == SPQRTree::NodeType::PNode)
1686  {
1687  //Find the two longest edges, they define the largest face containg n.
1688  edge longestEdges[2] = {nullptr, nullptr};
1689  for(edge edgeWalker : spqrTree.skeleton(mu).getGraph().edges)
1690  {
1691  if (!longestEdges[1]
1692  || edgeLength[mu][edgeWalker] > edgeLength[mu][longestEdges[1]]) {
1693  if (!longestEdges[0]
1694  || edgeLength[mu][edgeWalker] > edgeLength[mu][longestEdges[0]]) {
1695  longestEdges[1] = longestEdges[0];
1696  longestEdges[0] = edgeWalker;
1697  }
1698  else
1699  longestEdges[1] = edgeWalker;
1700  }
1701  }
1702 
1703  if ( !spqrTree.skeleton(mu).isVirtual(longestEdges[0])
1704  || !spqrTree.skeleton(mu).isVirtual(longestEdges[1]))
1705  {
1706  containsARealEdge = true;
1707  }
1708 
1709  if (!containsARealEdge)
1710  return -1;
1711 
1712  return edgeLength[mu][longestEdges[0]] + edgeLength[mu][longestEdges[1]];
1713  }
1714  else if (spqrTree.typeOf(mu) == SPQRTree::NodeType::SNode)
1715  {
1716  //The largest face containing n is any face in the single existing embedding of S.
1717  T sizeOfFace = 0;
1718  for(node nS : spqrTree.skeleton(mu).getGraph().nodes)
1719  sizeOfFace += nodeLength[spqrTree.skeleton(mu).original(nS)];
1720 
1721  for(edge eS : spqrTree.skeleton(mu).getGraph().edges)
1722  {
1723  if (!spqrTree.skeleton(mu).isVirtual(eS))
1724  containsARealEdge = true;
1725  sizeOfFace += edgeLength[mu][eS];
1726  }
1727 
1728  if (!containsARealEdge)
1729  return -1;
1730 
1731  return sizeOfFace;
1732  }
1733 
1734  //should never end here...
1735  return 42;
1736 }
1737 
1738 
1739 template<class T>
1741  const StaticSPQRTree& spqrTree,
1742  const node& mu,
1743  const NodeArray<T>& nodeLength,
1744  const NodeArray< EdgeArray<T> >& edgeLength)
1745 {
1746  bool containsARealEdge = false;
1747  if (spqrTree.typeOf(mu) == SPQRTree::NodeType::RNode)
1748  {
1749  //The largest face is a largest face in any embedding of S.
1750  planarEmbed(spqrTree.skeleton(mu).getGraph());
1751  CombinatorialEmbedding combinatorialEmbedding(spqrTree.skeleton(mu).getGraph());
1752  T biggestFaceSize = -1;
1753  for(face f : combinatorialEmbedding.faces)
1754  {
1755  bool m_containsARealEdge = false;
1756  T sizeOfFace = 0;
1757  for(adjEntry ae : f->entries)
1758  {
1759 #if 0
1760  node originalNode = spqrTree.skeleton(mu).original(ae->theNode());
1761 #endif
1762  if (!spqrTree.skeleton(mu).isVirtual(ae->theEdge()))
1763  m_containsARealEdge = true;
1764  sizeOfFace += edgeLength[mu][ae->theEdge()]
1765  + nodeLength[spqrTree.skeleton(mu).original(ae->theNode())];
1766  }
1767 
1768  if (sizeOfFace > biggestFaceSize)
1769  {
1770  biggestFaceSize = sizeOfFace;
1771  containsARealEdge = m_containsARealEdge;
1772  }
1773  }
1774 
1775  if (!containsARealEdge)
1776  return -1;
1777 
1778  return biggestFaceSize;
1779  }
1780  else if (spqrTree.typeOf(mu) == SPQRTree::NodeType::PNode)
1781  {
1782  //Find the two longest edges, they define the largest face.
1783  edge longestEdges[2] = {nullptr, nullptr};
1784  for(edge edgeWalker : spqrTree.skeleton(mu).getGraph().edges)
1785  {
1786  if (!longestEdges[1]
1787  || edgeLength[mu][edgeWalker] > edgeLength[mu][longestEdges[1]]) {
1788  if (!longestEdges[0]
1789  || edgeLength[mu][edgeWalker] > edgeLength[mu][longestEdges[0]]) {
1790  longestEdges[1] = longestEdges[0];
1791  longestEdges[0] = edgeWalker;
1792  }
1793  else
1794  longestEdges[1] = edgeWalker;
1795  }
1796  }
1797 
1798  if ( !spqrTree.skeleton(mu).isVirtual(longestEdges[0])
1799  || !spqrTree.skeleton(mu).isVirtual(longestEdges[1]))
1800  {
1801  containsARealEdge = true;
1802  }
1803 
1804  if (!containsARealEdge)
1805  return -1;
1806 
1807  return edgeLength[mu][longestEdges[0]] + edgeLength[mu][longestEdges[1]];
1808  }
1809  else if (spqrTree.typeOf(mu) == SPQRTree::NodeType::SNode)
1810  {
1811  //The largest face is any face in the single existing embedding of S.
1812  T sizeOfFace = 0;
1813  for(node nS : spqrTree.skeleton(mu).getGraph().nodes)
1814  sizeOfFace += nodeLength[spqrTree.skeleton(mu).original(nS)];
1815 
1816  for(edge eS : spqrTree.skeleton(mu).getGraph().edges)
1817  {
1818  if (!spqrTree.skeleton(mu).isVirtual(eS))
1819  containsARealEdge = true;
1820  sizeOfFace += edgeLength[mu][eS];
1821  }
1822 
1823  if (!containsARealEdge)
1824  return -1;
1825 
1826  return sizeOfFace;
1827  }
1828 
1829  //should never end here...
1830  return 42;
1831 }
1832 
1833 }
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 void expandEdge(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, adjEntry &adjExternal, const node &n=nullptr)
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
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
adjEntry firstAdj() const
Returns the first adjacency element in the face.
static void expandEdgeSNode(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, adjEntry &adjExternal)
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 T computeSize(const Graph &G, const node &n, const NodeArray< T > &nodeLength, const EdgeArray< T > &edgeLength)
Returns the size of a maximum external face in G containing the node n.
Declaration of CombinatorialEmbedding and face.
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
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...
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, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, adjEntry &adjExternal)
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.
Declaration of class StaticSPQRTree.
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.
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
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
static void bottomUpTraversal(StaticSPQRTree &spqrTree, const node &mu, const NodeArray< T > &nodeLength, NodeArray< EdgeArray< T > > &edgeLength)
Bottom up traversal of SPQR-tree computing the component length of all non-reference edges...
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
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
Encapsulates a pointer to a list element.
Definition: List.h:42
static void expandEdgeRNode(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, adjEntry &adjExternal, const node &n)
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.
node treeNode() const
Returns the corresponding node in the owner tree T to which S belongs.
Definition: Skeleton.h:85
static void expandEdgePNode(const StaticSPQRTree &spqrTree, NodeArray< bool > &treeNodeTreated, const node &mu, const node &leftNode, const NodeArray< T > &nodeLength, const NodeArray< EdgeArray< T > > &edgeLength, NodeArray< List< adjEntry > > &newOrder, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArraySource, NodeArray< ListIterator< adjEntry > > &adjBeforeNodeArrayTarget, adjEntry &adjExternal)
static void topDownTraversal(StaticSPQRTree &spqrTree, const node &mu, const NodeArray< T > &nodeLength, NodeArray< EdgeArray< T > > &edgeLength)
Top down traversal of SPQR-tree computing the component length of all reference edges.
Linear-time implementation of static SPQR-trees.
edge succ() const
Returns the successor in the list of all edges.
Definition: Graph_d.h:353
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:148
node rootNode() const override
Returns the root node of T.
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
Definition: Graph_d.h:651
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:326
Embedder that maximizing the external face.
The namespace for all OGDF objects.
Declaration of extended graph algorithms.
void allEdges(CONTAINER &edgeContainer) const
Returns a container with all edges of the graph.
Definition: Graph_d.h:661
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:598
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
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