Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

HypergraphAttributes.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Graph.h>
37 #include <ogdf/basic/basic.h>
38 #include <ogdf/basic/geometry.h>
39 #include <ogdf/basic/graphics.h>
42 
43 #include <string>
44 
45 namespace ogdf {
46 
61 protected:
64 
67 
70 
73 
76 
79 
82 
83 public:
85  HypergraphAttributes() : m_hypergraph(nullptr) { }
86 
88  explicit HypergraphAttributes(const Hypergraph& H) : m_hypergraph(&H) {
89  m_x.init(H, 0.0);
90  m_y.init(H, 0.0);
91  m_width.init(H, 10.0);
92  m_height.init(H, 10.0);
93  m_label.init(H);
94  m_shape.init(H, static_cast<int>(Shape::Ellipse));
95  }
96 
98  virtual ~HypergraphAttributes() { }
99 
100  const Hypergraph& constHypergraph() const { return *m_hypergraph; }
101 
103  const double& x(hypernode v) { return m_x[v]; }
104 
106  void setX(hypernode v, double pX) { m_x[v] = pX; }
107 
109  const double& y(hypernode v) { return m_y[v]; }
110 
112  void setY(hypernode v, double pY) { m_y[v] = pY; }
113 
115  const double& width(hypernode v) { return m_width[v]; }
116 
118  void setWidth(hypernode v, int pWidth) { m_width[v] = pWidth; }
119 
121  const double& height(hypernode v) { return m_height[v]; }
122 
124  void setHeight(hypernode v, int pHeight) { m_height[v] = pHeight; }
125 
127  int shape(hypernode v) { return m_shape[v]; }
128 
130  string& label(hypernode v) { return m_label[v]; }
131 };
132 
146 private:
149 
152 
155 
156 public:
158  HypergraphAttributesES() : m_repGA(nullptr), m_repG(nullptr) { }
159 
161  explicit HypergraphAttributesES(const Hypergraph& pH,
163  : HypergraphAttributes(pH) {
164  m_repG = new EdgeStandardRep(pH, pType);
165 
166  m_repGA = new GraphAttributes(m_repG->constGraph(),
168 
169  m_repGA->directed() = true;
170  }
171 
174  delete m_repGA;
175  delete m_repG;
176  }
177 
178  EdgeStandardType type() const { return m_type; }
179 
180  const Graph& repGraph() const { return m_repG->constGraph(); }
181 
182  const GraphAttributes& repGA() const { return *m_repGA; }
183 
186 
189  if (m_repG->hypernodeMap(v)) {
190  return m_repG->hypernodeMap(v)->type();
191  } else {
193  }
194  }
195 
197  const double& x(node v) { return m_repGA->x(v); }
198 
200  void setX(node v, double pX) {
201  if (m_repG->hypernodeMap(v)) {
202  setX(m_repG->hypernodeMap(v), pX);
203  } else {
204  m_repGA->x(v) = pX;
205  }
206  }
207 
209  void setX(hypernode v, double pX) {
210  m_x[v] = pX;
211  m_repGA->x(m_repG->nodeMap(v)) = pX;
212  }
213 
215  const double& y(node v) { return m_repGA->y(v); }
216 
218  void setY(hypernode v, double pY) {
219  m_y[v] = pY;
220  m_repGA->y(m_repG->nodeMap(v)) = pY;
221  }
222 
224  void setY(node v, double pY) {
225  if (m_repG->hypernodeMap(v)) {
226  setY(m_repG->hypernodeMap(v), pY);
227  } else {
228  m_repGA->y(v) = pY;
229  }
230  }
231 
233  const double& width(node v) { return m_repGA->width(v); }
234 
236  void setWidth(hypernode v, double pWidth) {
237  m_width[v] = pWidth;
238  m_repGA->width(m_repG->nodeMap(v)) = pWidth;
239  }
240 
242  void setWidth(node v, double pWidth) {
243  if (m_repG->hypernodeMap(v)) {
244  setWidth(m_repG->hypernodeMap(v), pWidth);
245  } else {
246  m_repGA->width(v) = pWidth;
247  }
248  }
249 
251  const double& height(node v) { return m_repGA->height(v); }
252 
254  void setHeight(hypernode v, double pHeight) {
255  m_height[v] = pHeight;
256  m_repGA->height(m_repG->nodeMap(v)) = pHeight;
257  }
258 
260  void setHeight(node v, double pHeight) {
261  if (m_repG->hypernodeMap(v)) {
262  setHeight(m_repG->hypernodeMap(v), pHeight);
263  } else {
264  m_repGA->height(v) = pHeight;
265  }
266  }
267 
269  DPolyline& bends(edge e) { return m_repGA->bends(e); }
270 
271 #if 0
272  void writeSVG(std::ostream &os, int fontSize, const string &fontColor) const
274  {
275  m_repGA->writeSVG(os, fontSize, fontColor);
276  }
277 
279  void writeSVG(const char *fileName, int fontSize, const string &fontColor) const
280  {
281  m_repGA->writeSVG(fileName, fontSize, fontColor);
282  }
283 #endif
284 
285  void clearAllBends() { m_repGA->clearAllBends(); }
286 
289 
291  const DRect boundingBox() const { return m_repGA->boundingBox(); }
292 };
293 
294 }
ogdf::HypergraphAttributes
Stores additional attributes of a hypergraph.
Definition: HypergraphAttributes.h:60
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::HypergraphAttributesES::~HypergraphAttributesES
virtual ~HypergraphAttributesES()
Destructor.
Definition: HypergraphAttributes.h:173
ogdf::HypergraphAttributes::y
const double & y(hypernode v)
Returns the y-coordinate of hypernode v.
Definition: HypergraphAttributes.h:109
Graph.h
Includes declaration of graph class.
ogdf::HypergraphAttributes::height
const double & height(hypernode v)
Returns the height of the bounding box of hypernode v.
Definition: HypergraphAttributes.h:121
graphics.h
Declaration of basic types for graphics.
ogdf::GraphAttributes::removeUnnecessaryBendsHV
void removeUnnecessaryBendsHV()
Removes unnecessary bend points in orthogonal segements.
ogdf::HypergraphAttributes::m_y
HypernodeArray< double > m_y
Coordinate y of a hypernode.
Definition: HypergraphAttributes.h:72
ogdf::HypergraphAttributesES::m_repG
EdgeStandardRep * m_repG
Edge standard representation reference.
Definition: HypergraphAttributes.h:151
ogdf::EdgeStandardRep::constGraph
const Graph & constGraph() const
Returns a reference to the representation graph.
Definition: EdgeStandardRep.h:111
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::HypergraphAttributes::label
string & label(hypernode v)
Returns the label of hypernode v.
Definition: HypergraphAttributes.h:130
ogdf::HypergraphAttributesES
Stores additional attributes of edge standard representation of a hypergraph.
Definition: HypergraphAttributes.h:145
ogdf::GenericPolyline
Polylines with PointType points.
Definition: geometry.h:261
ogdf::GraphAttributes::x
double x(node v) const
Returns the x-coordinate of node v.
Definition: GraphAttributes.h:247
ogdf::HypergraphRegisteredArray
RegisteredArray for nodes and edges of a hypergraph.
Definition: Hypergraph.h:381
ogdf::HypergraphAttributes::constHypergraph
const Hypergraph & constHypergraph() const
Definition: HypergraphAttributes.h:100
ogdf::HypergraphAttributesES::x
const double & x(node v)
Returns the x-coordinate of representation node v.
Definition: HypergraphAttributes.h:197
ogdf::HypergraphAttributesES::clearAllBends
void clearAllBends()
Definition: HypergraphAttributes.h:285
ogdf::HypergraphAttributesES::width
const double & width(node v)
Returns the width of a representation node v.
Definition: HypergraphAttributes.h:233
ogdf::EdgeStandardRep::hypernodeMap
hypernode hypernodeMap(node v)
Returns the hypernode associated with the node (if any).
Definition: EdgeStandardRep.h:120
ogdf::HypergraphAttributes::m_label
HypernodeArray< string > m_label
Label of a hypernode.
Definition: HypergraphAttributes.h:66
ogdf::HypergraphAttributesES::repGraph
const Graph & repGraph() const
Definition: HypergraphAttributes.h:180
ogdf::GraphAttributes::directed
bool directed() const
Returns if the graph is directed.
Definition: GraphAttributes.h:232
ogdf::HypergraphAttributesES::setWidth
void setWidth(node v, double pWidth)
Sets the the width of a representation node v.
Definition: HypergraphAttributes.h:242
ogdf::EdgeStandardType
EdgeStandardType
Enumeration class of possible edge standard representations.
Definition: EdgeStandardRep.h:50
ogdf::HypergraphAttributesES::boundingBox
const DRect boundingBox() const
Returns the bounding box of the hypergraph.
Definition: HypergraphAttributes.h:291
ogdf::HypergraphAttributes::m_height
HypernodeArray< double > m_height
Height of a hypernodes bounding box.
Definition: HypergraphAttributes.h:78
ogdf::HypergraphAttributes::m_width
HypernodeArray< double > m_width
Width of a hypernode bounding box.
Definition: HypergraphAttributes.h:75
Hypergraph.h
Declaration and a partial implementation of a Hypergraph class partly based on the original classes f...
ogdf::GraphAttributes::bends
const DPolyline & bends(edge e) const
Returns the list of bend points of edge e.
Definition: GraphAttributes.h:664
ogdf::GraphAttributes::y
double y(node v) const
Returns the y-coordinate of node v.
Definition: GraphAttributes.h:265
ogdf::HypergraphAttributes::HypergraphAttributes
HypergraphAttributes(const Hypergraph &H)
Initializes new instance of class HypergraphAttributes.
Definition: HypergraphAttributes.h:88
ogdf::HypergraphAttributes::x
const double & x(hypernode v)
Returns the x-coordinate of hypernode v.
Definition: HypergraphAttributes.h:103
ogdf::HypernodeElement::Type
Type
The type of hypernodes.
Definition: Hypergraph.h:233
ogdf::HypergraphAttributesES::m_repGA
GraphAttributes * m_repGA
Wrapped graph attributes reference.
Definition: HypergraphAttributes.h:148
ogdf::HypergraphAttributes::setWidth
void setWidth(hypernode v, int pWidth)
Sets the the width of hypernode v.
Definition: HypergraphAttributes.h:118
ogdf::DRect
Rectangles with real coordinates.
Definition: geometry.h:798
ogdf::HypergraphAttributesES::type
HypernodeElement::Type type(hypernode v)
Returns the type of representation node v.
Definition: HypergraphAttributes.h:185
ogdf::HypergraphAttributes::m_hypergraph
const Hypergraph * m_hypergraph
Only points to an existing hypergraph.
Definition: HypergraphAttributes.h:63
ogdf::HypergraphAttributesES::height
const double & height(node v)
Returns the height of a representation node v.
Definition: HypergraphAttributes.h:251
ogdf::HypergraphAttributesES::removeUnnecessaryBendsHV
void removeUnnecessaryBendsHV()
Removes unnecessary bend points in orthogonal segements.
Definition: HypergraphAttributes.h:288
ogdf::EdgeStandardRep
Edge standard representation of hypergraphs.
Definition: EdgeStandardRep.h:68
ogdf::HypergraphAttributes::~HypergraphAttributes
virtual ~HypergraphAttributes()
Destructor.
Definition: HypergraphAttributes.h:98
ogdf::EdgeStandardType::star
@ star
for every hyperedge e = {v_1, ..., v_l} a single new dummy node v_e is introduced,...
ogdf::EdgeStandardRep::nodeMap
node nodeMap(hypernode v)
Returns the node associated with the hypernode.
Definition: EdgeStandardRep.h:117
ogdf::HypergraphAttributesES::setX
void setX(node v, double pX)
Sets the x-coordinate of a representation node v.
Definition: HypergraphAttributes.h:200
ogdf::HypergraphAttributes::setHeight
void setHeight(hypernode v, int pHeight)
Sets the the height of hypernode v.
Definition: HypergraphAttributes.h:124
EdgeStandardRep.h
A declaration of EdgeStandardRep class representing a graph representation of a hypergraph in the edg...
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::GraphAttributes::height
double height(node v) const
Returns the height of the bounding box of node v.
Definition: GraphAttributes.h:393
ogdf::HypergraphAttributesES::bends
DPolyline & bends(edge e)
Returns the list of bend points of edge e.
Definition: HypergraphAttributes.h:269
ogdf::GraphAttributes::clearAllBends
void clearAllBends()
Removes all edge bends.
ogdf::Shape::Ellipse
@ Ellipse
ellipse
ogdf::HypergraphAttributesES::m_type
EdgeStandardType m_type
The type of of edge standard representation.
Definition: HypergraphAttributes.h:154
ogdf::HypergraphAttributesES::HypergraphAttributesES
HypergraphAttributesES(const Hypergraph &pH, EdgeStandardType pType=EdgeStandardType::star)
Initializes new instance of class HypergraphAttributes.
Definition: HypergraphAttributes.h:161
ogdf::HypergraphAttributesES::repGA
const GraphAttributes & repGA() const
Definition: HypergraphAttributes.h:182
ogdf::GraphAttributes::edgeGraphics
static const long edgeGraphics
Corresponds to edge attribute bends(edge).
Definition: GraphAttributes.h:122
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::HypergraphAttributesES::setY
void setY(node v, double pY)
Sets the y-coordinate of a representation node v.
Definition: HypergraphAttributes.h:224
ogdf::HypergraphAttributesES::type
EdgeStandardType type() const
Definition: HypergraphAttributes.h:178
ogdf::HypergraphAttributes::m_shape
HypernodeArray< int > m_shape
Shape of a hypernode.
Definition: HypergraphAttributes.h:81
ogdf::HypergraphAttributes::m_x
HypernodeArray< double > m_x
Coordinate x of a hypernod.e.
Definition: HypergraphAttributes.h:69
ogdf::GraphAttributes::boundingBox
virtual DRect boundingBox() const
Returns the bounding box of the graph.
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::HypergraphAttributesES::setHeight
void setHeight(hypernode v, double pHeight)
Sets the the height of hypernode v.
Definition: HypergraphAttributes.h:254
ogdf::HypergraphAttributesES::setHeight
void setHeight(node v, double pHeight)
Sets the the height of a representation node v.
Definition: HypergraphAttributes.h:260
ogdf::HypergraphAttributesES::setY
void setY(hypernode v, double pY)
Sets the x-coordinate of hypernode v.
Definition: HypergraphAttributes.h:218
ogdf::RegisteredArray< HypergraphRegistry< Key >, Value, WithDefault, Hypergraph >::init
void init(const Hypergraph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Definition: RegisteredArray.h:858
ogdf::HypergraphAttributes::setY
void setY(hypernode v, double pY)
Sets the y-coordinate of hypernode v.
Definition: HypergraphAttributes.h:112
ogdf::HypergraphAttributesES::type
HypernodeElement::Type type(node v)
Returns the type of representation node v.
Definition: HypergraphAttributes.h:188
ogdf::HypergraphAttributesES::HypergraphAttributesES
HypergraphAttributesES()
Initializes new instance of class HypergraphAttributes.
Definition: HypergraphAttributes.h:158
ogdf::HypernodeElement::type
Type type() const
Returns the type of hypernode.
Definition: Hypergraph.h:283
ogdf::HypergraphAttributesES::setWidth
void setWidth(hypernode v, double pWidth)
Sets the the width of hypernode v.
Definition: HypergraphAttributes.h:236
ogdf::HypergraphAttributes::width
const double & width(hypernode v)
Returns the width of the bounding box of hypernode v.
Definition: HypergraphAttributes.h:115
ogdf::HypergraphAttributesES::y
const double & y(node v)
Returns the y-coordinate of a representation node v.
Definition: HypergraphAttributes.h:215
ogdf::HypergraphAttributes::setX
void setX(hypernode v, double pX)
Sets the x-coordinate of hypernode v.
Definition: HypergraphAttributes.h:106
ogdf::HypergraphAttributesES::setX
void setX(hypernode v, double pX)
Sets the x-coordinate of hypernode v.
Definition: HypergraphAttributes.h:209
ogdf::HypernodeElement::Type::dummy
@ dummy
Default type.
ogdf::HypergraphAttributes::HypergraphAttributes
HypergraphAttributes()
Initializes new instance of class HypergraphAttributes.
Definition: HypergraphAttributes.h:85
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::Hypergraph
Definition: Hypergraph.h:409
ogdf::GraphAttributes::nodeGraphics
static const long nodeGraphics
Corresponds to node attributes x(node), y(node), width(node), height(node), and shape(node).
Definition: GraphAttributes.h:119
ogdf::HypergraphAttributes::shape
int shape(hypernode v)
Returns the shape of hypernode v.
Definition: HypergraphAttributes.h:127
ogdf::HypernodeElement
Class for the representation of hypernodes.
Definition: Hypergraph.h:226
ogdf::GraphAttributes::width
double width(node v) const
Returns the width of the bounding box of node v.
Definition: GraphAttributes.h:357