Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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:
54  //nodes and faces
55 
57  m_distributeEdges = true;
58  m_fourPlanar = true;
59  m_allowLowZero = false;
60  m_multiAlign = true;
61  m_traditional = true;
62  m_deg4free = false;
63  m_align = false;
64  m_topToBottom = BendCost::defaultCost; //bend costs depend on edges cluster depth
65  };
66 
68 
69  // Given a planar representation for a UML graph and its planar
70  // combinatorial embedding, call() produces an orthogonal
71  // representation using Tamassias bend minimization algorithm
72  // with a flow network where every flow unit defines 90 degree angle
73  // in traditional mode.
74  // A maximum number of bends per edge can be specified in
75  // startBoundBendsPerEdge. If the algorithm is not successful in
76  // producing a bend minimal representation subject to
77  // startBoundBendsPerEdge, it successively enhances the bound by
78  // one trying to compute an orthogonal representation.
79  //
80  // Using startBoundBendsPerEdge may not produce a bend minimal
81  // representation in general.
82  void call(ClusterPlanRep &PG,
84  OrthoRep &OR,
85  int startBoundBendsPerEdge = 0,
86  bool fourPlanar = true);
87 
88 
90  bool distributeEdges() { return m_distributeEdges; }
92  void distributeEdges(bool b) { m_distributeEdges = b; }
93 
95  bool multiAlign() { return m_multiAlign; }
97  void multiAlign(bool b) { m_multiAlign = b; }
98 
100  bool traditional() { return m_traditional; }
102  void traditional(bool b) { m_traditional = b; }
103 
105  bool fixDegreeFourAngles() { return m_deg4free; }
107  void fixDegreeFourAngles(bool b) { m_deg4free = b; }
108 
109  //alignment of brothers in hierarchies
110  void align(bool al) { m_align = al; }
111  bool align() { return m_align; }
112 
113  void bendCostTopDown(BendCost i) { m_topToBottom = i; }
114 
115  //return cluster dependant bend cost for standard cost pbc
116  int clusterProgBendCost(int clDepth, int treeDepth, int pbc)
117  {
118  int cost = 1;
119  switch (m_topToBottom)
120  {
121  case BendCost::topDownCost:
122  cost = pbc*(clDepth+1); //safeInt
123  break;
124  case BendCost::bottomUpCost:
125  cost = pbc*(treeDepth - clDepth + 1); //safeInt
126  break;
127  default: //defaultCost
128  cost = pbc;
129  break;
130  }
131 
132 #if 0
133  cout<<" Cost/pbc: "<<cost<<"/"<<pbc<<"\n";
134 #endif
135 
136  return cost;
137  }
138 
139  //this is a try: I dont know why this was never implemented for traditional,
140  //maybe because of the unit cost for traditional bends vs. the highbound
141  //cost for progressive bends
142  //return cluster dependant bend cost for standard cost pbc
143  //preliminary same as progressive
144  int clusterTradBendCost(int clDepth, int treeDepth, int pbc)
145  {
146  int cost = 1;
147  switch (m_topToBottom)
148  {
149  case BendCost::topDownCost:
150  cost = pbc*(clDepth+1); //safeInt
151  break;
152  case BendCost::bottomUpCost:
153  cost = pbc*(treeDepth - clDepth + 1); //safeInt
154  break;
155  default: //defaultCost
156  cost = pbc;
157  break;
158  }
159 
160  return cost;
161  }//clusterTradBendCost
162 
163 
164 
165 private:
166  bool m_distributeEdges; // distribute edges among all sides if degree > 4
167  bool m_fourPlanar; // should the input graph be four planar
168  // (no zero degree)
169  bool m_allowLowZero; // allow low degree nodes zero degree
170  // (to low for zero...)
171  bool m_multiAlign; // multi edges aligned on the same side
172  bool m_deg4free; // allow degree four nodes free angle assignment
173  bool m_traditional; // do not prefer 180 degree angles,
174  // traditional is not tamassia,
175  // traditional is a kandinsky - ILP - like network with node supply 4,
176  // not traditional interprets angle flow zero as 180 degree, "flow
177  // through the node"
178  bool m_align; //try to achieve an alignment in hierarchy levels
179 
180  BendCost m_topToBottom; //change bend costs on cluster hierarchy levels
181 
182  //set angle boundary
183  //warning: sets upper AND lower bounds, therefore may interfere with existing bounds
185  edge netArc,
186  int angle,
187  EdgeArray<int>& lowB,
188  EdgeArray<int>& upB,
189  EdgeArray<edge>& aTwin,
190  bool maxBound = true)
191  {
192  // preliminary
193  OGDF_ASSERT(!m_traditional);
194 
195  const int angleId = angle / 90;
196  const edge e2 = aTwin[netArc];
197 
198  OGDF_ASSERT(angleId >= 0);
199  OGDF_ASSERT(angleId <= 2);
200 
201  if (maxBound) {
202  lowB[netArc] = 2 - angleId;
203  upB[netArc] = 2;
204 
205  if (e2) {
206  upB[e2] = lowB[e2] = 0;
207  }
208  } else {
209  upB[netArc] = 2 - angleId;
210  lowB[netArc] = 0;
211 
212  if (e2) {
213  upB[e2] = 2;
214  lowB[e2] = 0;
215  }
216  }
217  }//setAngleBound
218 };
219 
220 
221 } // end namespace ogdf
#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:237
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:291
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