Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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