1 [OGDF](../../README.md) » [Porting Guide](../porting.md) » Baobab
3 # Porting from Sakura to Baobab
7 ### List, SList, ListPure, SListPure search() method
9 The `search(element)` method returned a position index.
10 It now returns a `ListIterator` or `ListConstIterator`.
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))` |
20 Some methods for reading and writing graphs have been **moved** to `GraphIO`
21 (as static methods, where the `ClusterGraph` is the first parameter):
23 | old method | new method |
24 | ------------------------ | --------------------- |
25 | `readClusterGML` | `GraphIO::readGML` |
26 | `writeGML` | `GraphIO::writeGML` |
27 | `readClusterGraphOGML` | `GraphIO::readOGML` |
29 ### ClusterGraphAttributes
31 Some **attribute access methods** have been renamed for consistency.
32 The following table shows the changes.
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` |
50 Access to cluster attributes by **cluster index** has been removed.
51 Use index by cluster instead.
53 The method `clusterID(node v)` has been **removed**.
54 Use `cga.clusterOf(v)->index()` instead (if `cga` is an instance
55 of `ClusterGraphAttributes`).
57 Some methods for reading and writing graphs have been **moved** to `GraphIO`
58 (as static methods, where `ClusterGraphAttributes` is the first parameter):
60 | old method | new method |
61 | ------------------------ | ---------------------- |
62 | `readClusterGML` | `GraphIO::readGML` |
63 | `writeGML` | `GraphIO::writeGML` |
64 | `readClusterGraphOGML` | `GraphIO::readOGML` |
65 | `writeOGML` | `GraphIO::writeOGML` |
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.
77 include <ogdf/basic/DisjointSets.h>
79 DisjointSets<edge> uf(G.numberOfEdges());
80 EdgeArray<int> setID(G);
84 setID[e] = uf.makeSet(e);
89 include <ogdf/basic/DisjointSets.h>
91 DisjointSets<> uf(G.numberOfEdges());
92 EdgeArray<int> setID(G);
96 setID[e] = uf.makeSet();
102 Some methods for reading and writing graphs have been **moved** to `GraphIO`
103 (as static methods, where the `Graph` is the first parameter):
105 | old method | new method |
106 | ----------------- | --------------------- |
107 | `readGML` | `GraphIO::readGML` |
108 | `writeGML` | `GraphIO::writeGML` |
109 | `readLEDAGraph` | `GraphIO::readLEDA` |
114 Some **types** have been renamed and moved to `graphics.h`:
116 | old name | new name |
117 | --------------------------------- | --------------- |
118 | `GraphAttributes::BrushPattern` | `FillPattern` |
119 | `GraphAttributes::EdgeArrow` | `EdgeArrow` |
120 | `GraphAttributes::EdgeStyle` | `StrokeType` |
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
129 Some **attribute access methods** have been renamed for consistency.
130 The following table shows the changes.
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 |
147 The setter method `directed` has been **renamed** to `setDirected`.
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`
153 Some methods for reading and writing graphs have been **moved** to GraphIO
154 (as static methods, where `GraphAttributes` is the first parameter):
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` |
166 Use `delNode()` and `delEdge()` (as you would do in a `Graph`) instead of `delCopy()`.
170 This class has been **removed**.
171 The SteinLib file reader (`SteinLibParser::readSteinLibInstance`) is now in
172 `GraphIO` (`GraphIO::readSTP`).
176 This class has been **removed**; use `std::string` instead.
178 Users of the `sprintf` methods should replace code like
180 GA.label(v).sprintf("Node %d", v->index() + 1);
184 GA.label(v) = "Node " + to_string(v->index() + 1);
186 For more sophisticated formatting, use a stringstream.
189 ### PlanarizationLayout
191 Different modules, use now `SubgraphPlanarizer`
195 Has been renamed to `LayerByLayerSweep`.
199 Some methods that are common in some classes are changed/renamed/moved.
203 These methods are usually moved to `GraphIO`.
207 Use `delEdge()` or `delNode()` instead.
211 If the graph is read-only, use `constGraph()`.
215 ### simple_graph_load.h
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.
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` |
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.
240 This file has been completely **removed**.
241 The SteinLib file reader (`SteinLibParser::readSteinLibInstance`) is now in `GraphIO` (`GraphIO::readSTP`).
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);`
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).
261 GraphIO handles reading from and writing to several graph formats, saving to SVG vector graphics format, and so on.
263 Simple usage example:
265 include <ogdf/fileformats/GraphIO.h>
268 GraphIO::readRome(G, "foo");
270 GraphIO::writeGML(G, "foo.gml");
272 GraphIO::drawSVG(GA, "foo.svg");
276 ## Third-party Libraries
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.
284 Abacus 3.2 is now integrated into OGDF, in its own namespace named `abacus`.
288 All classes like `ABA_FOOBAR` have been renamed
289 such that the `ABA_` prefix is removed and the suffix is camel-cased,
291 Examples are `Master`, `VarType`, `Variable`, `Sub`, `CSense`, `FSVarStat`.
293 There are exceptions and some classes have also been removed. See the following list:
295 | old name | use instead |
296 | ---------------- | ---------------- |
297 | `ABA_BUFFER` | `ArrayBuffer` |
298 | `ABA_CPUTIMER` | `StopwatchCPU` |
299 | `ABA_STRING` | `string` |
301 #### Missing Header Files
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.
308 #### Const Correctness
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.
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.
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.
328 Only minor changes have been made to the COIN-OR source which are documented in `src/coin/Readme.txt`.