Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

ClusterOrthoShaper.h
Go to the documentation of this file.
1 
34 #pragma once
35 
38 
39 
40 namespace ogdf {
41 
42 
44 
48 {
49 
50 public:
51 
52  enum class BendCost { defaultCost, topDownCost, bottomUpCost };
53  enum class n_type { low, high, inner, outer }; // types of network nodes: nodes and faces
54 
56  m_distributeEdges = true;
57  m_fourPlanar = true;
58  m_allowLowZero = false;
59  m_multiAlign = true;
60  m_traditional = true;
61  m_deg4free = false;
62  m_align = false;
63  m_topToBottom = BendCost::defaultCost; //bend costs depend on edges cluster depth
64  };
65 
67 
68  // Given a planar representation for a UML graph and its planar
69  // combinatorial embedding, call() produces an orthogonal
70  // representation using Tamassias bend minimization algorithm
71  // with a flow network where every flow unit defines 90 degree angle
72  // in traditional mode.
73  // A maximum number of bends per edge can be specified in
74  // startBoundBendsPerEdge. If the algorithm is not successful in
75  // producing a bend minimal representation subject to
76  // startBoundBendsPerEdge, it successively enhances the bound by
77  // one trying to compute an orthogonal representation.
78  //
79  // Using startBoundBendsPerEdge may not produce a bend minimal
80  // representation in general.
81  void call(ClusterPlanRep &PG,
83  OrthoRep &OR,
84  int startBoundBendsPerEdge = 0,
85  bool fourPlanar = true);
86 
87 
89  bool distributeEdges() { return m_distributeEdges; }
91  void distributeEdges(bool b) { m_distributeEdges = b; }
92 
94  bool multiAlign() { return m_multiAlign; }
96  void multiAlign(bool b) { m_multiAlign = b; }
97 
99  bool traditional() { return m_traditional; }
101  void traditional(bool b) { m_traditional = b; }
102 
104  bool fixDegreeFourAngles() { return m_deg4free; }
106  void fixDegreeFourAngles(bool b) { m_deg4free = b; }
107 
108  //alignment of brothers in hierarchies
109  void align(bool al) { m_align = al; }
110  bool align() { return m_align; }
111 
112  void bendCostTopDown(BendCost i) { m_topToBottom = i; }
113 
114  //return cluster dependant bend cost for standard cost pbc
115  int clusterProgBendCost(int clDepth, int treeDepth, int pbc)
116  {
117  int cost = 1;
118  switch (m_topToBottom)
119  {
120  case BendCost::topDownCost:
121  cost = pbc*(clDepth+1); //safeInt
122  break;
123  case BendCost::bottomUpCost:
124  cost = pbc*(treeDepth - clDepth + 1); //safeInt
125  break;
126  default: //defaultCost
127  cost = pbc;
128  break;
129  }
130 
131 #if 0
132  std::cout << " Cost/pbc: " << cost << "/" << pbc << "\n";
133 #endif
134 
135  return cost;
136  }
137 
138  //this is a try: I dont know why this was never implemented for traditional,
139  //maybe because of the unit cost for traditional bends vs. the highbound
140  //cost for progressive bends
141  //return cluster dependant bend cost for standard cost pbc
142  //preliminary same as progressive
143  int clusterTradBendCost(int clDepth, int treeDepth, int pbc)
144  {
145  int cost = 1;
146  switch (m_topToBottom)
147  {
148  case BendCost::topDownCost:
149  cost = pbc*(clDepth+1); //safeInt
150  break;
151  case BendCost::bottomUpCost:
152  cost = pbc*(treeDepth - clDepth + 1); //safeInt
153  break;
154  default: //defaultCost
155  cost = pbc;
156  break;
157  }
158 
159  return cost;
160  }
161 
162 private:
163  bool m_distributeEdges; // distribute edges among all sides if degree > 4
164  bool m_fourPlanar; // should the input graph be four planar (no zero degree)
165  bool m_allowLowZero; // allow low degree nodes zero degree (to low for zero...)
166  bool m_multiAlign; // multi edges aligned on the same side
167  bool m_deg4free; // allow degree four nodes free angle assignment
168  bool m_traditional; // do not prefer 180 degree angles, traditional is not tamassia,
169  // traditional is a kandinsky - ILP - like network with node supply 4,
170  // not traditional interprets angle flow zero as 180 degree, "flow
171  // through the node"
172  bool m_align; //try to achieve an alignment in hierarchy levels
173 
174  BendCost m_topToBottom; //change bend costs on cluster hierarchy levels
175 
176  //set angle boundary
177  //warning: sets upper AND lower bounds, therefore may interfere with existing bounds
179  edge netArc,
180  int angle,
181  EdgeArray<int>& lowB,
182  EdgeArray<int>& upB,
183  EdgeArray<edge>& aTwin,
184  bool maxBound = true)
185  {
186  // preliminary
187  OGDF_ASSERT(!m_traditional);
188 
189  const int angleId = angle / 90;
190  const edge e2 = aTwin[netArc];
191 
192  OGDF_ASSERT(angleId >= 0);
193  OGDF_ASSERT(angleId <= 2);
194 
195  if (maxBound) {
196  lowB[netArc] = 2 - angleId;
197  upB[netArc] = 2;
198 
199  if (e2) {
200  upB[e2] = lowB[e2] = 0;
201  }
202  } else {
203  upB[netArc] = 2 - angleId;
204  lowB[netArc] = 0;
205 
206  if (e2) {
207  upB[e2] = 2;
208  lowB[e2] = 0;
209  }
210  }
211  }
212 };
213 
214 }
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
void setAngleBound(edge netArc, int angle, EdgeArray< int > &lowB, EdgeArray< int > &upB, EdgeArray< edge > &aTwin, bool maxBound=true)
Declaration of orthogonal representation of planar graphs.
int clusterProgBendCost(int clDepth, int treeDepth, int pbc)
bool traditional()
returns option for traditional angle distribution
Orthogonal representation of an embedded graph.
Definition: OrthoRep.h:236
void traditional(bool b)
sets option traditional to b
Declaration of ClusterPlanRep class, allowing cluster boundary insertion and shortest path edge inser...
void distributeEdges(bool b)
sets option distributeEdges to b
bool fixDegreeFourAngles()
returns option for free angle assignment at degree four nodes
bool distributeEdges()
returns option distributeEdges
int clusterTradBendCost(int clDepth, int treeDepth, int pbc)
Class for the representation of edges.
Definition: Graph_d.h:292
Planarized representations for clustered graphs.
void bendCostTopDown(BendCost i)
Computes the orthogonal representation of a clustered graph.
bool multiAlign()
returns option multiAlign
The namespace for all OGDF objects.
Combinatorial embeddings of planar graphs with modification functionality.
void fixDegreeFourAngles(bool b)
sets option for free angle assignment at degree four nodes
void multiAlign(bool b)
sets option multiAlign to b
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41