Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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