Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
precondition.h
Go to the documentation of this file.
1
36#pragma once
37
39#include <ogdf/uml/UMLGraph.h>
40
41namespace ogdf {
42
43//descent the hierarchy tree at "sink" v recursively
45 NodeArray<int>& hierNumber, //number of hierarchy tree
46 // A node is visited if its hierNumber != 0
47 int hierNum, node v,
48 List<edge>& fakedGens, //temporary
49 bool fakeTree) {
50 OGDF_ASSERT(hierNumber[v] == 0);
52
53 bool returnValue = true;
54
55 for (adjEntry adj : v->adjEntries) {
56 edge e = adj->theEdge();
57 if (e->source() == v) {
58 continue;
59 }
60 if (!(UG.type(e) == Graph::EdgeType::generalization)) {
61 continue;
62 }
63 if (used[e]) {
64 continue; //error ??
65 }
66 used[e] = true;
67
68 node w = e->opposite(v);
69
70 if (hierNumber[w]) {
71 //temporarily fake trees
72 // if (hierNumber[w] == hierNum) //forward search edge
73 if (fakeTree) {
74#if 0
75 UG.type(e) = Graph::association;
76#endif
77 fakedGens.pushBack(e);
78 continue;
79 } else {
80 return false; //reached w over unused edge => no tree
81 }
82 }
83
85 //shortcut
86 if (!returnValue) {
87 return false;
88 }
89 }
90
91 return returnValue;
92}
93
95 for (adjEntry adj : v->adjEntries) {
96 edge e = adj->theEdge();
97 if (e->target() == v) {
98 continue;
99 }
100 if (UG.type(e) == Graph::EdgeType::generalization) {
101#if 0
102 OGDF_ASSERT(!used[e]);
103#endif
104 return e;
105 } else {
106 continue;
107 }
108 }
109 return nullptr;
110}
111
113 EdgeArray<bool> used(UG.constGraph(), false);
114#if 0
115 NodeArray<bool> visited(UG,false);
116#endif
117 NodeArray<int> hierNumber(UG.constGraph(), 0);
118
119 int hierNum = 0; //number of hierarchy tree
120
121 const Graph& G = UG.constGraph();
122 for (edge e : G.edges) {
123 //descent in the hierarchy containing e
124 if (!used[e] && UG.type(e) == Graph::EdgeType::generalization) {
125 hierNum++; //current hierarchy tree
126 //first we search for the sink
127 node sink = e->target();
128 edge sinkPath = firstOutGen(UG, e->target(), used);
129 int cycleCounter = 0;
130 while (sinkPath) {
131 sink = sinkPath->target();
132 sinkPath = firstOutGen(UG, sinkPath->target(), used);
133 cycleCounter++;
134 //if there is no sink, convert Generalizations to Associations and draw
135 if (cycleCounter > G.numberOfEdges()) {
137 fakedGens.pushBack(sinkPath);
138 sink = sinkPath->source();
139 sinkPath = nullptr;
140 }
141 }
142
143 //now sink is the hierarchy sink
144
145 //used is set in dfsGenTreeRec
147 if (!isTree) {
148 return false;
149 }
150 }
151 }
152
153 return true;
154}
155
156}
Declaration of EdgeRouter...
Declaration of class UMLGraph.
Class for adjacency list elements.
Definition Graph_d.h:79
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
node opposite(node v) const
Returns the adjacent node different from v.
Definition Graph_d.h:350
node target() const
Returns the target node of the edge.
Definition Graph_d.h:338
node source() const
Returns the source node of the edge.
Definition Graph_d.h:335
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition Graph_d.h:208
bool isTree(const Graph &G)
Returns true iff G is a tree, i.e. contains no undirected cycle and is connected.
#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.
bool dfsGenTree(UMLGraph &UG, List< edge > &fakedGens, bool fakeTree)
bool dfsGenTreeRec(UMLGraph &UG, EdgeArray< bool > &used, NodeArray< int > &hierNumber, int hierNum, node v, List< edge > &fakedGens, bool fakeTree)
edge firstOutGen(UMLGraph &UG, node v, EdgeArray< bool > &)