Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

CompactionConstraintGraph.h
Go to the documentation of this file.
1 
35 #pragma once
36 
40 #include <ogdf/planarity/PlanRep.h>
41 
42 namespace ogdf {
43 
46 {
47 public:
50 
52  bool verticalGen(edge e) const {return m_verticalGen[e];}
53 
56  bool verticalArc(edge e) const {return m_verticalArc[e];}
57 
59 
61  void align(bool b) {m_align = b;}
62 
65  bool alignmentArc(edge e) const {return m_alignmentArc[e];}
66 
68 
69 protected:
72  const PlanRep &PG,
73  OrthoDir arcDir,
74  int costGen = 1,
75  int costAssoc = 1, bool align = false);
76 
77  int m_edgeCost[2];
78 
79  //test fuer vorkomp. der Generalisierungen
82 
85 
87 
88 private:
89  //set special costs for node to merger generalizations
90  bool m_align;
91 
92  void insertPathVertices(const PlanRep &PG);
94  node v,
95  node pathVertex,
96  NodeArray<bool> &visited,
97  const NodeArray<node> &genOpposite);
98 
99  void insertBasicArcs(const PlanRep &PG);
100 };
101 
102 
113 template<class ATYPE>
115 {
116 public:
119  const PlanRep &PG,
120  OrthoDir arcDir,
121  ATYPE sep,
122  int costGen = 1,
123  int costAssoc = 1,
124  bool align = false) :
125  CompactionConstraintGraphBase(OR, PG, arcDir, costGen, costAssoc, align)
126  {
127  OGDF_ASSERT(&(const Graph &)PG == &(const Graph &)OR);
128 
129  m_length .init((Graph&)*this, sep);
130  m_extraOfs .init((Graph&)*this, 0);
131  m_extraRep .init((Graph&)*this, nullptr);
132 
133  m_sep = sep;
134 
135  m_centerPriority = true; //should centering of single edges have prio. to gen. length
136  m_genToMedian = true; //should outgoing merger gen. be drawn to merger median
137 
138  initializeCosts();
139  }
140 
143  ATYPE length(edge e) const {
144  return m_length[e];
145  }
146 
148  ATYPE extraOfs(node v) const {
149  return m_extraOfs[v];
150  }
151 
153  bool centerPriority() {return m_centerPriority;}
155  void centerPriority(bool b) { m_centerPriority = b;}
156 
159  ATYPE computeTotalCosts(const NodeArray<ATYPE> &pos) const;
160 
165  void insertVertexSizeArcs(
166  const PlanRep &PG,
167  const NodeArray<ATYPE> &sizeOrig,
168  const RoutingChannel<ATYPE> &rc);
169 
175  void insertVertexSizeArcs(
176  const PlanRep &PG,
177  const NodeArray<ATYPE> &sizeOrig,
178  const MinimumEdgeDistances<ATYPE> &minDist);
179 
183  void insertVisibilityArcs(
184  const PlanRep &PG,
185  const NodeArray<ATYPE> &posDir,
186  const NodeArray<ATYPE> &posOppDir
187  );
188 
189  void insertVisibilityArcs(
190  const PlanRep &PG,
191  const NodeArray<ATYPE> &posDir,
192  const NodeArray<ATYPE> &posOrthDir,
193  const MinimumEdgeDistances<ATYPE> &minDist);
194 
196  void setMinimumSeparation(const PlanRep &PG,
197  const NodeArray<int> &coord,
198  const MinimumEdgeDistances<ATYPE> &minDist);
199 
204  bool isFeasible(const NodeArray<ATYPE> &pos);
205 
207  ATYPE separation() const {return m_sep;}
208 
210  bool areMulti(edge e1, edge e2) const;
211 
212 private:
214  struct Interval
215  {
216  Interval(node v, ATYPE low, ATYPE high) {
217  m_low = low;
218  m_high = high;
219  m_pathNode = v;
220  }
221 
222  ATYPE m_low, m_high;
224 
226  friend std::ostream &operator<<(std::ostream &os,
227  const Interval &interval)
228  {
229  os << "[" << interval.m_low << "," << interval.m_high <<
230  ";" << interval.m_pathNode << "]";
231  return os;
232  }
233  };
234 
240  {
241  public:
243  const NodeArray<int> &secSort) {
244  m_pPos = &segPos;
245  m_pSec = &secSort;
246  }
247 
248  int compare(const node &x, const node &y) const {
249  ATYPE d = (*m_pPos)[x] - (*m_pPos)[y];
250  if (d < 0)
251  return -1;
252  else if (d > 0)
253  return 1;
254  else
255  return (*m_pSec)[x] - (*m_pSec)[y];
256  }
257 
259  private:
262  };
263 
264  virtual string getLengthString(edge e) const override {
265  return to_string(m_length[e]);
266  }
267 
268  void setBasicArcsZeroLength(const PlanRep &PG);
269  void resetGenMergerLengths(const PlanRep &PG, adjEntry adjFirst);
270  void setBoundaryCosts(adjEntry cornerDir,adjEntry cornerOppDir);
271 
272  bool checkSweepLine(const List<Interval> &sweepLine) const;
273 
274  ATYPE m_sep;
275 
277 
279 
282 
283  // we make vertex size arcs more expensive than basic arcs in order
284  // to get small cages
285  // should be replaced by option/value dependent on e.g. degree
291  //this does not work if generalization costs are set very small by the user
292  //because there must be a minimum cost for centering
294 
295  //factor of costs relative to generalization
296  static const int c_vertexArcFactor;
297  static const int c_bungeeFactor;
298  static const int c_doubleBendFactor;
299  static const int c_MedianFactor;
300 
302 
303 protected:
305  void setExtra(node v, node rep, ATYPE ofs) {
306  m_extraNode[v] = true;
307  m_extraRep[v] = rep;
308  m_extraOfs[v] = ofs;
309  }
310 
312  {
313  // we make vertex size arcs more expensive than basic arcs in order
314  // to get small cages; not necessary if cage size fixed in improvement
315  // cost should be dependend on degree
316  // Z.B. DURCH OPTION ODER WERT; DER VON DER ZAHL ADJAZENTER KANTEN ABHAENGIG IST
317  // should be derived by number of edges times something
318  int costGen = m_edgeCost[static_cast<int>(Graph::EdgeType::generalization)];
319 
320  m_vertexArcCost = c_vertexArcFactor*costGen; //spaeter aus Kompaktierungsmodul uebergeben
321  if (m_centerPriority)
322  m_bungeeCost = c_bungeeFactor*costGen+1;//-1;//for distance to middle position,
323  else
324  m_bungeeCost = c_bungeeFactor*4+1;//-1;//for distance to middle position,
325  //addition value should be < gen cost!!!
326  m_MedianArcCost = c_MedianFactor*m_vertexArcCost;
327  m_doubleBendCost = c_doubleBendFactor*m_vertexArcCost;
328  }
329 };
330 
331 //initialization of static members
332 template<class ATYPE>
334 template<class ATYPE>
336 template<class ATYPE>
337 const int CompactionConstraintGraph<ATYPE>::c_doubleBendFactor = 20; //double bends cost mxxx*vertexArcCost
338 //factor *VertexArcCost, costs for pulling generalization to median position at merger
339 template<class ATYPE>
340 const int CompactionConstraintGraph<ATYPE>::c_MedianFactor = 10*c_doubleBendFactor;
341 
342 
343 // allow 0-length for sides of generalization merger cages
344 template<class ATYPE>
346  const PlanRep &PG,
347  adjEntry adjFirst)
348 {
349  adjEntry adj = adjFirst;
350  int faceSize = 0;
351 
352  do {
353  if ((m_pOR->direction(adj) == m_arcDir ||
354  m_pOR->direction(adj) == m_oppArcDir) &&
355  (PG.typeOf(adj->theNode()) == Graph::NodeType::dummy ||
356  PG.typeOf(adj->twinNode()) == Graph::NodeType::dummy))
357  {
358  m_length[m_edgeToBasicArc[adj]] = 0;
359  }
360 
361  adj = adj->faceCycleSucc();
362  faceSize++;
363  } while(adj != adjFirst);
364 
365  //generalization position section
366  //pull upper generalization to median of merger cage's incoming lower generalizations
367 
368  if (m_genToMedian
369  && (m_pOR->direction(adjFirst) == m_arcDir
370  || m_pOR->direction(adjFirst) == m_oppArcDir)) {
371  int numIncoming = faceSize - 3;
372  int median = (numIncoming / 2) + 1;
373 
374  // if (numIncoming == 2) ... just the middle position
375  node upper = m_pathNode[adjFirst->theNode()];
376  if (PG.typeOf(adjFirst->theNode()) != Graph::NodeType::generalizationMerger) {
378  }
379 
380  node vMin;
381  if (m_pOR->direction(adjFirst) == m_arcDir) {
382  vMin = adjFirst->faceCyclePred()->theNode();
383  } else {
384  vMin = adjFirst->faceCycleSucc()->theNode();
385  }
386 
387  adj = adjFirst->faceCycleSucc(); // target right or left boundary, depending on drawing direction
388  for (int i = 0; i < median; i++) {
389  adj = adj->faceCycleSucc();
390  }
391 
392  node lower = m_pathNode[adj->theNode()];
393  node vCenter = newNode();
394  setExtra(vCenter, vMin, 0);
395 
396  // it seems we dont need the helper, as only source-adjEntries lying on
397  // the outer face are considered later, but keep it in mind
398 #if 0
399  edge helper = newEdge(m_pathNode[vMin], vCenter);
400  m_length[helper] = 0;
401  m_cost[helper] = 0;
403 #endif
404 
405  edge e1 = newEdge(vCenter,upper);
406  m_length[e1] = 0;
407  m_cost[e1] = m_MedianArcCost;
409 
410  edge e2 = newEdge(vCenter,lower);
411  m_length[e2] = 0;
412  m_cost[e2] = m_MedianArcCost;
414  }
415 }
416 
417 
418 // set cost of edges on the cage boundary to 0
419 template<class ATYPE>
421  adjEntry cornerDir,
422  adjEntry cornerOppDir)
423 {
424 #if 0
425  adjEntry adj;
426  for (adj = cornerDir; m_pOR->direction(adj) == m_arcDir; adj = adj->faceCycleSucc())
427  m_cost[m_edgeToBasicArc[adj]] = 0;
428  for (adj = cornerOppDir; m_pOR->direction(adj) == m_oppArcDir; adj = adj->faceCycleSucc())
429  m_cost[m_edgeToBasicArc[adj]] = 0;
430 #endif
431  //test for multi separation
432  adjEntry adj;
433  for (adj = cornerDir; m_pOR->direction(adj) == m_arcDir; adj = adj->faceCycleSucc())
434  {
435  m_cost[m_edgeToBasicArc[adj]] = 0;
436 
437  if (m_pathNode[adj->twin()->cyclicSucc()->theNode()] &&
438  (m_pOR->direction(adj->faceCycleSucc()) == m_arcDir)
439  )
441  m_pPR->original(adj->twin()->cyclicSucc()->theEdge());
442 
443  }
444  for (adj = cornerOppDir; m_pOR->direction(adj) == m_oppArcDir; adj = adj->faceCycleSucc())
445  {
446  m_cost[m_edgeToBasicArc[adj]] = 0;
447 
448  if (m_pathNode[adj->twin()->cyclicSucc()->theNode()])
450  m_pPR->original(adj->twin()->cyclicSucc()->theEdge());
451  }
452 }
453 
454 
455 //
456 // insert arcs required for respecting vertex sizes, sizes of routing channels
457 // and position of attached generalizations
458 // vertices are represented by variable cages
459 template<class ATYPE>
461  const PlanRep &PG,
462  const NodeArray<ATYPE> &sizeOrig,
463  const RoutingChannel<ATYPE> &rc)
464 {
465 
466  // segments in constraint graph are sides sMin and sMax; other two side
467  // are sides in which adjacency entries run in direction m_arcDir and
468  // m_oppArcDir
471 
472  const ATYPE overhang = rc.overhang();
473 
474  for(node v : PG.nodes)
475  {
476  if (PG.expandAdj(v) == nullptr) continue;
477 
479  {
480  resetGenMergerLengths(PG,PG.expandAdj(v));
481 
482  }
483  else // high/low-degree expander
484  {
485  ATYPE size = sizeOrig[v];
486 
487  const OrthoRep::VertexInfoUML &vi = *m_pOR->cageInfo(v);
488 
489  // determine routing channels rcMin and rcMax
490  ATYPE rcMin = overhang + rc(v,dirMin);
491  ATYPE rcMax = overhang + rc(v,dirMax);
492 
493  adjEntry cornerDir = vi.m_corner[static_cast<int>(m_arcDir)];
494  adjEntry cornerOppDir = vi.m_corner[static_cast<int>(m_oppArcDir)];
495  adjEntry cornerMin = vi.m_corner[static_cast<int>(dirMin)];
496  adjEntry cornerMax = vi.m_corner[static_cast<int>(dirMax)];
497 
498  // set cost of edges on the cage boundary to 0
499  setBoundaryCosts(cornerDir,cornerOppDir);
500 
501  const OrthoRep::SideInfoUML &sDir = vi.m_side[static_cast<int>(m_arcDir)];
502  const OrthoRep::SideInfoUML &sOppDir = vi.m_side[static_cast<int>(m_oppArcDir)];
503 
504  // correct lengths of edges within cage adjacent to corners
505  if(sDir.totalAttached() > 0) {
506  m_length[m_edgeToBasicArc[cornerDir]] = rcMin;
507  m_length[m_edgeToBasicArc[cornerMax->faceCyclePred()]] = rcMax;
508  } else {
509  // if no edges are attached at this side we need no constraint
510  m_length[m_edgeToBasicArc[cornerDir]] = 0;
511  delEdge(m_edgeToBasicArc[cornerDir]);
512  }
513 
514  if(sOppDir.totalAttached() > 0) {
515  m_length[m_edgeToBasicArc[cornerOppDir]] = rcMax;
516  m_length[m_edgeToBasicArc[cornerMin->faceCyclePred()]] = rcMin;
517  } else {
518  // if no edges are attached at this side we need no constraint
519  m_length[m_edgeToBasicArc[cornerOppDir]] = 0;
520  delEdge(m_edgeToBasicArc[cornerOppDir]);
521  }
522 
523 
524  // insert arcs for respecting vertex size / position of generalizations
525  node vMin = m_pathNode[cornerDir->theNode()];
526  node vMax = m_pathNode[cornerOppDir->theNode()];
527 
528  // any attached generalizations ?
529  if (sDir.m_adjGen == nullptr && sOppDir.m_adjGen == nullptr)
530  {
531  // no, only one arc for vertex size + routing channels
532  edge e = newEdge(vMin,vMax);
533  m_length[e] = rcMin + size + rcMax - 2*overhang;
534  m_cost [e] = 2*m_vertexArcCost;
536 
537  } else {
538  // yes, then two arcs for each side with an attached generalization
539  ATYPE minHalf = size/2;
540  ATYPE maxHalf = size - minHalf;
541  ATYPE lenMin = rcMin + minHalf - overhang;
542  ATYPE lenMax = maxHalf + rcMax - overhang;
543 
544  if (sDir.m_adjGen != nullptr) {
545  node vCenter = m_pathNode[sDir.m_adjGen->theNode()];
546  edge e1 = newEdge(vMin,vCenter);
547  m_length[e1] = lenMin;
548  m_cost [e1] = m_vertexArcCost;
550  edge e2 = newEdge(vCenter,vMax);
551  m_length[e2] = lenMax;
552  m_cost [e2] = m_vertexArcCost;
554  }
555 
556  if (sOppDir.m_adjGen != nullptr) {
557  node vCenter = m_pathNode[sOppDir.m_adjGen->theNode()];
558  edge e1 = newEdge(vMin,vCenter);
559  m_length[e1] = lenMin;
560  m_cost [e1] = m_vertexArcCost;
562  edge e2 = newEdge(vCenter,vMax);
563  m_length[e2] = lenMax;
564  m_cost [e2] = m_vertexArcCost;
566  }
567  }
568  }
569  }
570 }
571 
572 template<class ATYPE>
574  const PlanRep &PG)
575 {
576  for(edge e : PG.edges)
577  {
578  edge arc = m_edgeToBasicArc[e];
579  if (arc == nullptr) continue;
580 
581  node v = e->source();
582  node w = e->target();
583  if ( ((PG.typeOf(v) == Graph::NodeType::dummy) && (PG.typeOf(w) == Graph::NodeType::dummy) &&
584  (v->degree() == 2) && w->degree() == 2) &&
585  (m_pOR->angle(e->adjSource()) == m_pOR->angle(e->adjTarget()) ) && //no uturns
587  )
588  {
589  m_length[arc] = 0;
591  //we make fixtozero arcs as expensive as possible
592  m_cost[arc] = m_doubleBendCost;
593  }
594  }
595 }
596 
597 
598 
599 //
600 // insert arcs required for respecting vertex sizes
601 // and position of attached generalizations
602 // vertices are represented by tight cages
603 template<class ATYPE>
605  const PlanRep &PG,
606  const NodeArray<ATYPE> &sizeOrig,
607  const MinimumEdgeDistances<ATYPE> &minDist)
608 {
609  // set the length of all basic arcs corresponding to inner edge segments
610  // to 0
611  setBasicArcsZeroLength(PG);
612 
613  // segments in constraint graph are sides sMin and sMax; other two side
614  // are sides in which adjacency entries run in direction m_arcDir and
615  // m_oppArcDir
618 
619  for(node v : PG.nodes)
620  {
621  if (PG.expandAdj(v) == nullptr) continue;
622 
624  {
625  resetGenMergerLengths(PG,PG.expandAdj(v));
626 
627  }
628  else // high/low-degree expander
629  {
630  ATYPE size = sizeOrig[v];
631  const OrthoRep::VertexInfoUML &vi = *m_pOR->cageInfo(v);
632 
633  adjEntry cornerDir = vi.m_corner[static_cast<int>(m_arcDir)];
634  adjEntry cornerOppDir = vi.m_corner[static_cast<int>(m_oppArcDir)];
635  adjEntry cornerMin = vi.m_corner[static_cast<int>(dirMin)];
636  adjEntry cornerMax = vi.m_corner[static_cast<int>(dirMax)];
637 
638  adjEntry adj = cornerDir, last = cornerMax->faceCyclePred();
639  if(adj != last) {
640  m_length[m_edgeToBasicArc[adj]] = minDist.epsilon(v,m_arcDir,0);
641  m_length[m_edgeToBasicArc[last]] = minDist.epsilon(v,m_arcDir,1);
642  int i = 0;
643  for(adj = adj->faceCycleSucc(); adj != last; adj = adj->faceCycleSucc()) {
645  i++;
646  m_length[m_edgeToBasicArc[adj]] = minDist.delta(v,m_arcDir,i);
647  }
648  }
649 
650  adj = cornerOppDir, last = cornerMin->faceCyclePred();
651  if(adj != last) {
652  m_length[m_edgeToBasicArc[adj]] = minDist.epsilon(v,m_oppArcDir,0);
653  m_length[m_edgeToBasicArc[last]] = minDist.epsilon(v,m_oppArcDir,1);
654  int i = 0;
655  for(adj = adj->faceCycleSucc(); adj != last; adj = adj->faceCycleSucc()) {
657  i++;
658  m_length[m_edgeToBasicArc[adj]] = minDist.delta(v,m_oppArcDir,i);
659  }
660  }
661 
662 
663  // insert arcs for respecting vertex size / position of generalizations
664  node vMin = m_pathNode[cornerDir->theNode()];
665  node vMax = m_pathNode[cornerOppDir->theNode()];
666 
667  const OrthoRep::SideInfoUML &sDir = vi.m_side[static_cast<int>(m_arcDir)];
668  const OrthoRep::SideInfoUML &sOppDir = vi.m_side[static_cast<int>(m_oppArcDir)];
669 
670  // any attached generalizations ?
671  if (sDir.m_adjGen == nullptr && sOppDir.m_adjGen == nullptr)
672  {
673  //check for single edge case => special treatment
674  //generic case could handle all numbers
675 
676  if (sDir.totalAttached() == 1 || sOppDir.totalAttached() == 1)
677  {
678  //first, insert a new center node and connect it
679  ATYPE lenMin = size/2;
680  ATYPE lenMax = size - lenMin;
681  node vCenter = newNode();
682  setExtra(vCenter, cornerDir->theNode(), lenMin);
683 
684  edge e1 = newEdge(vMin,vCenter);
685  m_length[e1] = lenMin;
686  m_cost[e1] = m_vertexArcCost;
688  edge e2 = newEdge(vCenter,vMax);
689  m_length[e2] = lenMax;
690  m_cost[e2] = m_vertexArcCost;
692 
693  if (sDir.totalAttached() == 1)
694  {
695 
696  //then, insert a moveable node connecting center
697  //and outgoing segment
698  node vBungee = newNode();
699  //+1 should fix the fixzerolength problem
700  setExtra(vBungee, cornerDir->theNode(), minDist.epsilon(v,m_arcDir,0) );
701 
702  edge eToBungee = newEdge(vMin, vBungee);
703  m_type[eToBungee] = ConstraintEdgeType::MedianArc; //BasicArc; // XXX: is this ok?
704  m_cost[eToBungee] = 0; // XXX: what about this?
705  m_length[eToBungee] = minDist.epsilon(v,m_arcDir,0);
706 
707  edge eBungeeCenter = newEdge(vBungee, vCenter);
708  //bungee, center and outgoing segment may build column if in the middle
709  m_type[eBungeeCenter] = ConstraintEdgeType::MedianArc;
710  m_cost[eBungeeCenter] = m_bungeeCost; // XXX: what about this?
711  m_length[eBungeeCenter] = 0;
712 
713  //attention: pathnode construct works only if degree 1
714  edge eBungeeOut = newEdge(vBungee, m_pathNode[cornerDir->twinNode()]);
715  //bungee, center and outgoing segment may build column if in the middle
717  m_cost[eBungeeOut] = m_bungeeCost; // XXX: what about this?
718  m_length[eBungeeOut] = 0;
719 #if 0
720  //connect outgoing segment and "right" segment, maybe obsolete
721  edge eFromOut = newEdge(m_pathNode[cornerDir->twinNode()], vMax);
722  m_type[eFromOut] = ConstraintEdgeType::BasicArc; // XXX
723  m_cost[eFromOut] = 0; // XXX
724  m_length[eFromOut] = minDist.epsilon(v,m_arcDir,1);
725 #endif
726  }
727  if ( sOppDir.totalAttached() == 1 && m_pathNode[cornerOppDir->twinNode()] != vMin )
728  {
729 
730  //then, insert a moveable node connecting center
731  //and outgoing segment
732  node vBungee = newNode();
733  //+1 for not fixzerolength
734  setExtra(vBungee, cornerDir->theNode(), minDist.epsilon(v,m_oppArcDir,0) );
735 
736  edge eToBungee = newEdge(vMin, vBungee);
737  m_type[eToBungee] = ConstraintEdgeType::MedianArc;//BasicArc; // XXX: is this ok?
738  m_cost[eToBungee] = 0; // XXX: what about this?
739  m_length[eToBungee] = minDist.epsilon(v,m_oppArcDir,0);
740 
741  edge eBungeeCenter = newEdge(vBungee, vCenter);
742  //bungee, center and outgoing segment may build column if in the middle
743  m_type[eBungeeCenter] = ConstraintEdgeType::MedianArc;
744  m_cost[eBungeeCenter] = m_bungeeCost; // XXX: what about this?
745  m_length[eBungeeCenter] = 0;
746 
747  //attention: pathnode construct works only if degree 1, sometimes not at all
748  edge eBungeeOut = newEdge(vBungee, m_pathNode[cornerOppDir->twinNode()]);
749  //bungee, center and outgoing segment may build column if in the middle
751  m_cost[eBungeeOut] = m_bungeeCost; // XXX: what about this?
752  m_length[eBungeeOut] = 0;
753 #if 0
754  //connect outgoing segment and "right" segment, maybe obsolete
755  edge eFromOut = newEdge(m_pathNode[cornerOppDir->twinNode()], vMax);
756  m_type[eFromOut] = ConstraintEdgeType::BasicArc; // XXX
757  m_cost[eFromOut] = 0; // XXX
758  m_length[eFromOut] = minDist.epsilon(v,m_oppArcDir,0);
759 #endif
760  }
761  } else {
762  // no, only one arc for vertex size + routing channels
763  edge e = newEdge(vMin,vMax);
764  m_length[e] = size;
765  m_cost[e] = 2*m_vertexArcCost;
767  }
768  } else {
769  // yes, then two arcs for each side with an attached generalization
770  ATYPE lenMin = size/2;
771  ATYPE lenMax = size - lenMin;
772 
773 #if 0
774  ATYPE len = size/2;
775 #endif
776 
777  if (sDir.m_adjGen != nullptr) {
778  node vCenter = m_pathNode[sDir.m_adjGen->theNode()];
779  edge e1 = newEdge(vMin,vCenter);
780  m_length[e1] = lenMin;
781  m_cost [e1] = m_vertexArcCost;
783  edge e2 = newEdge(vCenter,vMax);
784  m_length[e2] = lenMax;
785  m_cost [e2] = m_vertexArcCost;
787  }
788  else
789  {
790  if (sDir.totalAttached() == 1)
791  {
792  node vCenter = newNode();//m_pathNode[sOppDir.m_adjGen->theNode()]; //newNode();
793  setExtra(vCenter, cornerDir->theNode(), lenMin);
794 
795  edge e1 = newEdge(vMin,vCenter);
796  m_length[e1] = lenMin;
797  m_cost[e1] = m_vertexArcCost;
799  edge e2 = newEdge(vCenter,vMax);
800  m_length[e2] = lenMax;
801  m_cost[e2] = m_vertexArcCost;
803 
804  //then, insert a moveable node connecting center
805  //and outgoing segment
806  node vBungee = newNode();
807  //+1 for not fixzerolength
808  setExtra(vBungee, cornerDir->theNode(), minDist.epsilon(v,m_arcDir,0) );
809 
810  edge eToBungee = newEdge(vMin, vBungee);
811  m_type[eToBungee] = ConstraintEdgeType::MedianArc;//BasicArc; // XXX: is this ok?
812  m_cost[eToBungee] = 0; // XXX: what about this?
813  m_length[eToBungee] = minDist.epsilon(v,m_arcDir,0);
814 
815  edge eBungeeCenter = newEdge(vBungee, vCenter);
816  //bungee, center and outgoing segment may build column if in the middle
817  m_type[eBungeeCenter] = ConstraintEdgeType::MedianArc;
818  m_cost[eBungeeCenter] = m_bungeeCost; // XXX: what about this?
819  m_length[eBungeeCenter] = 0;
820 
821  //attention: pathnode construct works only if degree 1
822  edge eBungeeOut = newEdge(vBungee, m_pathNode[cornerDir->twinNode()]);
823  //bungee, center and outgoing segment may build column if in the middle
825  m_cost[eBungeeOut] = m_bungeeCost; // XXX: what about this?
826  m_length[eBungeeOut] = 0;
827 
828  }
829  }
830  if (sOppDir.m_adjGen != nullptr) {
831  node vCenter = m_pathNode[sOppDir.m_adjGen->theNode()];
832  edge e1 = newEdge(vMin,vCenter);
833  m_length[e1] = lenMin;
834  m_cost [e1] = m_vertexArcCost;
836  edge e2 = newEdge(vCenter,vMax);
837  m_length[e2] = lenMax;
838  m_cost [e2] = m_vertexArcCost;
840  }
841  else
842  {
843  //special case single edge to middle position
844  if ( sOppDir.totalAttached() == 1 && m_pathNode[cornerOppDir->twinNode()] != vMin )
845  {
846  node vCenter = newNode();//m_pathNode[sDir.m_adjGen->theNode()];//newNode();
847  setExtra(vCenter, cornerDir->theNode(), lenMin);
848 
849  edge e1 = newEdge(vMin,vCenter);
850  m_length[e1] = lenMin;
851  m_cost[e1] = m_vertexArcCost;
853  edge e2 = newEdge(vCenter,vMax);
854  m_length[e2] = lenMax;
855  m_cost[e2] = m_vertexArcCost;
857  //then, insert a moveable node connecting center
858  //and outgoing segment
859  node vBungee = newNode();
860  //+1 for not fixzerolength
861  setExtra(vBungee, cornerDir->theNode(), minDist.epsilon(v,m_oppArcDir,0) );
862 
863  edge eToBungee = newEdge(vMin, vBungee);
864  m_type[eToBungee] = ConstraintEdgeType::MedianArc;//BasicArc; // XXX: is this ok?
865  m_cost[eToBungee] = 0; // XXX: what about this?
866  m_length[eToBungee] = minDist.epsilon(v,m_oppArcDir,0);
867 
868  edge eBungeeCenter = newEdge(vBungee, vCenter);
869  //bungee, center and outgoing segment may build column if in the middle
870  m_type[eBungeeCenter] = ConstraintEdgeType::MedianArc;
871  m_cost[eBungeeCenter] = m_bungeeCost; // XXX: what about this?
872  m_length[eBungeeCenter] = 0;
873 
874  //attention: pathnode construct works only if degree 1
875  edge eBungeeOut = newEdge(vBungee, m_pathNode[cornerOppDir->twinNode()]);
876  //bungee, center and outgoing segment may build column if in the middle
878  m_cost[eBungeeOut] = m_bungeeCost; // XXX: what about this?
879  m_length[eBungeeOut] = 0;
880  }
881  }
882  }
883 
884  // set cost of edges on the cage boundary to 0
885  setBoundaryCosts(cornerDir,cornerOppDir);
886  }
887  }
888 #if 0
889  if (m_arcDir == OrthoDir::East) writeGML("eastvertexsizeinserted.gml");
890  else writeGML("northvertexsizeinserted.gml");
891 #endif
892 }
893 
894 
895 // computes the total costs for coordintes given by pos, i.e.,
896 // the sum of the weighted lengths of edges in the constraint graph.
897 template<class ATYPE>
899  const NodeArray<ATYPE> &pos) const
900 {
901  ATYPE c = 0;
902  for(edge e : edges) {
903  c += cost(e) * (pos[e->target()] - pos[e->source()]);
904  }
905 
906  return c;
907 }
908 
909 
910 //
911 // insertion of visibility arcs
912 
913 // checks if intervals on the sweep line are in correct order
914 template<class ATYPE>
916 {
917  if (sweepLine.empty())
918  return true;
919 
920  ListConstIterator<Interval> it = sweepLine.begin();
921 
922  if((*it).m_high < (*it).m_low)
923  return false;
924 
925  ATYPE x = (*it).m_low;
926 
927  for(++it; it.valid(); ++it) {
928  if((*it).m_high < (*it).m_low)
929  return false;
930  if ((*it).m_high > x)
931  return false;
932  x = (*it).m_low;
933  }
934 
935  return true;
936 }
937 
938 
939 template<class ATYPE>
941  const PlanRep &PG,
942  const NodeArray<ATYPE> &posDir,
943  const NodeArray<ATYPE> &posOrthDir
944  )
945 {
946  MinimumEdgeDistances<ATYPE> minDist(PG, m_sep);
947 
948  for(node v : PG.nodes)
949  {
950  if(PG.expandAdj(v) == nullptr) continue;
951 
952  for(int d = 0; d < 4; ++d) {
953  minDist.delta(v,OrthoDir(d),0) = m_sep;//currentSeparation;
954  minDist.delta(v,OrthoDir(d),1) = m_sep;//currentSeparation;
955  }
956  }
957 
958  insertVisibilityArcs(PG,posDir,posOrthDir,minDist);
959 }
960 
961 
962 
963 // inserts arcs connecting segments which can see each other in a drawing
964 // of the associated planarized representation PG which is given by
965 // posDir and posOppDir.
966 
967 //ersetze mindist.delta durch min(m_sep, mindist.delta) fuer skalierung
968 template<class ATYPE>
970  const PlanRep &PG,
971  const NodeArray<ATYPE> &posDir,
972  const NodeArray<ATYPE> &posOrthDir,
973  const MinimumEdgeDistances<ATYPE> &minDist)
974 {
976  OrthoDir segOppDir = OrthoRep::nextDir(m_arcDir);
977 
978  // list of visibility arcs which have to be inserted
979  SListPure<Tuple2<node,node> > visibArcs;
980 
981  // lower and upper bound of segments
982  NodeArray<ATYPE> low(getGraph()), lowReal(getGraph()), high(getGraph());
983  NodeArray<ATYPE> segPos(getGraph(), 0); // position of segments
984  NodeArray<int> topNum(getGraph()/*,0*/); // secondary sorting criteria for segments
985 
986  // compute position and lower/upper bound of segments
987  // We have to take care that segments cannot be shifted one upon the other,
988  // e.g., if we have two segments (l1,h1) and (l2,h2) with l2 > h2 and
989  // the distance l2-h2 is smaller than separation, the segments can see
990  // each other. We do this by enlarging the lower bound of all segments
991  // by separation if this lower bound is realized by a bend.
992  //
993  // Note: Be careful at segments attached at a vertex which are closer
994  // than separation to each other. Possible solution: Remove visibility
995  // arcs of segments which are connected by orthogonal segments to the
996  // same vertex and bend in opposite directions.
997  for(node v : nodes) {
998 
999  //special case nodes
1000  if (m_path[v].empty()) continue;
1001 
1002  SListConstIterator<node> it = m_path[v].begin();
1003 
1004  segPos[v] = posDir[*it];
1005  low[v] = high[v] = posOrthDir[*it];
1006  node nodeLow = *it;
1007  for(++it; it.valid(); ++it) {
1008  ATYPE x = posOrthDir[*it];
1009  if (x < low [v]) {
1010  low [v] = x;
1011  nodeLow = *it;
1012  }
1013  if (x > high[v]) high[v] = x;
1014  }
1015  lowReal[v] = low[v];
1016  Graph::NodeType typeLow = PG.typeOf(nodeLow);
1018 #if 0
1019  bool subtractSep = true;
1020  if (nodeLow->degree() == 2) {
1021  adjEntry adjFound = nullptr;
1022  for(adjEntry adj : nodeLow->adjEntries) {
1023  if(m_pOR->direction(adj) == m_arcDir || m_pOR->direction(adj) == m_oppArcDir) {
1024  adjFound = adj;
1025  break;
1026  }
1027  }
1028  if (adjFound) {
1029  for(adjEntry adj2 = adjFound->faceCycleSucc();
1030  m_pOR->direction(adj2) == m_pOR->direction(adjFound);
1031  adj2 = adj2->twin()->faceCycleSucc()) ;
1032  if(posDir[adjFound->theNode()] == posDir[adj2->twinNode()])
1033  subtractSep = false;
1034  }
1035  }
1036  if (subtractSep)
1037  low[v] -= m_sep;
1038 #else
1039  low[v] -= m_sep;
1040 #endif
1041  }
1042  }
1043 
1044  // correct "-= m_sep" ...
1047  bool isCaseA = (m_arcDir == OrthoDir::East || m_arcDir == OrthoDir::South);
1048  const int angleAtMin = (m_arcDir == OrthoDir::East || m_arcDir == OrthoDir::South) ? 3 : 1;
1049  const int angleAtMax = (m_arcDir == OrthoDir::East || m_arcDir == OrthoDir::South) ? 1 : 3;
1050 
1051  for(node v : PG.nodes)
1052  {
1053  if(PG.expandAdj(v) == nullptr) continue;
1054  const OrthoRep::VertexInfoUML &vi = *m_pOR->cageInfo(v);
1055 
1056  int i = 0;
1057  adjEntry adj;
1058 
1059  for (adj = (isCaseA) ? vi.m_corner[static_cast<int>(dirMin)]->faceCycleSucc()->faceCycleSucc() : vi.m_corner[static_cast<int>(dirMin)]->faceCycleSucc();
1060  m_pOR->direction((isCaseA) ? adj : adj->faceCycleSucc()) == dirMin; //m_pOR->direction(adj) == dirMin;
1061  adj = adj->faceCycleSucc())
1062  {
1063  adjEntry adjCross = adj->cyclicPred();
1064  adjEntry adjTwin = adjCross->twin();
1065 
1066  adjEntry adjPred = adj->faceCyclePred();
1067  ATYPE delta = (isCaseA) ?
1068  min(abs(posOrthDir[adjPred->theNode()] - posOrthDir[adjPred->twinNode()]), m_sep) :
1069  min(abs(posOrthDir[adj->theNode()] - posOrthDir[adj->twinNode()]), m_sep);
1070  ATYPE boundary = (isCaseA) ?
1071  min(posOrthDir[adjPred->theNode()], posOrthDir[adjPred->twinNode()]) :
1072  min(posOrthDir[adj->theNode()], posOrthDir[adj->twinNode()]);
1073 
1074  if (PG.typeOf(adjCross->theEdge()) == Graph::EdgeType::generalization)
1075  {
1076  if (isCaseA) {
1078  m_pOR->angle(adjTwin) == 2)
1079  {
1080  node s1 = m_pathNode[adjTwin->theNode()];
1081  node s2 = m_pathNode[adjTwin->cyclicSucc()->twinNode()];
1082  low[s1] = lowReal[s1] - delta; // minDist.delta(v,dirMin,i);
1083  low[s2] = lowReal[s2] - delta; //minDist.delta(v,dirMin,i);
1084  }
1085  ++i;
1086  } else {
1087  ++i;
1089  m_pOR->angle(adjTwin->cyclicPred()) == 2)
1090  {
1091  node s1 = m_pathNode[adjTwin->theNode()];
1092  node s2 = m_pathNode[adjTwin->cyclicPred()->twinNode()];
1093  low[s1] = lowReal[s1] - delta; //minDist.delta(v,dirMin,i);
1094  low[s2] = lowReal[s2] - delta; //minDist.delta(v,dirMin,i);
1095  }
1096  }
1097  continue;
1098  }
1099 
1100  //we save the current direction and stop if we run in opposite
1101  OrthoDir runDir = m_pOR->direction(adjCross);
1102  // if -> while
1103  while (PG.typeOf(adjTwin->theNode()) == Graph::NodeType::dummy &&
1104  adjTwin->theNode()->degree() == 2 &&
1105  m_pOR->angle(adjTwin) == angleAtMin)
1106  {
1107  // We handle the case if an edge segment adjacent to a vertex
1108  // is separated by less than separation from edge segments above.
1109  node s = m_edgeToBasicArc[adjCross]->source();
1110  if(lowReal[s] != low[s])
1111  {
1112  if(low[s] >= boundary) // nothing to do?
1113  break;
1114  low[s] = boundary;
1115 #if 0
1116  low[s] += m_sep - delta; //minDist.delta(v,dirMin,i);
1117 #endif
1118 
1119  // If the compaction has eliminated bends, we can have the situation
1120  // that segment s has length 0 and the next segment s' (following the
1121  // edge) is at the same position (the edge arc has length 0).
1122  // In this case, the low-value of s' must be lowered (low[s'] := lowReal[s']
1123  // is approproate). The same situation can appear several times in a
1124  // row.
1125  //collect chains of segments compacted to zero length
1126  for( ; ; ) { //while(true/*lowReal[s] == high[s]*/) {
1127  do {
1128  adjCross = adjCross->faceCycleSucc();
1129  } while(m_pOR->direction(adjCross) == segDir ||
1130  m_pOR->direction(adjCross) == segOppDir);
1131 
1132  if(adjCross->theNode()->degree() != 2) // no longer a bend point?
1133  break;
1134 
1135  node sNext = m_edgeToBasicArc[adjCross]->opposite(s);
1136 
1137  if(segPos[sNext] != segPos[s])
1138  break;
1139 
1140  low[sNext] = lowReal[sNext]; //?
1141  s = sNext;
1142  }
1143  }
1144 
1145  adjTwin = adjCross->twin(); // update of twin for while
1146  //check if we have to stop
1147  if (runDir != m_pOR->direction(adjCross)) break;
1148  }
1149  }
1150 
1151  i = 0;
1152  for (adj = (isCaseA) ? vi.m_corner[static_cast<int>(dirMax)]->faceCycleSucc() : vi.m_corner[static_cast<int>(dirMax)]->faceCycleSucc()->faceCycleSucc();
1153  m_pOR->direction((isCaseA) ? adj->faceCycleSucc() : adj) == dirMax; // m_pOR->direction(adj) == dirMax;
1154  adj = adj->faceCycleSucc())
1155  {
1156  adjEntry adjCross = adj->cyclicPred();
1157  adjEntry adjTwin = adjCross->twin();
1158 
1159 #if 0
1160  ATYPE delta = -posOrthDir[adj->twinNode()] + posOrthDir[adj->theNode()];
1161 #endif
1162  adjEntry adjPred = adj->faceCyclePred();
1163  ATYPE delta = (isCaseA) ?
1164  min(abs(posOrthDir[adj->twinNode()] - posOrthDir[adj->theNode()]), m_sep) :
1165  min(abs(posOrthDir[adjPred->theNode()] - posOrthDir[adjPred->twinNode()]), m_sep);
1166  ATYPE boundary = (isCaseA) ?
1167  min(posOrthDir[adj->twinNode()], posOrthDir[adj->theNode()]) :
1168  min(posOrthDir[adjPred->theNode()], posOrthDir[adjPred->twinNode()]);
1169 
1170  if (PG.typeOf(adjCross->theEdge()) == Graph::EdgeType::generalization)
1171  {
1172  if (isCaseA) {
1173  ++i;
1175  m_pOR->angle(adjTwin->cyclicPred()) == 2)
1176  {
1177  node s1 = m_pathNode[adjTwin->theNode()];
1178  node s2 = m_pathNode[adjTwin->cyclicPred()->twinNode()];
1179  low[s1] = lowReal[s1] - delta; //minDist.delta(v,dirMax,i);
1180  low[s2] = lowReal[s2] - delta; //minDist.delta(v,dirMax,i);
1181  }
1182  } else {
1184  m_pOR->angle(adjTwin) == 2)
1185  {
1186  node s1 = m_pathNode[adjTwin->theNode()];
1187  node s2 = m_pathNode[adjTwin->cyclicSucc()->twinNode()];
1188  low[s1] = lowReal[s1] - delta; //minDist.delta(v,dirMax,i);
1189  low[s2] = lowReal[s2] - delta; //minDist.delta(v,dirMax,i);
1190  }
1191  ++i;
1192  }
1193  continue;
1194  }
1195 
1196 
1197  //we save the current direction and stop if we run in opposite
1198  OrthoDir runDir = m_pOR->direction(adjCross);
1199  // if -> while
1200  while (PG.typeOf(adjTwin->theNode()) == Graph::NodeType::dummy &&
1201  adjTwin->theNode()->degree() == 2 &&
1202  m_pOR->angle(adjTwin) == angleAtMax)
1203  {
1204  node s = m_edgeToBasicArc[adjCross]->target();
1205  if(lowReal[s] != low[s])
1206  {
1207  if(low[s] >= boundary) // nothing to do?
1208  break;
1209  low[s] = boundary;
1210 #if 0
1211  low[s] += m_sep - delta; //minDist.delta(v,dirMax,i);
1212 #endif
1213 
1214  // If the compaction has eliminated bends, we can have the situation
1215  // that segment s has length 0 and the next segment s' (following the
1216  // edge) is at the same position (the edge arc has length 0).
1217  // In this case, the low-value of s' must be lowered (low[s'] := lowReal[s']
1218  // is approproate). The same situation can appear several times in a
1219  // row.
1220  //collect chains of segments compacted to zero length
1221  for( ; ; ) /*lowReal[s] == high[s]*/
1222  {
1223  do
1224  {
1225  adjCross = adjCross->faceCycleSucc();
1226  } while(m_pOR->direction(adjCross) == segDir ||
1227  m_pOR->direction(adjCross) == segOppDir);
1228 
1229  if(adjCross->theNode()->degree() != 2) // no longer a bend point?
1230  break;
1231 
1232  node sNext = m_edgeToBasicArc[adjCross]->opposite(s);
1233 
1234  if(segPos[sNext] != segPos[s])
1235  break;
1236 
1237  low[sNext] = lowReal[sNext];//was: low[s]
1238  s = sNext;
1239  }
1240  }
1241 
1242  adjTwin = adjCross->twin(); // update of twin for while
1243 
1244  //check if we have to stop
1245  if (runDir != m_pOR->direction(adjCross)) break;
1246  }
1247  }
1248  }
1249 
1250  // compute topological numbering of segments as second sorting criteria
1251  // in order to process overlapping segments in the order imposed by the
1252  // embedding
1254 
1255 
1256  // sort segments
1257  SegmentComparer cmpBySegPos(segPos,topNum);
1258  List<node> sortedPathNodes;
1259  allNodes(sortedPathNodes);
1260  sortedPathNodes.quicksort(cmpBySegPos);
1261 
1262  // add segments in the order given by sortedPathNodes to sweep line
1263  List<Interval> sweepLine;
1264 
1265  ListIterator<node> itV;
1266  for(itV = sortedPathNodes.begin(); itV.valid(); ++itV)
1267  {
1268  //special case nodes
1269  if (m_path[*itV].empty()) continue;
1270  OGDF_HEAVY_ASSERT(checkSweepLine(sweepLine));
1271 
1272  node v = *itV;
1274  for(it = sweepLine.begin(); it.valid(); ++it) {
1275  if ((*it).m_low < high[v])
1276  break;
1277  }
1278 
1279  if (!it.valid()) {
1280  sweepLine.pushBack(Interval(v,low[v],high[v]));
1281  continue;
1282  }
1283 
1284  if((*it).m_high <= low[v]) {
1285  sweepLine.insertBefore(Interval(v,low[v],high[v]),it);
1286  continue;
1287  }
1288 
1289  ListIterator<Interval> itUp = it, itSucc;
1290  // we store if itUp will be deleted in order not to
1291  // access the deleted iterator later
1292  bool isItUpDel = ( ((*itUp).m_low >= low[v]) && ((*itUp).m_high <= high[v]) );
1293 
1294  for(; it.valid() && (*it).m_low >= low[v]; it = itSucc) {
1295  itSucc = it.succ();
1296  if ((*it).m_high <= high[v]) {
1297  visibArcs.pushBack(Tuple2<node,node>((*it).m_pathNode,v));
1298  sweepLine.del(it);
1299  }
1300  }
1301 
1302  if (it == itUp && (*it).m_high > high[v]) {
1303  node w = (*it).m_pathNode;
1304  sweepLine.insertAfter(Interval(w,(*it).m_low,low[v]),it);
1305  (*it).m_low = high[v];
1306  sweepLine.insertAfter(Interval(v,low[v],high[v]),it);
1307  visibArcs.pushBack(Tuple2<node,node>(w,v));
1308 
1309  } else {
1310  if ( (!isItUpDel) && itUp != it && (*itUp).m_low < high[v]) {
1311  (*itUp).m_low = high[v];
1312  visibArcs.pushBack(Tuple2<node,node>((*itUp).m_pathNode,v));
1313  }
1314  if (it.valid()) {
1315  if ((*it).m_high > low[v]) {
1316  (*it).m_high = low[v];
1317  visibArcs.pushBack(Tuple2<node,node>((*it).m_pathNode,v));
1318  }
1319  sweepLine.insertBefore(Interval(v,low[v],high[v]),it);
1320 
1321  } else {
1322  sweepLine.pushBack(Interval(v,low[v],high[v]));
1323  }
1324  }
1325 
1326  }
1327 
1328  // remove all arcs from visibArcs that are already in the constraint graph
1329  removeRedundantVisibArcs(visibArcs);
1330 
1331  // compute original adjacency entry corresponding to a segment
1332  // We use this in order to omit visibility arcs between segments which
1333  // belong to the same edge if they can see each other from the same side
1334  // of the edge; if they see each other from different sides the arc is
1335  // essential!
1336  NodeArray<adjEntry> correspEdge(getGraph(),nullptr);
1337 
1338  for(node v : PG.nodes) {
1339  node seg = m_pathNode[v];
1340  for(adjEntry adj : v->adjEntries) {
1341  if(m_pOR->direction(adj) != segDir) continue;
1342  edge eAdj = adj->theEdge();
1343  edge eOrig = PG.original(eAdj);
1344  if (eOrig == nullptr) continue;
1345  if (adj == eAdj->adjSource())
1346  correspEdge[seg] = eOrig->adjSource();
1347  else
1348  correspEdge[seg] = eOrig->adjTarget();
1349  }
1350  }
1351 
1352  // remove visibility arcs between ...
1353  SListIterator<Tuple2<node,node> > itT, itTSucc, itTPred;
1354  for(itT = visibArcs.begin(); itT.valid(); itT = itTSucc) {
1355  itTSucc = itT.succ();
1356  node v = (*itT).x1(), w = (*itT).x2();
1357 
1358  // remove arcs which connect segments belonging to the same edge
1359  if (correspEdge[v] && (correspEdge[v] == correspEdge[w]))
1360  {
1361  if (itTPred.valid())
1362  visibArcs.delSucc(itTPred);
1363  else
1364  visibArcs.popFront();
1365  }
1366 
1367  else
1368  itTPred = itT;
1369  }
1370 
1371 
1372 
1373  for(itT = visibArcs.begin(); itT.valid(); ++itT) {
1374  //CHECK if
1375  node v = (*itT).x1(), w = (*itT).x2();
1376  if (!(m_extraNode[v] || m_extraNode[w])) {
1377  //CHECK if
1378  node boundRepresentant1 = m_path[v].front();
1379  node boundRepresentant2 = m_path[w].front();
1380  node en1 = m_pPR->expandedNode(boundRepresentant1);
1381  node en2 = m_pPR->expandedNode(boundRepresentant2);
1382  //do not insert visibility in cages
1383  if (!( ( en1 && en2 ) && ( en1 == en2) ))
1384  {
1385  edge e = newEdge(v,w);
1386 
1387  //hier vielleicht multiedges abfangen: length auf max(min(sep, dists), minDist.sep)
1388 
1389  m_length[e] = max(m_sep, minDist.separation()); //m_sep;
1390  m_cost [e] = 0;
1392 #if 0
1393  writeGML("visibilityinserted.gml");
1394 #endif
1395  }
1396  }
1397  }
1398 
1399  OGDF_HEAVY_ASSERT(checkSweepLine(sweepLine));
1400 }
1401 
1402 // performs feasibility test for position assignment pos, i.e., checks if
1403 // the segment positions given by pos fulfill the constraints in the
1404 // compaction constraint graph
1405 template<class ATYPE>
1407  const NodeArray<ATYPE> &pos)
1408 {
1409  for(edge e : getGraph().edges) {
1410  node v = m_path[e->source()].front();
1411  node w = m_path[e->target()].front();
1412  if (pos[w] - pos[v] < length(e)) {
1413  std::cout << "feasibility check failed for edge " << e << std::endl;
1414  std::cout << " representatives: " << v << ", " << w << std::endl;
1415  std::cout << " length: " << length(e) << std::endl;
1416  std::cout << " actual distance: " << pos[w] - pos[v] << std::endl;
1417  std::cout << " type of " << e << ": ";
1418  switch(m_type[e]) {
1419  case ConstraintEdgeType::BasicArc: std::cout << "basic arc" << std::endl;
1420  break;
1421  case ConstraintEdgeType::VertexSizeArc: std::cout << "vertex-size arc" << std::endl;
1422  break;
1423  case ConstraintEdgeType::VisibilityArc: std::cout << "visibility arc" << std::endl;
1424  break;
1425  case ConstraintEdgeType::MedianArc: std::cout << "median arc" << std::endl;
1426  break;
1427  case ConstraintEdgeType::ReducibleArc: std::cout << "reducible arc" <<std::endl;
1428  break;
1429  case ConstraintEdgeType::FixToZeroArc: std::cout << "fixtozero arc" <<std::endl;
1430 
1431  }
1432  return false;
1433  }
1434  }
1435 
1436  return true;
1437 }
1438 
1439 }
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:328
int m_MedianArcCost
draw merger gen at median of incoming generalizations
int m_doubleBendCost
try to minimize double bends
void delSucc(iterator itBefore)
Removes the succesor of itBefore.
Definition: SList.h:518
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:96
bool valid() const
Returns true iff the iterator points to an element.
Definition: SList.h:115
ListIteratorBase< E, isConst, isReverse > succ() const
Returns successor iterator.
Definition: List.h:145
void centerPriority(bool b)
Sets centerPriority (center single edges?)
void setBoundaryCosts(adjEntry cornerDir, adjEntry cornerOppDir)
void insertVertexSizeArcs(const PlanRep &PG, const NodeArray< ATYPE > &sizeOrig, const RoutingChannel< ATYPE > &rc)
Inserts arcs for respecting sizes of vertices and achieving desired placement of generalizations if v...
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:1373
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
int m_bungeeCost
middle position distance penalty
#define OGDF_AUGMENT_COMPARER(type)
Add this macro to your class to turn it into a full comparer.
Definition: comparer.h:157
NodeArray< node > m_pathNode
segment containing a node in PG
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition: Graph_d.h:333
bool checkSweepLine(const List< Interval > &sweepLine) const
Maintains input sizes for improvement compaction (deltas and epsilons)
NodeArray< bool > m_extraNode
Node does not represent drawing node as we dont have positions we save a drawing representant and an ...
ATYPE extraOfs(node v) const
Returns extraNode position, change to save mem, only need some entries.
Singly linked lists.
Definition: SList.h:38
Information about a side of a vertex in UML diagrams.
Definition: OrthoRep.h:240
#define OGDF_THROW(CLASS)
Replacement for throw.
Definition: exceptions.h:65
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:210
const Graph & getGraph() const
Returns underlying graph.
int angle(adjEntry adj) const
Definition: OrthoRep.h:328
const ATYPE & epsilon(node v, OrthoDir s, int i) const
adjEntry faceCyclePred() const
Returns the cyclic predecessor in face.
Definition: Graph_d.h:144
iterator begin()
Returns an iterator to the first element of the list.
Definition: List.h:352
Represents a constraint graph used for compaction.
EdgeArray< bool > m_alignmentArc
Basic arcs that have to be short for alignment (node to gen expander)
iterator insertAfter(const E &x, iterator it)
Inserts element x after it.
Definition: List.h:1398
Orthogonal representation of an embedded graph.
Definition: OrthoRep.h:236
virtual void delEdge(edge e)
Removes edge e from the graph.
Declaration of a base class for planar representations of graphs and cluster graphs.
Further information about the cages of vertices in UML diagrams.
Definition: OrthoRep.h:278
NodeArray< edge > m_originalEdge
save edge for the basic arcs
Encapsulates a pointer to an ogdf::SList element.
Definition: SList.h:39
SListIteratorBase< E, isConst > succ() const
Returns successor iterator.
Definition: SList.h:137
#define OGDF_HEAVY_ASSERT(expr)
Assert condition expr when using heavy debugging. See OGDF_ASSERT.
Definition: basic.h:44
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:279
Graph::NodeType typeOf(node v) const
Returns the type of node v.
Definition: PlanRep.h:208
Declaration of class RoutingChannel which maintains required size of routing channels and separation...
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:124
CompactionConstraintGraphBase(const OrthoRep &OR, const PlanRep &PG, OrthoDir arcDir, int costGen=1, int costAssoc=1, bool align=false)
Construction.
void del(iterator it)
Removes it from the list.
Definition: List.h:1437
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition: Graph_d.h:142
bool m_centerPriority
should centering be more expensive than generalizations
NodeArray< edge > m_pathToEdge
save the (single!) edge (segment) for a pathNode
Represents an interval on the sweep line.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:568
adjEntry expandAdj(node v) const
Returns the adjacency entry of a node of an expanded face.
Definition: PlanRep.h:159
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
ATYPE separation() const
Returns the separation value.
iterator begin()
Returns an iterator to the first element of the list.
Definition: SList.h:318
void removeRedundantVisibArcs(SListPure< Tuple2< node, node >> &visibArcs)
Removes "arcs" from visibArcs which we already have in the constraint graph (as basic arcs) ...
void quicksort()
Sorts the list using Quicksort.
Definition: List.h:1152
bool m_genToMedian
draw outgoing generalization from merger above ingoing gen.
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: SList.h:451
NodeArray< node > m_extraRep
existing representant of extranodes position anchor
Tuples of two elements (2-tuples).
Definition: tuples.h:46
CompactionConstraintGraph(const OrthoRep &OR, const PlanRep &PG, OrthoDir arcDir, ATYPE sep, int costGen=1, int costAssoc=1, bool align=false)
Construction.
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
bool verticalArc(edge e) const
Returns true if e is basic arc of vertical edge in PlanRepUML hierarchy.
A common base class for ogdf::GridCompactionConstraintGraphBase and ogdf::CompactionConstraintGraphBa...
const VertexInfoUML * cageInfo(node v) const
Definition: OrthoRep.h:353
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing...
Definition: exceptions.h:253
void setBasicArcsZeroLength(const PlanRep &PG)
static const int c_doubleBendFactor
double bends cost factor*vertexArcCost
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Definition: Graph_d.h:108
Class for the representation of edges.
Definition: Graph_d.h:292
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:105
void popFront()
Removes the first element from the list.
Definition: SList.h:497
void insertBasicArcs(const PlanRep &PG)
void resetGenMergerLengths(const PlanRep &PG, adjEntry adjFirst)
Maintains input sizes for constructive compaction (size of routing channels, separation, cOverhang)
Class for the representation of nodes.
Definition: Graph_d.h:169
Encapsulates a pointer to a list element.
Definition: List.h:42
node expandedNode(node v) const
Definition: PlanRep.h:597
SegmentComparer(const NodeArray< ATYPE > &segPos, const NodeArray< int > &secSort)
ATYPE length(edge e) const
Returns length of edge e.
void insertPathVertices(const PlanRep &PG)
virtual string getLengthString(edge e) const override
OrthoDir
Definition: OrthoRep.h:51
const Graph & original() const
Returns a reference to the original graph.
Definition: GraphCopy.h:286
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
Definition: Graph_d.h:284
EdgeArray< ATYPE > m_length
length of an edge
ATYPE overhang() const
inserted to replace some reducible in fixzerolength
Comparer class used for sorting segments by increasing position (given by segPos) such that two overl...
static OrthoDir prevDir(OrthoDir d)
Returns the previous OrthoDir (in a clockwise manner)
Definition: OrthoRep.h:444
ATYPE computeTotalCosts(const NodeArray< ATYPE > &pos) const
Computes the total costs for coordintes given by pos, i.e., the sum of the weighted lengths of edges ...
void computeTopologicalSegmentNum(NodeArray< int > &topNum)
Computes topological numbering on the segments of the constraint graph.
static OrthoDir nextDir(OrthoDir d)
Returns the next OrthoDir (in a clockwise manner)
Definition: OrthoRep.h:439
bool isFeasible(const NodeArray< ATYPE > &pos)
Performs feasibility test for position assignment pos, i.e., checks if the segment positions given by...
void setExtra(node v, node rep, ATYPE ofs)
Node v has no representation in drawing, only internal representation.
static const int c_MedianFactor
median arcs cost factor*vertexArcCost
Declaration of class MinimumEdgeDistances which maintains minimum distances between attached edges at...
bool alignmentArc(edge e) const
Returns if arc is important for alignment. These are the arcs representing node to gen...
const ATYPE & delta(node v, OrthoDir s, int i) const
NodeArray< ATYPE > m_extraOfs
offset of extra node to its rep, should change this
int compare(const node &x, const node &y) const
can be compacted to zero length
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
Definition: Graph_d.h:651
can be compacted to zero length, can be fixed
void align(bool b)
Triggers alignment (=>some special edge handling to support al.)
OrthoDir direction(adjEntry adj) const
Definition: OrthoRep.h:347
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:326
NodeArray< SListPure< node > > m_path
list of nodes contained in a segment
iterator insertBefore(const E &x, iterator it)
Inserts element x before it.
Definition: List.h:1392
Class implementing template-parameter-independent behaviour of ogdf::CompactionConstraintGraph.
The namespace for all OGDF objects.
void dfsInsertPathVertex(node v, node pathVertex, NodeArray< bool > &visited, const NodeArray< node > &genOpposite)
EdgeArray< bool > m_verticalGen
generalization that runs vertical relative to hierarchy
bool centerPriority()
Gets centerPriority (center single edges?)
NodeType
The type of nodes.
Definition: Graph_d.h:545
EdgeArray< ConstraintEdgeType > m_type
constraint type for each edge
EdgeArray< bool > m_verticalArc
arc corresponding to such an edge
node newNode()
Creates a new node and returns it.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:565
EdgeArray< edge > m_edgeToBasicArc
basic arc representing an edge in PG
void insertVisibilityArcs(const PlanRep &PG, const NodeArray< ATYPE > &posDir, const NodeArray< ATYPE > &posOppDir)
Inserts arcs connecting segments which can see each other in a drawing of the associated planarized r...
friend std::ostream & operator<<(std::ostream &os, const Interval &interval)
output operator
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition: Graph_d.h:335
bool empty() const
Returns true iff the list is empty.
Definition: List.h:256
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Definition: Graph_d.h:595
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:100
bool verticalGen(edge e) const
Returns true if e is vertical edge in PlanRepUML hierarchy.
Class for adjacency list elements.
Definition: Graph_d.h:79
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
Declares ogdf::CommonCompactionConstraintGraphBase.
Planarized representations (of a connected component) of a graph.
Definition: PlanRep.h:59
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition: Graph_d.h:200