Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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