Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ClusterOrthoShaper.h
Go to the documentation of this file.
1
34#pragma once
35
38
39namespace ogdf {
40
41
43
47public:
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.
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
155private:
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
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}
Declaration of ClusterPlanRep class, allowing cluster boundary insertion and shortest path edge inser...
Declaration of orthogonal representation of planar graphs.
Computes the orthogonal representation of a clustered graph.
void distributeEdges(bool b)
sets option distributeEdges to b
bool distributeEdges()
returns option distributeEdges
void traditional(bool b)
sets option traditional to b
bool multiAlign()
returns option multiAlign
int clusterProgBendCost(int clDepth, int treeDepth, int pbc)
void multiAlign(bool b)
sets option multiAlign to b
bool fixDegreeFourAngles()
returns option for free angle assignment at degree four nodes
bool traditional()
returns option for traditional angle distribution
void setAngleBound(edge netArc, int angle, EdgeArray< int > &lowB, EdgeArray< int > &upB, EdgeArray< edge > &aTwin, bool maxBound=true)
int clusterTradBendCost(int clDepth, int treeDepth, int pbc)
void call(ClusterPlanRep &PG, CombinatorialEmbedding &E, OrthoRep &OR, int startBoundBendsPerEdge=0, bool fourPlanar=true)
void fixDegreeFourAngles(bool b)
sets option for free angle assignment at degree four nodes
Planarized representations for clustered graphs.
Combinatorial embeddings of planar graphs with modification functionality.
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
Orthogonal representation of an embedded graph.
Definition OrthoRep.h:219
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.