Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

doc/porting/baobab.md
Go to the documentation of this file.
1 [OGDF](../../README.md) » [Porting Guide](../porting.md) » Baobab
2 
3 # Porting from Sakura to Baobab
4 
5 ## Classes
6 
7 ### List, SList, ListPure, SListPure search() method
8 
9 The `search(element)` method returned a position index.
10 It now returns a `ListIterator` or `ListConstIterator`.
11 
12 | use case | old code | new code |
13 | ----------------------------------------- | ----------------------------------- | ------------------------------------|
14 | check if element is a member of the list | `list.search(element) != -1` | `list.search(element).valid()` |
15 | find the iterator for an element | `list.get(list.search(element))` | `list.search(element)` |
16 | find the position index of an element | `list.search(element)` | `list.pos(list.search(element))` |
17 
18 ### ClusterGraph
19 
20 Some methods for reading and writing graphs have been **moved** to `GraphIO`
21 (as static methods, where the `ClusterGraph` is the first parameter):
22 
23 | old method | new method |
24 | ------------------------ | --------------------- |
25 | `readClusterGML` | `GraphIO::readGML` |
26 | `writeGML` | `GraphIO::writeGML` |
27 | `readClusterGraphOGML` | `GraphIO::readOGML` |
28 
29 ### ClusterGraphAttributes
30 
31 Some **attribute access methods** have been renamed for consistency.
32 The following table shows the changes.
33 
34 | old name | new name | remark |
35 | ------------------------- | -------- | ------ |
36 | `clusterBackColor` | `fillBgColor` | colors are now represented by `Color` (instead of `String`) |
37 | `clusterColor` | `strokeColor` | colors are now represented by `Color` (instead of `String`) |
38 | `clusterFillColor` | `fillColor` | colors are now represented by `Color` (instead of `String`) |
39 | `clusterFillPattern` | `fillPattern` | attribute type has been changed from `GraphAttributes::BrushPattern` to `FillPattern`; use `setFillPattern` to change the attribute value |
40 | `clusterHeight` | `height` | |
41 | `clusterLabel` | `label` | |
42 | `clusterLineStyle` | `strokeType` | attribute type has been changed from `GraphAttributes::EdgeStyle` to `StrokeType`; use `setStrokeType` to change the attribute value |
43 | `clusterLineWidth` | `strokeWidth` | attribute type has been changed from `double` to `float` |
44 | `clusterWidth` | `width` | |
45 | `clusterXPos` | `x` | |
46 | `clusterYPos` | `y` | |
47 | `setClusterFillPattern` | `setFillPattern` | attribute type has been changed from `GraphAttributes::BrushPattern` to `FillPattern` |
48 | `setClusterLineStyle` | `setStrokeType` | attribute type has been changed from `GraphAttributes::EdgeStyle` to `StrokeType` |
49 
50 Access to cluster attributes by **cluster index** has been removed.
51 Use index by cluster instead.
52 
53 The method `clusterID(node v)` has been **removed**.
54 Use `cga.clusterOf(v)->index()` instead (if `cga` is an instance
55 of `ClusterGraphAttributes`).
56 
57 Some methods for reading and writing graphs have been **moved** to `GraphIO`
58 (as static methods, where `ClusterGraphAttributes` is the first parameter):
59 
60 | old method | new method |
61 | ------------------------ | ---------------------- |
62 | `readClusterGML` | `GraphIO::readGML` |
63 | `writeGML` | `GraphIO::writeGML` |
64 | `readClusterGraphOGML` | `GraphIO::readOGML` |
65 | `writeOGML` | `GraphIO::writeOGML` |
66 
67 ### DisjointSets
68 
69 DisjointSets manages disjoint sets of *integers* (set IDs) from zero
70 to the maximum number of sets. The mapping (for example from nodes
71 to set IDs) is the responsibility of the user.
72 The first template parameter (the type of the set elements) is now
73 gone because it was not necessary.
74 
75 The code
76 ```c++
77 include <ogdf/basic/DisjointSets.h>
78 …
79  DisjointSets<edge> uf(G.numberOfEdges());
80  EdgeArray<int> setID(G);
81  …
82  edge e;
83  …
84  setID[e] = uf.makeSet(e);
85 …
86 ```
87 simply becomes
88 ```c++
89 include <ogdf/basic/DisjointSets.h>
90 …
91  DisjointSets<> uf(G.numberOfEdges());
92  EdgeArray<int> setID(G);
93  …
94  edge e;
95  …
96  setID[e] = uf.makeSet();
97 …
98 ```
99 
100 ### Graph
101 
102 Some methods for reading and writing graphs have been **moved** to `GraphIO`
103 (as static methods, where the `Graph` is the first parameter):
104 
105 | old method | new method |
106 | ----------------- | --------------------- |
107 | `readGML` | `GraphIO::readGML` |
108 | `writeGML` | `GraphIO::writeGML` |
109 | `readLEDAGraph` | `GraphIO::readLEDA` |
110 
111 
112 ### GraphAttributes
113 
114 Some **types** have been renamed and moved to `graphics.h`:
115 
116 | old name | new name |
117 | --------------------------------- | --------------- |
118 | `GraphAttributes::BrushPattern` | `FillPattern` |
119 | `GraphAttributes::EdgeArrow` | `EdgeArrow` |
120 | `GraphAttributes::EdgeStyle` | `StrokeType` |
121 
122 The scope of some **attribute bit specifiers** (for the constructor of
123 `GraphAttributes`) has grown such that some other could be removed:
124 `GraphAttributes::nodeStyle` now implies `GraphAttributes::nodeColor`
125 which has hence been removed. In the same way, use `GraphAttributes::edgeStyle`
126 instead of `GraphAttributes::edgeColor`. `GraphAttributes::nodeLevel` has
127 just been removed.
128 
129 Some **attribute access methods** have been renamed for consistency.
130 The following table shows the changes.
131 
132 | old name | new name | remark |
133 | ----------------- | --------------- | ------ |
134 | `arrowEdge` | `arrowType` | attribute type has been changed from `GraphAttributes::EdgeArrow` to `EdgeArrow` |
135 | `colorEdge` | `strokeColor` | colors are now represented by `Color` (instead of `String`) |
136 | `colorNode` | `fillColor` | colors are now represented by `Color` (instead of `String`) |
137 | `edgeWidth` | `strokeWidth` | attribute type has been changed from `double` to `float` |
138 | `labelEdge` | `label` | |
139 | `labelNode` | `label` | |
140 | `lineWidthNode` | `strokeWidth` | attribute type has been changed from `double` to `float` |
141 | `nodeLine` | `strokeColor` | colors are now represented by `Color` (instead of `String`) |
142 | `nodePattern` | `fillPattern` | attribute type has been changed from `GraphAttributes::BrushPattern` to `FillPattern`; use `setFillPattern` to change the attribute value |
143 | `shapeNode` | `shape` | attribute type has been changed from `int` to `Shape` |
144 | `styleEdge` | `strokeType` | attribute type has been changed from `GraphAttributes::EdgeStyle` to `StrokeType`; use `setStrokeType` to change the attribute value |
145 | `styleNode` | `strokeType` | attribute type has been changed from `GraphAttributes::EdgeStyle` to `StrokeType`; use `setStrokeType` to change the attribute value |
146 
147 The setter method `directed` has been **renamed** to `setDirected`.
148 
149 Some types and attributes have been **removed** as they are not used anymore:
150  * types: `GraphAttributes::ImageAlignment`, `GraphAttributes::ImageStyle`
151  * methods: `imageAlignmentNode`, `imageDrawLineNode`, `imageHeightNode`, `imageStyleNode`, `imageUriNode`, `imageWidthNode`
152 
153 Some methods for reading and writing graphs have been **moved** to GraphIO
154 (as static methods, where `GraphAttributes` is the first parameter):
155 
156 | old method | new method |
157 | ------------- | ---------------------- |
158 | `readGML` | `GraphIO::readGML` |
159 | `writeGML` | `GraphIO::writeGML` |
160 | `readRudy` | `GraphIO::readRudy` |
161 | `writeRudy` | `GraphIO::writeRudy` |
162 | `writeSVG` | `GraphIO::drawSVG` |
163 
164 ### GraphCopy
165 
166 Use `delNode()` and `delEdge()` (as you would do in a `Graph`) instead of `delCopy()`.
167 
168 ### SteinLibParser
169 
170 This class has been **removed**.
171 The SteinLib file reader (`SteinLibParser::readSteinLibInstance`) is now in
172 `GraphIO` (`GraphIO::readSTP`).
173 
174 ### String
175 
176 This class has been **removed**; use `std::string` instead.
177 
178 Users of the `sprintf` methods should replace code like
179 ```c++
180  GA.label(v).sprintf("Node %d", v->index() + 1);
181 ```
182 by code like
183 ```c++
184  GA.label(v) = "Node " + to_string(v->index() + 1);
185 ```
186 For more sophisticated formatting, use a stringstream.
187 
188 
189 ### PlanarizationLayout
190 
191 Different modules, use now `SubgraphPlanarizer`
192 
193 ### TwoLayerCrossMin
194 
195 Has been renamed to `LayerByLayerSweep`.
196 
197 ## Methods
198 
199 Some methods that are common in some classes are changed/renamed/moved.
200 
201 ### read* and write*
202 
203 These methods are usually moved to `GraphIO`.
204 
205 ### delCopy()
206 
207 Use `delEdge()` or `delNode()` instead.
208 
209 ### getGraph()
210 
211 If the graph is read-only, use `constGraph()`.
212 
213 ## Files
214 
215 ### simple_graph_load.h
216 
217 This file has been completely **removed**.
218 All its functions are now static methods in the class `GraphIO`, though with a different name.
219 The following table explains the name changes.
220 
221 | old name | new name |
222 | ------------------------ | ---------------------------------- |
223 | `loadRomeGraph` | `GraphIO::readRome` |
224 | `loadChacoGraph` | `GraphIO::readChaco` |
225 | `loadSimpleGraph` | `GraphIO::readPMDissGraph` |
226 | `loadYGraph` | `GraphIO::readYGraph` |
227 | `loadChallengeGraph` | `GraphIO::readChallengeGraph` |
228 | `saveChallengeGraph` | `GraphIO::writeChallengeGraph` |
229 | `loadEdgeListSubgraph` | `GraphIO::readEdgeListSubgraph` |
230 | `saveEdgeListSubgraph` | `GraphIO::writeEdgeListSubgraph` |
231 | `loadBenchHypergraph` | `GraphIO::writeChaco` |
232 | `loadPlaHypergraph` | `GraphIO::readPLA` |
233 | `loadBenchHypergraph` | `GraphIO::readBENCH` |
234 
235 For `loadYGraph`, note that the input file is now specified
236 by `istream` or a filename string, instead of a C-style `FILE` handle.
237 
238 ### SteinLibParser.h
239 
240 This file has been completely **removed**.
241 The SteinLib file reader (`SteinLibParser::readSteinLibInstance`) is now in `GraphIO` (`GraphIO::readSTP`).
242 
243 ## General Concepts
244 
245 ### Colors
246 
247 Colors are now represented by the class `Color`,
248 and no longer by strings of the form `"#RRGGBB"`.
249 For porting these string representations, `Color` offers you several options:
250  * You can construct a `Color` from its string representation by passing the string in the constructor: `Color color("ff0000");`
251  * You can set a color from the string representation: `Color color; ... color.fromString("ff0000");`
252  * You can decompose the string representation and construct the color from its components: `Color color(0xff,0x00,0x00);`
253  * You can use named colors from the `Color::Name` enumeration: `Color color(Color::Red);`
254 
255 The most readable form is the latter one, so it might be useful to adopt this version where possible;
256 the `Color::Name` enumeration is quite extensive and corresponds to the
257 [SVG color keywords](http://www.w3.org/TR/SVG/types.html#ColorKeywords).
258 
259 ### GraphIO
260 
261 GraphIO handles reading from and writing to several graph formats, saving to SVG vector graphics format, and so on.
262 
263 Simple usage example:
264 ```c++
265 include <ogdf/fileformats/GraphIO.h>
266 
267 …
268  GraphIO::readRome(G, "foo");
269  …
270  GraphIO::writeGML(G, "foo.gml");
271  …
272  GraphIO::drawSVG(GA, "foo.svg");
273 …
274 ```
275 
276 ## Third-party Libraries
277 
278 Some code uses LP solvers or SAT solvers. To keep the third-party dependencies
279 of OGDF small and ease the use of that solvers, such solvers are now included
280 or integrated into OGDF.
281 
282 ### Abacus
283 
284 Abacus 3.2 is now integrated into OGDF, in its own namespace named `abacus`.
285 
286 #### Abacus Classes
287 
288 All classes like `ABA_FOOBAR` have been renamed
289 such that the `ABA_` prefix is removed and the suffix is camel-cased,
290 like `FooBar`.
291 Examples are `Master`, `VarType`, `Variable`, `Sub`, `CSense`, `FSVarStat`.
292 
293 There are exceptions and some classes have also been removed. See the following list:
294 
295 | old name | use instead |
296 | ---------------- | ---------------- |
297 | `ABA_BUFFER` | `ArrayBuffer` |
298 | `ABA_CPUTIMER` | `StopwatchCPU` |
299 | `ABA_STRING` | `string` |
300 
301 #### Missing Header Files
302 
303 Because Abacus' own timers are replaced by OGDF timers, the file `abacus/timer.h`
304 has been removed. Instead include `ogdf/basic/Stopwatch.h` and use the
305 `StopwatchWallClock` or `StopwatchCPU` classes. Note that they must not be
306 initialized with Abacus objects.
307 
308 #### Const Correctness
309 
310 Abacus is not fully const correct.
311 For the OGDF integration, missing `const` declarations have been inserted.
312 However, when using old Abacus code (written against the original Abacus)
313 this may lead to non-compiling code when you inherit from Abacus classes
314 with virtual methods that were non-const and are now const.
315 
316 For example, virtual `Constraint` methods like `print` and `coeff` are
317 all declared const now. If you define non-const `print` and `coeff` in
318 your own constraints, the const `print` and `coeff` version are still
319 undefined. C++ compilers like `g++` may hence display errors like
320 "`cannot allocate an object of abstract type ‘YourConstraintType’`".
321 Adding `const` keywords in the right position(s) should solve the problems.
322 
323 ### COIN-OR
324 
325 COIN-OR (Clp 1.14.7 and Symphony 5.4.5) is included in the OGDF source tree.
326 However, it is not linked to the OGDF binary.
327 
328 Only minor changes have been made to the COIN-OR source which are documented in `src/coin/Readme.txt`.