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
36#include <ogdf/basic/Graph.h>
37#include <ogdf/basic/basic.h>
38
39namespace ogdf {
40class ClusterPlanRep;
41class CombinatorialEmbedding;
42class OrthoRep;
43
45
49public:
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.
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
157private:
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}
Includes declaration of graph class.
Basic declarations, included by all source files.
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.
Class for the representation of edges.
Definition Graph_d.h:364
Orthogonal representation of an embedded graph.
Definition OrthoRep.h:225
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.