Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

NonPlanarCore.h
Go to the documentation of this file.
1 
33 #pragma once
34 
36 #include <ogdf/basic/Queue.h>
40 
41 
42 namespace ogdf {
43 
45 
65 template<typename TCost = int>
67 
68  template<typename T>
69  friend class GlueMap;
70 
71 public:
76  struct CutEdge {
77  const edge e;
78  const bool dir;
79 
80  CutEdge(edge paramEdge, bool directed) : e(paramEdge), dir(directed) {};
81  };
82 
93  explicit NonPlanarCore(const Graph &G, bool nonPlanarityGuaranteed = false);
94 
100  NonPlanarCore(const Graph &G, const EdgeArray<TCost> &weight, bool nonPlanarityGuaranteed = false);
101 
109  NonPlanarCore(const Graph &G, const EdgeArray<TCost> &weight, MinSTCutModule<TCost> *minSTCutModule,
110  bool nonPlanarityGuaranteed = false);
111 
113  const Graph &core() const {
114  return m_graph;
115  }
116 
118  const Graph &originalGraph() const {
119  return *m_pOriginal;
120  }
121 
123  node original(node v) const {
124  return m_orig[v];
125  }
126 
129  List<edge> res;
130  if (isVirtual(e)) {
131  EdgeArray<edge> origEdgesOfThisSTComponent(*mapE(e));
132  for (edge eInCop: origEdgesOfThisSTComponent.graphOf()->edges) {
133  if (origEdgesOfThisSTComponent[eInCop] != nullptr) {
134  res.pushBack(origEdgesOfThisSTComponent[eInCop]);
135  }
136  }
137  } else {
138  res.pushBack(realEdge(e));
139  }
140  return res;
141  }
142 
144  bool isVirtual(edge e) const {
145  return m_real[e] == nullptr;
146  }
147 
149  edge realEdge(edge e) const {
150  return m_real[e];
151  }
152 
157  const EdgeArray<TCost> &cost() const {
158  return m_cost;
159  }
160 
165  node tNode(edge e) const {
166  return m_tNode[e];
167  }
168 
173  node sNode(edge e) const {
174  return m_sNode[e];
175  }
176 
181  return m_mapE[e];
182  }
183 
188  TCost cost(edge e) const {
189  return m_cost[e];
190  }
191 
193  const List<CutEdge> &mincut(edge e) const {
194  return m_mincut[e];
195  }
196 
197  // destructor
198  virtual ~NonPlanarCore();
199 
201 
207  void retransform(const GraphCopy &planarCore, GraphCopy &planarGraph, bool pCisPlanar = true);
208 
209 protected:
211  void call(const Graph &G, const EdgeArray<TCost> *weight, MinSTCutModule<TCost> *minSTCutModule,
212  bool nonPlanarityGuaranteed);
213 
222  void getAllMultiedges(List<edge> &winningEdges, List<edge> &losingEdges);
223 
240  void traversingPath(const Skeleton &Sv, edge eS, List<CutEdge> &path, NodeArray<node> &mapV,
241  edge coreEdge, const EdgeArray<TCost> *weight_src, MinSTCutModule<TCost> *minSTCutModule);
242 
251  void splitEdgeIntoSections(edge e, List<node> &splitdummies);
252 
257  void removeSplitdummies(List<node> &splitdummies);
258 
266  void normalizeCutEdgeDirection(edge coreEdge);
267 
275  void importEmbedding(edge e);
276 
283  void markCore(NodeArray<bool> &mark);
284 
289  void inflateCrossing(node v);
290 
298  void getMincut(edge e, List<edge> &cut);
299 
308  void glue(edge eWinner, edge eLoser);
309 
316  void glueMincuts(edge eWinner, edge eLoser);
317 
320 
323 
329 
335 
338 
341 
344 
347 
350 
353 
356 
359 
362 
365 };
366 
370 template<typename Cost>
371 class GlueMap {
372 public:
382  GlueMap(edge eWinner, edge eLoser, NonPlanarCore<Cost> &npc);
383 
387  void mapLoserToNewWinnerEdge(edge eInLoser);
388 
392  void mapLoserToWinnerNode(node vInLoser, node vInWinner);
393 
397  void mapLoserToNewWinnerNode(node vInLoser);
398 
409  void reorder(node vLoser, bool sameDirection, bool isTNodeOfPNode);
410 
417  return m_mapV_l2w[v];
418  }
419 
424  const Graph &getLoserGraph() const {
425  return *m_gLoser;
426  }
427 
428 protected:
434  const edge m_eLoser;
438  const Graph *m_gLoser;
451 };
452 
453  template<typename Cost>
454  NonPlanarCore<Cost>::NonPlanarCore(const Graph &G, bool nonPlanarityGuaranteed) :
456  m_cost(m_graph), m_T(G), m_mapV(m_graph, nullptr), m_mapE(m_graph, nullptr), m_underlyingGraphs(m_graph, nullptr),
458  MinSTCutBFS<Cost> minSTCutBFS;
459  call(G, nullptr, &minSTCutBFS, nonPlanarityGuaranteed);
460  }
461 
462  template<typename Cost>
464  bool nonPlanarityGuaranteed) :
465  m_pOriginal(&G), m_orig(m_graph), m_real(m_graph, nullptr), m_mincut(m_graph),
466  m_cost(m_graph), m_T(G), m_mapV(m_graph, nullptr), m_mapE(m_graph, nullptr), m_underlyingGraphs(m_graph, nullptr),
467  m_sNode(m_graph), m_tNode(m_graph) {
468  call(G, &weight, minSTCutModule, nonPlanarityGuaranteed);
469  }
470 
471  template<typename Cost>
472  NonPlanarCore<Cost>::NonPlanarCore(const Graph &G, const EdgeArray<Cost> &weight, bool nonPlanarityGuaranteed) :
473  m_pOriginal(&G), m_orig(m_graph), m_real(m_graph, nullptr), m_mincut(m_graph),
474  m_cost(m_graph), m_T(G), m_mapV(m_graph, nullptr), m_mapE(m_graph, nullptr), m_underlyingGraphs(m_graph, nullptr),
475  m_sNode(m_graph), m_tNode(m_graph) {
476  MinSTCutDijkstra<Cost> minSTCutDijkstra;
477  call(G, &weight, &minSTCutDijkstra, nonPlanarityGuaranteed);
478  }
479 
480 
481  template<typename Cost>
483  for(auto pointer : m_mapE) {
484  delete pointer;
485  }
486  for(auto pointer : m_mapV) {
487  delete pointer;
488  }
489  for(auto pointer : m_underlyingGraphs) {
490  delete pointer;
491  }
492  }
493 
494  template<typename Cost>
495  void NonPlanarCore<Cost>::call(const Graph &G, const EdgeArray<Cost> *weight, MinSTCutModule<Cost> *minSTCutModule,
496  bool nonPlanarityGuaranteed) {
497  if (!nonPlanarityGuaranteed
498  && isPlanar(G)) {
499  return;
500  }
501  OGDF_ASSERT(!isPlanar(G));
503 
504  // mark tree nodes in the core
505  NodeArray<bool> mark;
506  markCore(mark);
507 
508  NodeArray<node> map(G, nullptr);
509  NodeArray<node> mapAux(G, nullptr);
510  const Graph &tree = m_T.tree();
511 
512  for(node v : tree.nodes){
513  if(mark[v] == false){
514  continue;
515  }
516 
517  Skeleton &S = m_T.skeleton(v);
518 
519  for(edge e : S.getGraph().edges){
520  node src = S.original(e->source());
521  node tgt = S.original(e->target());
522 
523  if(tgt == src){
524  continue;
525  }
526 
527  if(map[src] == nullptr){
528  m_orig[map[src] = m_graph.newNode()] = S.original(e->source());
529  }
530 
531  if(map[tgt] == nullptr){
532  m_orig[map[tgt] = m_graph.newNode()] = S.original(e->target());
533  }
534 
535  if(S.isVirtual(e)){
536  node w = S.twinTreeNode(e);
537 
538  if(mark[w] == false){
539  // new virtual edge in core graph
540  edge lastCreatedEdge = m_graph.newEdge(map[src], map[tgt]);
541  m_real[lastCreatedEdge] = nullptr;
542  traversingPath(S, e, m_mincut[lastCreatedEdge], mapAux,
543  lastCreatedEdge, weight, minSTCutModule);
544  }
545  } else {
546  // new real edge in core graph
547  edge lastCreatedEdge = m_graph.newEdge(map[src], map[tgt]);
548  m_real[lastCreatedEdge] = S.realEdge(e);
549  traversingPath(S, e, m_mincut[lastCreatedEdge], mapAux,
550  lastCreatedEdge, weight, minSTCutModule);
551  }
552  }
553  }
554 
555  if(weight != nullptr)
556  {
557  for(edge e : m_graph.edges)
558  {
559  Cost cost(0);
560  for(auto cutEdge : m_mincut[e])
561  {
562  cost += (*weight)[cutEdge.e];
563  }
564  m_cost[e] = cost;
565  }
566  } else {
567  for(edge e : m_graph.edges)
568  {
569  m_cost[e] = m_mincut[e].size();
570  }
571  }
572 
573  List<node> allNodes;
574  m_graph.allNodes(allNodes);
575 
576  // The while loop is used to eliminate multiedges from the core. We're pruning P-Nodes.
577  List<edge> winningMultiEdges;
578  List<edge> losingMultiEdges;
579  getAllMultiedges(winningMultiEdges, losingMultiEdges);
580  while(!winningMultiEdges.empty() && !losingMultiEdges.empty()){
581  edge winningMultiEdge = winningMultiEdges.popFrontRet();
582  edge losingMultiEdge = losingMultiEdges.popFrontRet();
583  #ifdef OGDF_DEBUG
584  int sizeOfWinCut = m_mincut[winningMultiEdge].size();
585  int sizeOfLosCut = m_mincut[losingMultiEdge].size();
586  #endif
587 
588  glue(winningMultiEdge, losingMultiEdge);
589  glueMincuts(winningMultiEdge, losingMultiEdge);
590 
591  OGDF_ASSERT(m_mincut[winningMultiEdge].size() == sizeOfWinCut + sizeOfLosCut);
592  delete m_underlyingGraphs[losingMultiEdge];
593  delete m_mapV[losingMultiEdge];
594  delete m_mapE[losingMultiEdge];
595  m_real[winningMultiEdge] = nullptr;
596  m_real[losingMultiEdge] = nullptr;
597  m_graph.delEdge(losingMultiEdge);
598  }
599  // The for loop is used to eliminate deg 2 nodes from the core. We're pruning S-Nodes.
600  for(node v : allNodes){
601  if(v->degree() != 2){
602  continue;
603  }
604  edge outEdge = v->firstAdj()->theEdge();
605  edge inEdge = v->lastAdj()->theEdge();
606 
607  if(m_cost[inEdge] > m_cost[outEdge])
608  {
609  swap(inEdge, outEdge);
610  }
611  // We join the embeddings of the underlying embeddings/graphs of both edges
612  // so that outEdge gets integrated into inEdge
613  glue(inEdge, outEdge);
614 
615  m_real[inEdge] = nullptr;
616  m_real[outEdge] = nullptr;
617 
618  adjEntry adjSource = inEdge->adjSource()->cyclicSucc();
619  adjEntry adjTarget = (outEdge->target() == v ? outEdge->adjSource()->cyclicSucc()
620  : outEdge->adjTarget()->cyclicSucc());
621  if(inEdge->target() != v){
622  adjSource = adjTarget;
623  adjTarget = inEdge->adjTarget()->cyclicSucc();
624  }
625  m_graph.move(inEdge, adjSource, ogdf::Direction::before, adjTarget, ogdf::Direction::before);
626  delete m_underlyingGraphs[outEdge];
627  delete m_mapV[outEdge];
628  delete m_mapE[outEdge];
629  m_graph.delNode(v);
630  }
631 
632 
633  if(nonPlanarityGuaranteed){
634  OGDF_ASSERT(!isPlanar(m_graph));
635  }
636  }
637 
638  template<typename Cost>
640  const Graph &tree = m_T.tree();
641 
642  // We mark every tree node that belongs to the core
643  mark.init(tree, true); // start with all nodes and unmark planar leaves
644  NodeArray<int> degree(tree);
645 
646  Queue<node> Q;
647 
648  for(node v : tree.nodes){
649  degree[v] = v->degree();
650  if(degree[v] <= 1){ // also append deg-0 node (T has only one node)
651  Q.append(v);
652  }
653  }
654 
655  while(!Q.empty()){
656  node v = Q.pop();
657 
658  // if v has a planar skeleton
659  if(m_T.typeOf(v) != SPQRTree::NodeType::RNode ||
660  isPlanar(m_T.skeleton(v).getGraph())){
661  mark[v] = false; // unmark this leaf
662 
663  node w = nullptr;
664  for(adjEntry adj : v->adjEntries){
665  node x = adj->twinNode();
666  if(mark[x] == true){
667  w = x;
668  break;
669  }
670  }
671 
672  if(w != nullptr){
673  --degree[w];
674  if(degree[w] == 1){
675  Q.append(w);
676  }
677  }
678  }
679  }
680  }
681 
682  struct QueueEntry {
683  QueueEntry(node p, node v) : m_parent(p), m_current(v){ }
684 
687  };
688 
689  template<typename Cost>
691  NodeArray<node> &mapV, edge coreEdge,
692  const EdgeArray<Cost> *weight_src,
693  MinSTCutModule<Cost> *minSTCutModule)
694  {
695  List<CutEdge> &currPath = path;
696 
697  // Build the graph representing the planar st-component
698  Graph *h_pointer = new Graph();
699  Graph &H = *h_pointer;
700 
701  EdgeArray<edge> *mapE_src_pointer = new EdgeArray<edge>(H, nullptr);
702  EdgeArray<edge> &mapE_src = *mapE_src_pointer;
703  NodeArray<node> *mapV_src_pointer = new NodeArray<node>(H, nullptr);
704  NodeArray<node> &mapV_src = *mapV_src_pointer;
705  SListPure<node> nodes;
706  SListPure<edge> multedges;
707 
708  if(Sv.isVirtual(eS)){
710  Q.append(QueueEntry(Sv.treeNode(), Sv.twinTreeNode(eS)));
711 
712  while(!Q.empty()){
713  QueueEntry x = Q.pop();
714  node parent = x.m_parent;
715  node current = x.m_current;
716 
717  const Skeleton &S = m_T.skeleton(current);
718  for(edge e : S.getGraph().edges){
719  if(S.isVirtual(e)){
720  continue;
721  }
722 
723  node src = S.original(e->source());
724  node tgt = S.original(e->target());
725 
726  if(mapV[src] == nullptr){
727  nodes.pushBack(src);
728  mapV[src] = H.newNode();
729  mapV_src[mapV[src]] = src;
730  }
731  if(mapV[tgt] == nullptr){
732  nodes.pushBack(tgt);
733  mapV[tgt] = H.newNode();
734  mapV_src[mapV[tgt]] = tgt;
735  }
736 
737  edge e_new = H.newEdge(mapV[src], mapV[tgt]);
738  mapE_src[e_new] = S.realEdge(e);
739  OGDF_ASSERT(mapE_src[e_new]->source() != nullptr);
740  }
741 
742  for(adjEntry adj : current->adjEntries){
743  node w = adj->twinNode();
744  if(w != parent){
745  Q.append(QueueEntry(current, w));
746  }
747  }
748  }
749  } else {
750  nodes.pushBack(Sv.original(eS->source()));
751  nodes.pushBack(Sv.original(eS->target()));
752  mapV[Sv.original(eS->source())] = H.newNode();
753  mapV_src[mapV[Sv.original(eS->source())]] = Sv.original(eS->source());
754  mapV[Sv.original(eS->target())] = H.newNode();
755  mapV_src[mapV[Sv.original(eS->target())]] = Sv.original(eS->target());
756  mapE_src[H.newEdge(mapV[Sv.original(eS->source())], mapV[Sv.original(eS->target())])] = Sv.realEdge(eS);
757  }
758  // add st-edge
759  edge e_st = H.newEdge(mapV[Sv.original(eS->source())], mapV[Sv.original(eS->target())]);
760  m_sNode[coreEdge] = mapV[Sv.original(eS->source())];
761  m_tNode[coreEdge] = mapV[Sv.original(eS->target())];
762 
763  // Compute planar embedding of H
764  #ifdef OGDF_DEBUG
765  bool ok =
766  #endif
767  planarEmbed(H);
768  OGDF_ASSERT(ok);
770 
771  // we rearange the adj Lists of s and t, so that adj(e_st) is the first adj
772  List<adjEntry> adjListFront;
773  List<adjEntry> adjListBack;
774  e_st->source()->allAdjEntries(adjListFront);
775  if(adjListFront.front() != e_st->adjSource()){
776  adjListFront.split(adjListFront.search(e_st->adjSource()), adjListFront, adjListBack);
777  adjListFront.concFront(adjListBack);
778  H.sort(e_st->source(), adjListFront);
779  }
780 
781  e_st->target()->allAdjEntries(adjListFront);
782  if(adjListFront.front() != e_st->adjTarget()){
783  adjListFront.split(adjListFront.search(e_st->adjTarget()), adjListFront, adjListBack, ogdf::Direction::before);
784  adjListFront.concFront(adjListBack);
785  H.sort(e_st->target(), adjListFront);
786  }
787 
788  if(Sv.isVirtual(eS)){
789  List<edge> edgeList;
790  if(weight_src != nullptr) {
791  EdgeArray<Cost> weight(H);
792  for (edge e : H.edges) {
793  if (e != e_st) {
794  weight[e] = (*weight_src)[mapE_src[e]];
795  }
796  }
797  minSTCutModule->call(H, weight, e_st->source(), e_st->target(), edgeList, e_st);
798  } else {
799  minSTCutModule->call(H, e_st->source(), e_st->target(), edgeList, e_st);
800  }
801  auto it = edgeList.begin();
802  for(;it != edgeList.end(); it++) {
803  currPath.pushBack(CutEdge(mapE_src[*it], minSTCutModule->direction(*it)));
804  }
805  }
806  else {
807  OGDF_ASSERT(Sv.realEdge(eS) != nullptr);
808  currPath.pushFront(CutEdge(Sv.realEdge(eS), true));
809  }
810  H.delEdge(e_st);
811 
812  OGDF_ASSERT(m_underlyingGraphs[coreEdge] == nullptr);
813  m_underlyingGraphs[coreEdge] = h_pointer;
814  OGDF_ASSERT(m_mapE[coreEdge] == nullptr);
815  m_mapE[coreEdge] = mapE_src_pointer;
816  OGDF_ASSERT(m_mapV[coreEdge] == nullptr);
817  m_mapV[coreEdge] = mapV_src_pointer;
818  #ifdef OGDF_DEBUG
819  for(node v : H.nodes){
820  OGDF_ASSERT(mapV_src[v] != nullptr);
821  }
822  for(edge e : H.edges){
823  OGDF_ASSERT(mapE_src[e] != nullptr); }
824  #endif
825 
826  for(node v : nodes){
827  mapV[v] = nullptr;
828  }
829  }
830 
831  template<typename Cost>
833  winningEdges.clear();
834  losingEdges.clear();
835  SListPure<edge> edges;
836  EdgeArray<int> minIndex(m_graph), maxIndex(m_graph);
837  parallelFreeSortUndirected(m_graph, edges, minIndex, maxIndex);
838 
839  SListConstIterator<edge> it = edges.begin();
840  edge ePrev = *it, e;
841  for(it = ++it; it.valid(); ++it, ePrev = e){
842  e = *it;
843  if(minIndex[ePrev] == minIndex[e] && maxIndex[ePrev] == maxIndex[e]){
844  winningEdges.pushFront(ePrev);
845  losingEdges.pushFront(e);
846  }
847  }
848  }
849 
850  template<typename Cost>
851  void NonPlanarCore<Cost>::glue(edge eWinner, edge eLoser){
852  GlueMap<Cost> map(eWinner, eLoser, *this);
853 
854  // true iff this glueing is about a PNode (so a glueing at two common nodes)
855  bool thisIsAboutAPNode = false;
856  if((eLoser->source() == eWinner->source() && eLoser->target() == eWinner->target()) ||
857  (eLoser->target() == eWinner->source() && eLoser->source() == eWinner->target())){
858  thisIsAboutAPNode = true;
859  }
860 
861  // find the s- and t-nodes in their skeleton for both of the edges
862  node sWinner = m_sNode[eWinner];
863  node tWinner = m_tNode[eWinner];
864  node sLoser = m_sNode[eLoser];
865  node tLoser = m_tNode[eLoser];
866 
867  bool sameDirection = !(eWinner->source() == eLoser->target() && eWinner->target() == eLoser->source());
868 
869  // we get a list of all nodes of the loser graph
870  List<node> allNodesButSt;
871  map.getLoserGraph().allNodes(allNodesButSt);
872 
873  #ifdef OGDF_DEBUG
874  bool ok = true;
875  #endif
876 
877  // for both s and t of eLoser we check if it's either the s or the t node of eWinner
878  // if one of it is, we delete it from the list of nodes, that are to be added
879  // otherwise it stays in 'allNodesButSt' to be added later
880  if(eLoser->source() == eWinner->source() || eLoser->source() == eWinner->target()){
881  #ifdef OGDF_DEBUG
882  ok =
883  #endif
884  allNodesButSt.removeFirst(sLoser);
885  OGDF_ASSERT(ok);
886  if(eLoser->source() == eWinner->source()){
887  map.mapLoserToWinnerNode(sLoser, sWinner);
888  } else {
889  map.mapLoserToWinnerNode(sLoser, tWinner);
890  }
891  OGDF_ASSERT(!allNodesButSt.removeFirst(sLoser));
892  }
893  if(eLoser->target() == eWinner->source() || eLoser->target() == eWinner->target()){
894  #ifdef OGDF_DEBUG
895  ok =
896  #endif
897  allNodesButSt.removeFirst(tLoser);
898  OGDF_ASSERT(ok);
899  if(eLoser->target() == eWinner->source()){
900  map.mapLoserToWinnerNode(tLoser, sWinner);
901  } else {
902  map.mapLoserToWinnerNode(tLoser, tWinner);
903  }
904  OGDF_ASSERT(!allNodesButSt.removeFirst(tLoser));
905  }
906 
907 
908  // insert the remaining nodes of the loser graph into the winner graph
909  for(node v : allNodesButSt){
911  }
912 
913  // insert all edges of the loser graph into the the winner graph
914  for(edge e : map.getLoserGraph().edges){
916  }
917 
918  // reorder the adjEntries of every node of the loser graph in the winner graph,
919  // to match the embedding in the loser graph
920  List<node> allNodes = allNodesButSt;
921  allNodes.pushBack(sLoser);
922  allNodes.pushBack(tLoser);
923  for(node v : allNodes){
924  map.reorder(v, sameDirection, (tLoser == v && thisIsAboutAPNode));
925  }
926  if(!thisIsAboutAPNode){
927  if(eWinner->source() == eLoser->source()){
928  m_sNode[eWinner] = map.getWinnerNodeOfLoserNode(tLoser);
929  }
930  if(eWinner->target() == eLoser->source()){
931  m_tNode[eWinner] = map.getWinnerNodeOfLoserNode(tLoser);
932  }
933  if(eWinner->source() == eLoser->target()){
934  m_sNode[eWinner] = map.getWinnerNodeOfLoserNode(sLoser);
935  }
936  if(eWinner->target() == eLoser->target()){
937  m_tNode[eWinner] = map.getWinnerNodeOfLoserNode(sLoser);
938  }
939  }
940  }
941 
942  template<typename Cost>
943  void NonPlanarCore<Cost>::retransform(const GraphCopy &planarCore, GraphCopy &planarGraph, bool pCisPlanar){
944  #ifdef OGDF_DEBUG
945  GraphCopy copyCore(planarCore);
946  copyCore.removePseudoCrossings();
947  OGDF_ASSERT(copyCore.numberOfNodes() == planarCore.numberOfNodes());
948  #endif
949  m_endGraph = &planarGraph;
950  m_planarCore = &planarCore;
951  OGDF_ASSERT(!pCisPlanar || m_planarCore->genus() == 0);
952  m_endGraph->clear();
953  m_endGraph->createEmpty(*m_pOriginal);
954  List<node> allNodes;
955  m_pOriginal->allNodes(allNodes);
956  EdgeArray<edge> eCopy(*m_pOriginal, nullptr);
957  m_endGraph->initByNodes(allNodes, eCopy);
958 
959  #ifdef OGDF_DEBUG
960  for(node v : m_endGraph->nodes){
961  List<adjEntry> adjEntries;
962  v->allAdjEntries(adjEntries);
963  OGDF_ASSERT(v->degree() == adjEntries.size());
964  }
965  #endif
966 
967  // For every node of the core we rearrange the adjacency order of the corresponding endGraph node
968  // according to the planarized core.
969  for(node v : m_planarCore->nodes){
970  if(m_planarCore->isDummy(v)){
971  continue;
972  }
973  List<adjEntry> pcOrder;
974  v->allAdjEntries(pcOrder);
975  List<adjEntry> newOrder;
976  node coreNode = m_planarCore->original(v);
977  OGDF_ASSERT(coreNode != nullptr);
978  for(adjEntry adjPC : v->adjEntries) {
979  edge coreEdge = m_planarCore->original(adjPC->theEdge());
980  EdgeArray<edge> &mapE = *m_mapE[coreEdge];
981  NodeArray<node> &mapV = *m_mapV[coreEdge];
982  node stNode = (mapV[m_sNode[coreEdge]] == original(coreNode) ? m_sNode[coreEdge] : m_tNode[coreEdge]);
983  // find the node of emb which represents the same node v represents
984  for(adjEntry adjEmb : stNode->adjEntries){
985  if(adjEmb->theEdge()->source() == adjEmb->theNode()){
986  newOrder.pushBack(m_endGraph->copy(mapE[adjEmb->theEdge()])->adjSource());
987  } else {
988  newOrder.pushBack(m_endGraph->copy(mapE[adjEmb->theEdge()])->adjTarget());
989  }
990  }
991  }
992  m_endGraph->sort(m_endGraph->copy(original(coreNode)), newOrder);
993  }
994  if(!pCisPlanar) {
995  for(edge e: m_graph.edges) {
996  importEmbedding(e);
997  }
998  return;
999  } else {
1000  List<node> splitdummies;
1001  for (edge e : m_graph.edges) {
1002  // for every edge from the core we ensure, that the embedding of the subgraph it describes
1003  // is the same in both the original and the end graph
1004  importEmbedding(e);
1005  // reverse all cut edges, which are not the same direction as e
1006  normalizeCutEdgeDirection(e);
1007  // to ensure the right order of the inserted crossings, we insert dummy nodes
1008  // to split the edge in sections, each of which only has one crossing
1009  splitEdgeIntoSections(e, splitdummies);
1010  }
1011 
1012  // now we can start and insert the crossings of the planar core into the end graph.
1013  // a node represents a crossing if it's a dummy
1014  for (node v : m_planarCore->nodes) {
1015  if (m_planarCore->isDummy(v)) {
1016  inflateCrossing(v);
1017  }
1018  }
1019  OGDF_ASSERT(m_endGraph->genus() == 0);
1020 
1021  removeSplitdummies(splitdummies);
1022  for (edge e : m_graph.edges) {
1023  normalizeCutEdgeDirection(e);
1024  }
1025  }
1026  }
1027 
1028  template<typename Cost>
1030  for(auto cutE : m_mincut[coreEdge]) {
1031  if(!cutE.dir) {
1032  for(edge e : m_endGraph->chain(cutE.e)) {
1033  m_endGraph->reverseEdge(e);
1034  }
1035  }
1036  }
1037  }
1038 
1039  template<typename Cost>
1041  for(node v : splitdummies){
1042  edge eIn = v->firstAdj()->theEdge();
1043  edge eOut = v->lastAdj()->theEdge();
1044  if(eIn->target() == v){
1045  m_endGraph->unsplit(eIn, eOut);
1046  } else {
1047  m_endGraph->unsplit(eOut, eIn);
1048  }
1049  }
1050  }
1051 
1052  template<typename Cost>
1054  List<edge> chain = m_planarCore->chain(e);
1055  int chainSize = chain.size();
1056  while(chainSize > 2){
1057  for(CutEdge cutEdge : mincut(e)){
1058  splitdummies.pushBack(m_endGraph->split(m_endGraph->copy(cutEdge.e))->source());
1059  }
1060  chainSize--;
1061  }
1062  #ifdef OGDF_DEBUG
1063  for(CutEdge cutEdge : mincut(e)){
1064  if(chain.size() < 3){
1065  OGDF_ASSERT(m_endGraph->chain(cutEdge.e).size() == 1);
1066  } else {
1067  OGDF_ASSERT(m_endGraph->chain(cutEdge.e).size() == chain.size() - 1);
1068  }
1069  OGDF_ASSERT(m_endGraph->original(m_endGraph->chain(cutEdge.e).front()) == cutEdge.e);
1070  }
1071  #endif
1072  }
1073 
1074  template<typename Cost>
1076  const Graph &embG = *m_underlyingGraphs[e];
1077  // a map from the nodes of the emb to those in the end graph
1078  const EdgeArray<edge> &mapE_toOrig = *m_mapE[e];
1079  // bc the edges of the end graph are split for the crossing insertion,
1080  // a map of the emb might have more than one edge in the endgraph, we just
1081  // map the AdjEntries of both source and target of each edge of emb
1082  // to AdjEntries in the end graph
1083  const NodeArray<node> &mapV_toOrig = *m_mapV[e];
1084  AdjEntryArray<adjEntry> mapA_toFinal(embG, nullptr);
1085  for(auto it = mapE_toOrig.begin(); it != mapE_toOrig.end(); it++){
1086  OGDF_ASSERT(it.key() != nullptr);
1087  OGDF_ASSERT((*it) != nullptr);
1088  OGDF_ASSERT((*it)->graphOf() == m_pOriginal);
1089  mapA_toFinal[it.key()->adjSource()] = m_endGraph->chain(*it).front()->adjSource();
1090  mapA_toFinal[it.key()->adjTarget()] = m_endGraph->chain(*it).back()->adjTarget();
1091  }
1092  node s(m_sNode[e]), t(m_tNode[e]);
1093  List<node> nodesOfEmb;
1094  embG.allNodes(nodesOfEmb);
1095  // for every node of emb we order the adjEntries of the corresponding node
1096  // in the end graph, so that both match
1097  for(node v : nodesOfEmb){
1098  if(v == s || v == t){
1099  continue;
1100  }
1101  List<adjEntry> rightAdjOrder;
1102  for(adjEntry adj = v->firstAdj(); adj; adj = adj->succ()){
1103  rightAdjOrder.pushBack(mapA_toFinal[adj]);
1104  }
1105  m_endGraph->sort(m_endGraph->copy(mapV_toOrig[v]), rightAdjOrder);
1106  }
1107  }
1108 
1109  template<typename Cost>
1111  // we want e1 and e2 to be these two edges
1112  // ^
1113  // |
1114  // e2-->v--->
1115  // ^
1116  // |
1117  // e1
1118  edge e1 = v->firstAdj()->theEdge();
1119  while(e1->target() != v){
1120  e1 = e1->adjSource()->succ()->theEdge();
1121  }
1122  edge e2 = e1->adjTarget()->succ()->theEdge();
1123  while(e2->target() != v){
1124  e2 = e2->adjSource()->cyclicSucc()->theEdge();
1125  }
1126  if(e1 == e2->adjTarget()->cyclicSucc()->theEdge()){
1127  edge help = e1;
1128  e1 = e2;
1129  e2 = help;
1130  }
1131  OGDF_ASSERT(e2 == e1->adjTarget()->cyclicSucc()->theEdge());
1132  List<edge> e1cut;
1133  getMincut(e1, e1cut);
1134  List<edge> e2cut;
1135  getMincut(e2, e2cut);
1136  OGDF_ASSERT(e1 != e2);
1137  OGDF_ASSERT(e1cut.size() > 0);
1138  OGDF_ASSERT(e2cut.size() > 0);
1139  // the actual crossing insertion
1140  // for (auto it1 = e1cut.begin(); it1.valid(); it1++)
1141  for(int i = 0; i < e1cut.size(); i++){
1142  auto it1 = e1cut.get(i);
1143  edge crossingEdge = *it1;
1144  for(int j = 0; j < e2cut.size(); j++){
1145  auto it2 = e2cut.get(j);
1146  edge crossedEdge = *it2;
1147  m_endGraph->insertCrossing(*it1, crossedEdge, true);
1148  OGDF_ASSERT(crossedEdge == *it2);
1149  e2cut.insertAfter(crossedEdge, it2);
1150  e2cut.del(it2);
1151  }
1152  OGDF_ASSERT(crossingEdge != *it1);
1153  e1cut.insertAfter(crossingEdge, it1);
1154  e1cut.del(it1);
1155  }
1156  }
1157 
1158  template<typename Cost>
1160  OGDF_ASSERT(e->graphOf() == m_planarCore);
1161 
1162  cut.clear();
1163  // chain is a list of the edges of the planar core, that represent e
1164  List<edge> chain = m_planarCore->chain(m_planarCore->original(e));
1165  // this is the main part of this function:
1166  // as we know, the cut edges are split by splitdummies to partition the edge,
1167  // such that every crossing on the edge has its own section to be inserted into (denoted by pos)
1168  // cut_pre stores the first section for every cut edge
1169  for(CutEdge eCut : mincut(m_planarCore->original(e))) {
1170  OGDF_ASSERT(m_endGraph->chain(eCut.e).size() + 1 >= chain.size());
1171  // while iterating we have to differentiate between already inserted crossings and splitdummies
1172  // we can do that, by only counting the deg 2 nodes we pass while iterating through the chain of the cut edge
1173  auto it = m_endGraph->chain(eCut.e).begin();
1174  for(int i = 0; i < chain.pos(chain.search(e)); i++){
1175  it++;
1176  while((*it)->source()->degree() == 4){
1177  it++;
1178  OGDF_ASSERT(it.valid());
1179  }
1180  }
1181  cut.pushBack(*(it));
1182  }
1183  // cut is the result of this function
1184  }
1185 
1186  template<typename Cost>
1188  #ifdef OGDF_DEBUG
1189  if(eWinner->adjSource()->theNode() == eLoser->adjSource()->theNode()){
1190  OGDF_ASSERT(eWinner->adjSource()->theNode() == eLoser->adjSource()->theNode());
1191  OGDF_ASSERT(eWinner->adjTarget()->theNode() == eLoser->adjTarget()->theNode());
1192  }
1193  else {
1194  OGDF_ASSERT(eWinner->adjSource()->theNode() == eLoser->adjTarget()->theNode());
1195  OGDF_ASSERT(eWinner->adjTarget()->theNode() == eLoser->adjSource()->theNode());
1196  }
1197  #endif
1198  List<CutEdge> wincut = m_mincut[eWinner];
1199 
1200  List<CutEdge> losecut = m_mincut[eLoser];
1201 
1202  if(eWinner->source() == eLoser->target()) {
1203  List<CutEdge> newLosecut;
1204  for(auto cutEit = losecut.begin(); cutEit != losecut.end(); cutEit++) {
1205  newLosecut.pushBack(CutEdge((*cutEit).e, !(*cutEit).dir));
1206  }
1207  losecut = newLosecut;
1208  }
1209 
1210  wincut.conc(losecut);
1211  m_mincut[eWinner] = wincut;
1212  m_cost[eWinner] += m_cost[eLoser];
1213  }
1214 
1215  template<typename Cost>
1216  GlueMap<Cost>::GlueMap(edge eWinner, edge eLoser, NonPlanarCore<Cost> &npc) : m_npc(npc), m_eWinner(eWinner),
1217  m_eLoser(eLoser){
1219 
1222 
1225 
1227 
1228  OGDF_ASSERT(m_npc.m_mapV[m_eWinner] != nullptr);
1229  OGDF_ASSERT(m_npc.m_mapV[m_eLoser] != nullptr);
1230 
1233 
1234  OGDF_ASSERT(m_npc.m_mapE[m_eWinner] != nullptr);
1235  OGDF_ASSERT(m_npc.m_mapE[m_eLoser] != nullptr);
1236 
1239 
1240  OGDF_ASSERT(m_mapEloser->graphOf() == m_gLoser);
1241  OGDF_ASSERT(m_mapVloser->graphOf() == m_gLoser);
1242 
1243  OGDF_ASSERT(m_mapEwinner->graphOf() == m_gWinner);
1244  OGDF_ASSERT(m_mapVwinner->graphOf() == m_gWinner);
1245 
1246  m_mapE_l2w = EdgeArray<edge>(*m_gLoser, nullptr);
1247  m_mapV_l2w = NodeArray<node>(*m_gLoser, nullptr);
1248  }
1249 
1250  template<typename Cost>
1252  edge newEdge = m_gWinner->newEdge(m_mapV_l2w[loser->source()], m_mapV_l2w[loser->target()]);
1253  m_mapE_l2w[loser] = newEdge;
1254  (*m_mapEwinner)[newEdge] = (*m_mapEloser)[loser];
1255  }
1256 
1257  template<typename Cost>
1259  m_mapV_l2w[loser] = winner;
1260  (*m_mapVwinner)[winner] = (*m_mapVloser)[loser];
1261  }
1262 
1263  template<typename Cost>
1265  node newNode = m_gWinner->newNode();
1266  m_mapV_l2w[loser] = newNode;
1267  (*m_mapVwinner)[newNode] = (*m_mapVloser)[loser];
1268  }
1269 
1270  template<typename Cost>
1271  void GlueMap<Cost>::reorder(node vLoser, bool sameDirection, bool isTNodeOfPNode){
1272  node vWinner = m_mapV_l2w[vLoser];
1273  List<adjEntry> rightAdjOrder;
1274  List<adjEntry> wrongAdjOrder;
1275  vWinner->allAdjEntries(wrongAdjOrder);
1276  OGDF_ASSERT(wrongAdjOrder.size() == vWinner->degree());
1277 
1278  OGDF_ASSERT(vLoser->degree() <= vWinner->degree());
1279  // for every adjEntry of v in the "right" graph (the embedding which we want to get into the "wrong" graph)
1280  // we search for the corresponding adjEntry in the list of adjEntries of the "wrong" v
1281  for(adjEntry adj : vLoser->adjEntries){
1282  OGDF_ASSERT(m_mapE_l2w[adj->theEdge()] != nullptr);
1283  edge edgeInWinner = m_mapE_l2w[adj->theEdge()];
1284  adjEntry adj_in = (adj->theEdge()->adjSource() == adj ? edgeInWinner->adjSource() : edgeInWinner->adjTarget());
1285  rightAdjOrder.pushBack(adj_in);
1286  }
1287  List<adjEntry> adjOrder;
1288  vWinner->allAdjEntries(adjOrder);
1289  OGDF_ASSERT(vLoser->degree() <= adjOrder.size());
1290  if(!sameDirection){
1291  rightAdjOrder.reverse();
1292  }
1293  if(adjOrder.size() == rightAdjOrder.size()){
1294  adjOrder = rightAdjOrder;
1295  } else {
1296  List<adjEntry> helpList;
1297  adjOrder.split(adjOrder.get(adjOrder.size() - rightAdjOrder.size()), adjOrder, helpList);
1298  if(isTNodeOfPNode){
1299  adjOrder.concFront(rightAdjOrder);
1300  } else {
1301  adjOrder.conc(rightAdjOrder);
1302  }
1303  }
1304  m_gWinner->sort(vWinner, adjOrder);
1305  }
1306 } // end namespace ogdf
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:327
void markCore(NodeArray< bool > &mark)
Marks all nodes of the underlying SPQRTree and prunes planar leaves until the marked nodes span a tre...
void clear()
Removes all elements from the list.
Definition: List.h:1394
iterator begin()
Returns an iterator to the first entry in the edge array.
Definition: EdgeArray.h:243
const Graph & getLoserGraph() const
Getter for m_gLoser.
virtual edge realEdge(edge e) const =0
Returns the real edge that corresponds to skeleton edge e.
node tNode(edge e) const
Returns the t node of the skeleton of the st-component represented by the core edge e = (s...
virtual node twinTreeNode(edge e) const =0
Returns the tree node in T containing the twin edge of skeleton edge e.
Min-st-cut algorithm, that calculates the cut by calculating the shortest path between the faces adja...
void removePseudoCrossings()
Removes all crossing nodes which are actually only two "touching" edges.
NodeArray< node > m_mapV_l2w
A map from the nodes of the loser graph to their new home in the winner graph.
The parameterized class Queue<E> implements list-based queues.
Definition: Queue.h:213
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:95
bool valid() const
Returns true iff the iterator points to an element.
Definition: SList.h:113
const Graph * graphOf() const
Returns a pointer to the associated graph.
Definition: EdgeArray.h:164
iterator append(const E &x)
Adds x at the end of queue.
Definition: Queue.h:343
void getMincut(edge e, List< edge > &cut)
Get the mincut of e with respect to its position in the chain of its original edge.
EdgeArray< EdgeArray< edge > * > m_mapE
The mapping between the edges of each embedding and their original.
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
NodeArray< node > m_orig
Corresp. original node.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition: Graph_d.h:330
static const int Graph
Definition: GmlParser.h:59
NonPlanarCore< Cost > & m_npc
The NonPlanarCore on which this instance operates.
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
void conc(List< E > &L2)
Appends L2 to this list and makes L2 empty.
Definition: List.h:1431
Singly linked lists.
Definition: SList.h:38
const EdgeArray< edge > * m_mapEloser
A map from the edges of the loser graph to the original graph, to denote the original of each node...
const Graph & getGraph() const
Returns a reference to the skeleton graph M.
Definition: Skeleton.h:99
void normalizeCutEdgeDirection(edge coreEdge)
Every edge of coreEdge&#39;s cut that doesn&#39;t go the same direction as coreEdge gets reversed.
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:208
node original(node v) const
Returns the node of the original graph, which is represented by v in the core.
GraphCopy * m_endGraph
A pointer to a copy of the original graph, in which crossings are replaced by dummy nodes...
iterator begin()
Returns an iterator to the first element of the list.
Definition: List.h:332
void split(iterator it, List< E > &L1, List< E > &L2, Direction dir=Direction::before)
Splits the list at element it into lists L1 and L2.
Definition: List.h:1451
iterator insertAfter(const E &x, iterator it)
Inserts element x after it.
Definition: List.h:1341
EdgeArray< edge > m_mapE_l2w
A map from the edges of the loser graph to their new home in the winner graph.
void glue(edge eWinner, edge eLoser)
Glues together the skeletons of eWinner and eLoser for pruned P- and S-nodes.
virtual node original(node v) const =0
Returns the vertex in the original graph G that corresponds to v.
void reorder(node vLoser, bool sameDirection, bool isTNodeOfPNode)
This method reorders the adjacency order of vLoser&#39;s counterpart in the winner graph according to the...
void glueMincuts(edge eWinner, edge eLoser)
Glues together the mincuts of the winner and the loser edge.
static const int H
Definition: GmlParser.h:68
Dynamic arrays indexed with adjacency entries.
StaticSPQRTree m_T
The SPQRTree that represents the original graph.
Encapsulates a pointer to an ogdf::SList element.
Definition: SList.h:40
iterator end()
Returns an iterator to one-past-last entry in the edge array.
Definition: EdgeArray.h:261
const Graph & core() const
Returns the non-planar core.
GraphCopy const * m_planarCore
A pointer to a copy of the core, in which crossings are replaced by dummy nodes.
void call(const Graph &G, const EdgeArray< TCost > *weight, MinSTCutModule< TCost > *minSTCutModule, bool nonPlanarityGuaranteed)
The private method behind the constructors.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:278
TCost cost(edge e) const
Returns the cost of e, which is the number of original edges crossed, if e is crossed, i.e.
Skeleton graphs of nodes in an SPQR-tree.
Definition: Skeleton.h:61
EdgeArray< edge > m_real
Corresp. original edge (0 if virtual)
void del(iterator it)
Removes it from the list.
Definition: List.h:1380
void parallelFreeSortUndirected(const Graph &G, SListPure< edge > &edges, EdgeArray< int > &minIndex, EdgeArray< int > &maxIndex)
Sorts the edges of G such that undirected parallel edges come after each other in the list...
EdgeArray< NodeArray< node > * > m_mapV
The mapping between the nodes of each embedding and their original.
const EdgeArray< TCost > & cost() const
Returns the costs of the edges in the core, which is the number of original edges crossed...
Graph * m_gWinner
The graph that eWinner represents.
node sNode(edge e) const
Returns the s node of the skeleton of the st-component represented by the core edge e = (s...
virtual bool direction(edge e)
Returns the direction of e in the cut.
void retransform(const GraphCopy &planarCore, GraphCopy &planarGraph, bool pCisPlanar=true)
Inserts the crossings from a copy of the core into a copy of the original graph.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:548
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...
const Graph * m_gLoser
The graph that eLoser represents.
void reverse()
Reverses the order of the list elements.
Definition: List.h:1044
EdgeArray< edge > * m_mapEwinner
A map from the edges of the winner graph to the original graph, to denote the original of each edge...
const bool dir
true, iff the edge is directed from the s partition to the t partion
Definition: NonPlanarCore.h:78
iterator begin()
Returns an iterator to the first element of the list.
Definition: SList.h:316
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
Definition: List.h:1303
Declaration of class StaticSPQRTree.
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: SList.h:455
Min-st-cut algorithm, that calculates the cut by doing a depth first search over the dual graph of of...
Definition: MinSTCutBFS.h:52
const List< CutEdge > & mincut(edge e) const
Returns the mincut of the st-component represented by e.
Declaration of min-st-cut algorithm which calculates the min-st-cut of an st-planar graph by doing di...
void getAllMultiedges(List< edge > &winningEdges, List< edge > &losingEdges)
Checks for multiedges in the core.
const_reference front() const
Returns a const reference to the first element.
Definition: List.h:254
Graph m_graph
The core.
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
iterator end()
Returns an iterator to one-past-last element of the list.
Definition: List.h:350
friend class GlueMap
Definition: NonPlanarCore.h:69
Declaration and implementation of list-based queues (classes QueuePure<E> and Queue<E>).
const NodeArray< node > * m_mapVloser
A map from the nodes of the loser graph to the original graph, to denote the original of each node...
void splitEdgeIntoSections(edge e, List< node > &splitdummies)
To be able to insert crossings correctly, an end graph edge ought to be split into n-1 sections if n ...
bool isPlanar(const Graph &G)
Returns true, if G is planar, false otherwise.
bool isBiconnected(const Graph &G, node &cutVertex)
Returns true iff G is biconnected.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Definition: Graph_d.h:105
Class for the representation of edges.
Definition: Graph_d.h:291
E popFrontRet()
Removes the first element from the list and returns it.
Definition: List.h:1360
bool empty() const
Returns true iff the queue is empty.
Definition: Queue.h:251
void allAdjEntries(ADJLIST &adjList) const
Returns a list with all adjacency entries of this node.
Definition: Graph_d.h:226
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:250
const_iterator get(int pos) const
Returns a const iterator pointing to the element at position pos.
Definition: List.h:290
EdgeArray< TCost > m_cost
Costs to cross each edge of the core.
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
Definition: Graph_d.h:213
List< edge > original(edge e) const
Returns the edges of the original graph, which are represented by e in the core.
const edge e
the edge
Definition: NonPlanarCore.h:77
Class for the representation of nodes.
Definition: Graph_d.h:167
const edge m_eWinner
The core edge that will survive.
CutEdge(edge paramEdge, bool directed)
Definition: NonPlanarCore.h:80
EdgeArray< List< CutEdge > > m_mincut
Traversing path for an edge in the core.
void removeSplitdummies(List< node > &splitdummies)
After inserting the crossings, the end graph edges don&#39;t need to be partitioned anymore so the splitd...
void importEmbedding(edge e)
This method asserts that all parts of the end graph that are represented by edge e internally have th...
void mapLoserToNewWinnerEdge(edge eInLoser)
A mapping from the eInLoser graph to a new edge in the winner graph is created.
virtual ~NonPlanarCore()
node treeNode() const
Returns the corresponding node in the owner tree T to which S belongs.
Definition: Skeleton.h:85
EdgeArray< node > m_sNode
The s node of the st-component of a core edge.
node m_current
const Graph & originalGraph() const
Returns the original graph.
Linear-time implementation of static SPQR-trees.
int pos(const_iterator it) const
Returns the position (starting with 0) of iterator it in the list.
Definition: List.h:312
bool removeFirst(const E &x)
Removes the first occurrence of x (if any) from the list.
Definition: List.h:1386
Non-planar core reduction.
Definition: NonPlanarCore.h:66
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:145
Struct to represent an edge that needs to be crossed in order to cross an st-component.
Definition: NonPlanarCore.h:76
int size() const
Returns the number of elements in the list.
Definition: List.h:1255
node m_parent
void mapLoserToNewWinnerNode(node vInLoser)
A mapping from the vInLoser to a new node in the winner graph is created.
Declaration of simple graph algorithms.
void allNodes(NODELIST &nodeList) const
Returns a list with all nodes of the graph.
Definition: Graph_d.h:631
EdgeArray< edge > * mapE(edge e) const
Returns a map from the edges of the st-component represented by the core edge e to the original graph...
NonPlanarCore(const Graph &G, bool nonPlanarityGuaranteed=false)
The unweighted version of the Algorithm call and constructor.
NodeArray< node > * m_mapVwinner
A map from the nodes of the winner graph to the original graph, to denote the original of each edge...
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:325
EdgeArray< Graph * > m_underlyingGraphs
The graph for the underlying skeleton of a virtual edge in the core.
This is a helper class to make the glueing of two edges simpler.
EdgeArray< node > m_tNode
The t node of the st-component of a core edge.
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
void concFront(List< E > &L2)
Prepends L2 to this list and makes L2 empty.
Definition: List.h:1438
The namespace for all OGDF objects.
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:578
void mapLoserToWinnerNode(node vInLoser, node vInWinner)
A mapping from the vInLoser to the vInWinner is created.
E pop()
Removes front element and returns it.
Definition: Queue.h:357
node newNode()
Creates a new node and returns it.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:545
virtual bool call(const Graph &graph, const EdgeArray< TCost > &weight, node s, node t, List< edge > &edgeList, edge e_st=nullptr)=0
The actual algorithm call.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:211
void inflateCrossing(node v)
The crossing denoted by dummy node v from the planarized copy of the core get inserted into the end g...
void traversingPath(const Skeleton &Sv, edge eS, List< CutEdge > &path, NodeArray< node > &mapV, edge coreEdge, const EdgeArray< TCost > *weight_src, MinSTCutModule< TCost > *minSTCutModule)
Computes the traversing path for a given edge and the unmarked tree rooted in the node of eS and save...
bool isVirtual(edge e) const
True iff the edge e in the core represents more than one orginal edge and therefore is virtual...
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
const Graph * m_pOriginal
The original graph.
const edge m_eLoser
The core edge that will be deleted.
Declaration of min-st-cut algorithm which calculates the min-st-cut of an st-planar graph by doing a ...
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition: Graph_d.h:332
node getWinnerNodeOfLoserNode(node v) const
Getter for m_mapV_l2w.
bool empty() const
Returns true iff the list is empty.
Definition: List.h:236
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
QueueEntry(node p, node v)
edge realEdge(edge e) const
Returns the edge of the orginal graph, which is represented by e or nullptr iff e is virtual...
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