Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

UMLGraph.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 #include <ogdf/basic/SList.h>
37 
38 
39 namespace ogdf {
40 
42 {
43 public:
44  // construction
45 
46  // Creates a UML graph for no associated graph (default constructor).
47  UMLGraph() : GraphAttributes(), m_pG(nullptr) { }
48 
49  // Creates a UML graph associated with graph \p G.
53  explicit UMLGraph(Graph &G, long initAttributes = 0);
54 
56  virtual ~UMLGraph();
57 
58  // Initializes the UML graph for graph \p G.
66  virtual void init(Graph &G, long initAttr)
67  {
68  m_pG = &G;
69  GraphAttributes::init(G, initAttr);
70  m_hierarchyParent.init(constGraph(), nullptr);
71  m_upwardEdge.init(constGraph(), false);
72 
73  delete m_hiddenEdges;
74  m_hiddenEdges = new Graph::HiddenEdgeSet(G);
75  }
76 
77  virtual void init(const Graph &G, long initAttr) override {
78  init(const_cast<Graph &>(G), initAttr);
79  }
80 
83 
85  void insertGenMergers();
87  node doInsertMergers(node v, SList<edge> &inGens);
88  void undoGenMergers();
89 
93 
98  void replaceByStar(List< List<node> > &cliques);
99 
101  void undoStars();
103  void undoStar(node center, bool restoreAllEdges);
104 
107  {
108  return m_cliqueCircleSize[v];
109  }
111  {
112  return m_cliqueCirclePos[v];
113  }
114 
115 #if 0
116  //compute circle positions for all nodes around center
117  //using the ordering given in this UMLGraph, calls
118  //ccP(List...)
119  //rectMin is a temporary solution until compaction with constraints allows stretching
120  //of rect to clique size, it gives the min(w,h) of the given fixed size rect around the clique
121  void computeCliquePosition(node center, double rectMin);
122  void computeCliquePosition(node center, double rectMin, const adjEntry &startAdj);
123 #endif
124 
131  void computeCliquePosition(List<node> &adjNodes, node center, double rectMin = -1.0);
132 
133  const SListPure<node> &centerNodes() {return m_centerNodes;}
134 
136  void setDefaultCliqueCenterSize(double i) {m_cliqueCenterSize = max(i, 1.0);}
137  double getDefaultCliqueCenterSize() {return m_cliqueCenterSize;}
138 
141  {
142  // TODO: check here how to guarantee that value is defined,
143  // edgearray is only valid if there are cliques replaced
144  return m_replacementEdge[e];
145  }
146 
148 
149 #if 0
150  Graph& pureGraph() const {return *m_pG;}
152 
154  void setAlign(edge e, bool b) {m_alignEdge[e] = b;}
155 #endif
156 
158  void setUpwards(adjEntry a, bool b) {m_upwardEdge[a] = b;}
159  bool upwards(adjEntry a) const {return m_upwardEdge[a];}
160 
162  void writeGML(const char *fileName);
163 
165  void writeGML(ostream &os);
166 
170  void adjustHierarchyParents();
171 
172 #if 0
173  void sortEdgesFromLayout();
177 #endif
178 
181  public:
182  explicit AssociationClass(edge e, double width = 1.0, double height = 1.0,
183  double x = 0.0, double y = 0.0)
184  : m_width(width), m_height(height), m_x(x), m_y(y), m_edge(e), m_node(nullptr)
185  { }
186 
187  double m_width;
188  double m_height;
189  double m_x;
190  double m_y;
193  };
194  const SListPure<AssociationClass*> &assClassList() const {return m_assClassList;}
195 
196  const AssociationClass* assClass(edge e) const {return m_assClass[e];}
197 
199  node createAssociationClass(edge e, double width = 1.0, double height = 1.0)
200  {
201  AssociationClass* ac = new AssociationClass(e, width, height);
202  m_assClass[e] = ac;
203  m_assClassList.pushBack(ac);
204  //we already insert the node here, but not the edge
205  //when we always insert this node here, we can remove the associationclass
206  //class and information later on
207  node v = m_pG->newNode();
208  m_height[v] = ac->m_height;
209  m_width[v] = ac->m_width;
210  m_associationClassModel[ac->m_edge] = v;
211  ac->m_node = v;
212  //guarantee correct angle at edge to edge connection
213  if (m_attributes & GraphAttributes::nodeType)
214  {
216  }
217  return v;
218  }
219 
220  //this modelling should only take place in the preprocessing steps
221  //of the drawing algorithms?
224  {
225  SListIterator<UMLGraph::AssociationClass*> it = m_assClassList.begin();
226  while (it.valid())
227  {
228  modelAssociationClass((*it));
229  ++it;
230  }//while
231  }
233  {
234  node dummy = m_pG->split(ac->m_edge)->source();
235 
236  m_height[dummy] = 1; //just a dummy size
237  m_width[dummy] = 1;
238  OGDF_ASSERT(ac->m_node);
239  m_pG->newEdge(ac->m_node, dummy);
240 
241  return dummy;
242  }
243 
245  {
246  SListIterator<UMLGraph::AssociationClass*> it = m_assClassList.begin();
247  while (it.valid())
248  {
249  undoAssociationClass((*it));
250  ++it;
251  }//while
252  }
253 
256  {
257  node v = m_associationClassModel[ac->m_edge];
258  OGDF_ASSERT(v);
259  OGDF_ASSERT(v->degree() == 1);
261  //save layout information
262  ac->m_x = x(v);
263  ac->m_y = y(v);
264 
265  //remove node and unsplit edge
266 
267  //run around the dummy node connected to v
268  adjEntry outAdj = v->firstAdj();
269  adjEntry dummyAdj = outAdj->twin();
270 
271  node dummy = dummyAdj->theNode();
272  OGDF_ASSERT(dummy->degree() == 3);
273 
274  //we do not delete the node if we already inserted it in create...
275  //because it is a part of the graph now (in contrast to the split node)
276  m_pG->delEdge(v->firstAdj()->theEdge());
277  OGDF_ASSERT(v->degree() == 0);
278 
279  m_pG->unsplit(dummy);
280  }//undoAssociationClass
281 
282 protected:
285 
286  node replaceByStar(List<node> &clique, NodeArray<int> &cliqueNum);
287  DRect circularBound(node center);
288 
290 
291 private:
292 
294 
297 
298  //information about edges that are deleted in clique processing
299 #if 0
300  class CliqueInfo {
301  public:
302  CliqueInfo(node v, int i) : m_target(v), m_edgeIndex(i) {}
303  node m_target; //target node of deleted edge
304  int m_edgeIndex; //index of deleted edge, has to be restored
305  };
306 #endif
307 
310 
312  EdgeArray<bool> m_replacementEdge; // XXX: maybe we can join this with edge type
317 
319 
321  //structures for association classes
322  //may be replaced later by generic structures for different types
326 
329 
332 
337 
339 
341 };
342 
343 
344 } // end namespace ogdf
Declaration of singly linked lists and iterators.
NodeArray< node > m_hierarchyParent
used to derive edge types for alignment in PlanRepUML (same hierarchyparent => edge connects (half)br...
Definition: UMLGraph.h:336
Functionality for temporarily hiding edges in constant time.
Definition: Graph_d.h:770
virtual void init(const Graph &G, long attr)
Initializes the graph attributes for graph G.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
NodeArray< DRect > m_cliqueCircleSize
save the bounding box size of the circular drawing of the clique at center
Definition: UMLGraph.h:314
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:95
bool valid() const
Returns true iff the iterator points to an element.
Definition: SList.h:113
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Declaration and implementation of AdjEntryArray class.
const SListPure< AssociationClass * > & assClassList() const
Definition: UMLGraph.h:194
DRect cliqueRect(node v)
Returns the size of a circular drawing for a clique around center v.
Definition: UMLGraph.h:106
EdgeArray< AssociationClass * > m_assClass
association class for list
Definition: UMLGraph.h:324
Singly linked lists.
Definition: SList.h:38
NodeArray< DPoint > m_cliqueCirclePos
save the position of the node in the circular drawing of the clique
Definition: UMLGraph.h:316
node modelAssociationClass(AssociationClass *ac)
Definition: UMLGraph.h:232
Rectangles with real coordinates.
Definition: geometry.h:515
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:208
void modelAssociationClasses()
Inserts representation for association class in underlying graph.
Definition: UMLGraph.h:223
SListPure< edge > m_mergeEdges
Definition: UMLGraph.h:320
SListPure< AssociationClass * > m_assClassList
saves all accociation classes
Definition: UMLGraph.h:323
Encapsulates a pointer to an ogdf::SList element.
Definition: SList.h:40
void setDefaultCliqueCenterSize(double i)
Default size of inserted clique replacement center nodes.
Definition: UMLGraph.h:136
Real points.
Definition: geometry.h:219
Singly linked lists (maintaining the length of the list).
Definition: SList.h:777
double getDefaultCliqueCenterSize()
Definition: UMLGraph.h:137
DPoint cliquePos(node v)
Definition: UMLGraph.h:110
static const int nodeType
Corresponds to node attribute type(node).
Stores additional attributes of a graph (like layout information).
bool upwards(adjEntry a) const
Definition: UMLGraph.h:159
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing...
Definition: exceptions.h:308
no new dummy nodes are introduced, for every hyperedge e = (v_1, ..., v_l), we add a cliqie K_l conne...
EdgeArray< bool > m_replacementEdge
used to mark clique replacement edges
Definition: UMLGraph.h:312
Class for the representation of edges.
Definition: Graph_d.h:291
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:102
AssociationClass(edge e, double width=1.0, double height=1.0, double x=0.0, double y=0.0)
Definition: UMLGraph.h:182
virtual void init(Graph &G, long initAttr)
Definition: UMLGraph.h:66
Class for the representation of nodes.
Definition: Graph_d.h:167
virtual void init(const Graph &G, long initAttr) override
Initializes the graph attributes for graph G.
Definition: UMLGraph.h:77
void setUpwards(adjEntry a, bool b)
Sets status of edges to be specially embedded (if alignment)
Definition: UMLGraph.h:158
SListPure< node > m_centerNodes
center nodes introduced at clique replacement
Definition: UMLGraph.h:309
double m_cliqueCenterSize
default size of inserted clique replacement center nodes
Definition: UMLGraph.h:308
node createAssociationClass(edge e, double width=1.0, double height=1.0)
Adds association class to edge e.
Definition: UMLGraph.h:199
const SListPure< node > & centerNodes()
Definition: UMLGraph.h:133
Modelling of association classes.
Definition: UMLGraph.h:180
The namespace for all OGDF objects.
bool isReplacement(edge e)
Returns true if edge was inserted during clique replacement.
Definition: UMLGraph.h:140
const AssociationClass * assClass(edge e) const
Definition: UMLGraph.h:196
void undoAssociationClass(AssociationClass *ac)
Removes the modeling of the association class without removing the information.
Definition: UMLGraph.h:255
void undoAssociationClasses()
Definition: UMLGraph.h:244
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:211
EdgeArray< node > m_associationClassModel
modelled classes are stored
Definition: UMLGraph.h:325
Graph::HiddenEdgeSet * m_hiddenEdges
Definition: UMLGraph.h:340
AdjEntryArray< bool > m_upwardEdge
used to classify edges for embedding with alignment
Definition: UMLGraph.h:331
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:99
Class for adjacency list elements.
Definition: Graph_d.h:78
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
Graph * m_pG
Definition: UMLGraph.h:293