Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
HypergraphAttributes.h
Go to the documentation of this file.
1
33#pragma once
34
38
39namespace ogdf {
40
55protected:
58
61
64
67
70
73
76
77public:
79 HypergraphAttributes() : m_hypergraph(nullptr) { }
80
82 explicit HypergraphAttributes(const Hypergraph& H) : m_hypergraph(&H) {
83 m_x.init(H, 0.0);
84 m_y.init(H, 0.0);
85 m_width.init(H, 10.0);
86 m_height.init(H, 10.0);
87 m_label.init(H);
88 m_shape.init(H, static_cast<int>(Shape::Ellipse));
89 }
90
93
94 const Hypergraph& constHypergraph() const { return *m_hypergraph; }
95
97 const double& x(hypernode v) { return m_x[v]; }
98
100 void setX(hypernode v, double pX) { m_x[v] = pX; }
101
103 const double& y(hypernode v) { return m_y[v]; }
104
106 void setY(hypernode v, double pY) { m_y[v] = pY; }
107
109 const double& width(hypernode v) { return m_width[v]; }
110
112 void setWidth(hypernode v, int pWidth) { m_width[v] = pWidth; }
113
115 const double& height(hypernode v) { return m_height[v]; }
116
118 void setHeight(hypernode v, int pHeight) { m_height[v] = pHeight; }
119
121 int shape(hypernode v) { return m_shape[v]; }
122
124 string& label(hypernode v) { return m_label[v]; }
125};
126
140private:
143
146
149
150public:
152 HypergraphAttributesES() : m_repGA(nullptr), m_repG(nullptr) { }
153
156 EdgeStandardType pType = EdgeStandardType::star)
158 m_repG = new EdgeStandardRep(pH, pType);
159
160 m_repGA = new GraphAttributes(m_repG->constGraph(),
161 GraphAttributes::nodeGraphics | GraphAttributes::edgeGraphics);
162
163 m_repGA->directed() = true;
164 }
165
168 delete m_repGA;
169 delete m_repG;
170 }
171
172 EdgeStandardType type() const { return m_type; }
173
174 const Graph& repGraph() const { return m_repG->constGraph(); }
175
176 const GraphAttributes& repGA() const { return *m_repGA; }
177
180
183 if (m_repG->hypernodeMap(v)) {
184 return m_repG->hypernodeMap(v)->type();
185 } else {
186 return HypernodeElement::Type::dummy;
187 }
188 }
189
191 const double& x(node v) { return m_repGA->x(v); }
192
194 void setX(node v, double pX) {
195 if (m_repG->hypernodeMap(v)) {
196 setX(m_repG->hypernodeMap(v), pX);
197 } else {
198 m_repGA->x(v) = pX;
199 }
200 }
201
203 void setX(hypernode v, double pX) {
204 m_x[v] = pX;
205 m_repGA->x(m_repG->nodeMap(v)) = pX;
206 }
207
209 const double& y(node v) { return m_repGA->y(v); }
210
212 void setY(hypernode v, double pY) {
213 m_y[v] = pY;
214 m_repGA->y(m_repG->nodeMap(v)) = pY;
215 }
216
218 void setY(node v, double pY) {
219 if (m_repG->hypernodeMap(v)) {
220 setY(m_repG->hypernodeMap(v), pY);
221 } else {
222 m_repGA->y(v) = pY;
223 }
224 }
225
227 const double& width(node v) { return m_repGA->width(v); }
228
230 void setWidth(hypernode v, double pWidth) {
231 m_width[v] = pWidth;
232 m_repGA->width(m_repG->nodeMap(v)) = pWidth;
233 }
234
236 void setWidth(node v, double pWidth) {
237 if (m_repG->hypernodeMap(v)) {
238 setWidth(m_repG->hypernodeMap(v), pWidth);
239 } else {
240 m_repGA->width(v) = pWidth;
241 }
242 }
243
245 const double& height(node v) { return m_repGA->height(v); }
246
248 void setHeight(hypernode v, double pHeight) {
249 m_height[v] = pHeight;
250 m_repGA->height(m_repG->nodeMap(v)) = pHeight;
251 }
252
254 void setHeight(node v, double pHeight) {
255 if (m_repG->hypernodeMap(v)) {
256 setHeight(m_repG->hypernodeMap(v), pHeight);
257 } else {
258 m_repGA->height(v) = pHeight;
259 }
260 }
261
263 DPolyline& bends(edge e) { return m_repGA->bends(e); }
264
265#if 0
267 void writeSVG(std::ostream &os, int fontSize, const string &fontColor) const
268 {
269 m_repGA->writeSVG(os, fontSize, fontColor);
270 }
271
273 void writeSVG(const char *fileName, int fontSize, const string &fontColor) const
274 {
275 m_repGA->writeSVG(fileName, fontSize, fontColor);
276 }
277#endif
278
279 void clearAllBends() { m_repGA->clearAllBends(); }
280
283
285 const DRect boundingBox() const { return m_repGA->boundingBox(); }
286};
287
288}
A declaration of EdgeStandardRep class representing a graph representation of a hypergraph in the edg...
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration and implementation of hyperraph array classes based on Node/EdgeArray classes written by ...
Rectangles with real coordinates.
Definition geometry.h:790
Class for the representation of edges.
Definition Graph_d.h:300
Edge standard representation of hypergraphs.
hypernode hypernodeMap(node v)
Returns the hypernode associated with the node (if any).
node nodeMap(hypernode v)
Returns the node associated with the hypernode.
const Graph & constGraph() const
Returns a reference to the representation graph.
Polylines with PointType points.
Definition geometry.h:253
Stores additional attributes of a graph (like layout information).
void removeUnnecessaryBendsHV()
Removes unnecessary bend points in orthogonal segements.
double y(node v) const
Returns the y-coordinate of node v.
double height(node v) const
Returns the height of the bounding box of node v.
bool directed() const
Returns if the graph is directed.
double x(node v) const
Returns the x-coordinate of node v.
double width(node v) const
Returns the width of the bounding box of node v.
virtual DRect boundingBox() const
Returns the bounding box of the graph.
void clearAllBends()
Removes all edge bends.
const DPolyline & bends(edge e) const
Returns the list of bend points of edge e.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Stores additional attributes of edge standard representation of a hypergraph.
void setHeight(node v, double pHeight)
Sets the the height of a representation node v.
EdgeStandardType m_type
The type of of edge standard representation.
HypernodeElement::Type type(hypernode v)
Returns the type of representation node v.
virtual ~HypergraphAttributesES()
Destructor.
HypergraphAttributesES()
Initializes new instance of class HypergraphAttributes.
void setX(node v, double pX)
Sets the x-coordinate of a representation node v.
void setY(hypernode v, double pY)
Sets the x-coordinate of hypernode v.
const double & x(node v)
Returns the x-coordinate of representation node v.
void setWidth(node v, double pWidth)
Sets the the width of a representation node v.
const double & width(node v)
Returns the width of a representation node v.
const double & height(node v)
Returns the height of a representation node v.
EdgeStandardRep * m_repG
Edge standard representation reference.
HypernodeElement::Type type(node v)
Returns the type of representation node v.
void removeUnnecessaryBendsHV()
Removes unnecessary bend points in orthogonal segements.
void setHeight(hypernode v, double pHeight)
Sets the the height of hypernode v.
GraphAttributes * m_repGA
Wrapped graph attributes reference.
const double & y(node v)
Returns the y-coordinate of a representation node v.
void setWidth(hypernode v, double pWidth)
Sets the the width of hypernode v.
void setY(node v, double pY)
Sets the y-coordinate of a representation node v.
const GraphAttributes & repGA() const
HypergraphAttributesES(const Hypergraph &pH, EdgeStandardType pType=EdgeStandardType::star)
Initializes new instance of class HypergraphAttributes.
EdgeStandardType type() const
DPolyline & bends(edge e)
Returns the list of bend points of edge e.
const DRect boundingBox() const
Returns the bounding box of the hypergraph.
void setX(hypernode v, double pX)
Sets the x-coordinate of hypernode v.
Stores additional attributes of a hypergraph.
const Hypergraph * m_hypergraph
Only points to an existing hypergraph.
void setX(hypernode v, double pX)
Sets the x-coordinate of hypernode v.
void setHeight(hypernode v, int pHeight)
Sets the the height of hypernode v.
void setY(hypernode v, double pY)
Sets the y-coordinate of hypernode v.
HypernodeArray< double > m_x
Coordinate x of a hypernod.e.
const double & width(hypernode v)
Returns the width of the bounding box of hypernode v.
int shape(hypernode v)
Returns the shape of hypernode v.
const Hypergraph & constHypergraph() const
const double & x(hypernode v)
Returns the x-coordinate of hypernode v.
HypergraphAttributes()
Initializes new instance of class HypergraphAttributes.
HypernodeArray< double > m_height
Height of a hypernodes bounding box.
HypernodeArray< string > m_label
Label of a hypernode.
virtual ~HypergraphAttributes()
Destructor.
HypernodeArray< double > m_width
Width of a hypernode bounding box.
const double & height(hypernode v)
Returns the height of the bounding box of hypernode v.
HypernodeArray< double > m_y
Coordinate y of a hypernode.
void setWidth(hypernode v, int pWidth)
Sets the the width of hypernode v.
const double & y(hypernode v)
Returns the y-coordinate of hypernode v.
HypergraphAttributes(const Hypergraph &H)
Initializes new instance of class HypergraphAttributes.
HypernodeArray< int > m_shape
Shape of a hypernode.
string & label(hypernode v)
Returns the label of hypernode v.
Dynamic arrays indexed with hypernodes.
void init(const Hypergraph &H)
Reinitializes the array. Associates the array with H.
Class for the representation of hypernodes.
Definition Hypergraph.h:215
Type type() const
Returns the type of hypernode.
Definition Hypergraph.h:272
Type
The type of hypernodes.
Definition Hypergraph.h:222
Class for the representation of nodes.
Definition Graph_d.h:177
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
EdgeStandardType
Enumeration class of possible edge standard representations.