Extended SWIG python interface (inspired by Kyle Ellrott): inference is possible...
[libdai.git] / tests / unit / graph_test.cpp
1 /* This file is part of libDAI - http://www.libdai.org/
2 *
3 * Copyright (c) 2006-2011, The libDAI authors. All rights reserved.
4 *
5 * Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
6 */
7
8
9 #include <dai/graph.h>
10 #include <vector>
11 #include <strstream>
12
13
14 using namespace dai;
15
16
17 #define BOOST_TEST_MODULE GraphALTest
18
19
20 #include <boost/test/unit_test.hpp>
21
22
23 BOOST_AUTO_TEST_CASE( ConstructorsTest ) {
24 // check constructors
25 GraphAL G0;
26 BOOST_CHECK_EQUAL( G0.nrNodes(), 0 );
27 BOOST_CHECK_EQUAL( G0.nrEdges(), 0 );
28 BOOST_CHECK_EQUAL( G0.isConnected(), true );
29 BOOST_CHECK_EQUAL( G0.isTree(), true );
30 G0.checkConsistency();
31
32 GraphAL G2( 2 );
33 BOOST_CHECK_EQUAL( G2.nrNodes(), 2 );
34 BOOST_CHECK_EQUAL( G2.nrEdges(), 0 );
35 BOOST_CHECK_EQUAL( G2.isConnected(), false );
36 BOOST_CHECK_EQUAL( G2.isTree(), false );
37 G2.checkConsistency();
38 BOOST_CHECK( !(G2 == G0) );
39
40 std::vector<Edge> edges;
41 edges.push_back( Edge( 0, 1 ) );
42 edges.push_back( Edge( 1, 2 ) );
43 edges.push_back( Edge( 2, 1 ) );
44 edges.push_back( Edge( 1, 2 ) );
45 GraphAL G3( 3, edges.begin(), edges.end() );
46 BOOST_CHECK_EQUAL( G3.nrNodes(), 3 );
47 BOOST_CHECK_EQUAL( G3.nrEdges(), 2 );
48 BOOST_CHECK_EQUAL( G3.isConnected(), true );
49 BOOST_CHECK_EQUAL( G3.isTree(), true );
50 G3.checkConsistency();
51 BOOST_CHECK( !(G3 == G0) );
52 BOOST_CHECK( !(G3 == G2) );
53
54 GraphAL G4( G3 );
55 BOOST_CHECK( !(G4 == G0) );
56 BOOST_CHECK( !(G4 == G2) );
57 BOOST_CHECK( G4 == G3 );
58
59 GraphAL G5 = G3;
60 BOOST_CHECK( !(G5 == G0) );
61 BOOST_CHECK( !(G5 == G2) );
62 BOOST_CHECK( G5 == G3 );
63 }
64
65
66 BOOST_AUTO_TEST_CASE( NeighborTest ) {
67 // check nb() accessor / mutator
68 std::vector<Edge> edges;
69 edges.push_back( Edge( 0, 1 ) );
70 edges.push_back( Edge( 1, 2 ) );
71 GraphAL G( 3, edges.begin(), edges.end() );
72 BOOST_CHECK_EQUAL( G.nb(0).size(), 1 );
73 BOOST_CHECK_EQUAL( G.nb(1).size(), 2 );
74 BOOST_CHECK_EQUAL( G.nb(2).size(), 1 );
75 BOOST_CHECK_EQUAL( G.nb(0,0).iter, 0 );
76 BOOST_CHECK_EQUAL( G.nb(0,0).node, 1 );
77 BOOST_CHECK_EQUAL( G.nb(0,0).dual, 0 );
78 BOOST_CHECK_EQUAL( G.nb(1,0).iter, 0 );
79 BOOST_CHECK_EQUAL( G.nb(1,0).node, 0 );
80 BOOST_CHECK_EQUAL( G.nb(1,0).dual, 0 );
81 BOOST_CHECK_EQUAL( G.nb(1,1).iter, 1 );
82 BOOST_CHECK_EQUAL( G.nb(1,1).node, 2 );
83 BOOST_CHECK_EQUAL( G.nb(1,1).dual, 0 );
84 BOOST_CHECK_EQUAL( G.nb(2,0).iter, 0 );
85 BOOST_CHECK_EQUAL( G.nb(2,0).node, 1 );
86 BOOST_CHECK_EQUAL( G.nb(2,0).dual, 1 );
87 BOOST_CHECK( G.nbSet(0) == SmallSet<size_t>( 1 ) );
88 BOOST_CHECK( G.nbSet(1) == SmallSet<size_t>( 0, 2 ) );
89 BOOST_CHECK( G.nbSet(2) == SmallSet<size_t>( 1 ) );
90 }
91
92
93 BOOST_AUTO_TEST_CASE( AddEraseTest ) {
94 // check addition and erasure of nodes and edges
95 std::vector<Edge> edges;
96 edges.push_back( Edge( 0, 1 ) );
97 edges.push_back( Edge( 1, 2 ) );
98 edges.push_back( Edge( 1, 0 ) );
99 GraphAL G( 2 );
100 G.construct( 3, edges.begin(), edges.end() );
101 G.checkConsistency();
102 BOOST_CHECK_EQUAL( G.nrNodes(), 3 );
103 BOOST_CHECK_EQUAL( G.nrEdges(), 2 );
104 BOOST_CHECK_EQUAL( G.addNode(), 3 );
105 G.checkConsistency();
106 std::vector<size_t> nbs;
107 nbs.push_back( 3 );
108 BOOST_CHECK_EQUAL( G.addNode( nbs.begin(), nbs.end() ), 4 );
109 BOOST_CHECK_EQUAL( G.addNode(), 5 );
110 G.checkConsistency();
111 G.addEdge( 0, 4 );
112 G.checkConsistency();
113 G.addEdge( 0, 5 );
114 BOOST_CHECK( G.isTree() );
115 G.checkConsistency();
116 BOOST_CHECK_EQUAL( G.nrNodes(), 6 );
117 BOOST_CHECK_EQUAL( G.nrEdges(), 5 );
118 G.addEdge( 2, 3 );
119 BOOST_CHECK( !G.isTree() );
120
121 G.addEdge( 5, 3 );
122 G.eraseNode( 0 );
123 G.checkConsistency();
124 BOOST_CHECK( G.isTree() );
125 G.eraseEdge( 0, 1 );
126 G.checkConsistency();
127 BOOST_CHECK( !G.isTree() );
128 BOOST_CHECK( !G.isConnected() );
129 G.eraseNode( 0 );
130 G.checkConsistency();
131 BOOST_CHECK( G.isTree() );
132 G.addEdge( 3, 2 );
133 G.checkConsistency();
134 BOOST_CHECK( !G.isTree() );
135 G.eraseNode( 1 );
136 G.checkConsistency();
137 BOOST_CHECK( !G.isTree() );
138 BOOST_CHECK( !G.isConnected() );
139 G.eraseNode( 2 );
140 G.checkConsistency();
141 BOOST_CHECK( !G.isTree() );
142 BOOST_CHECK( !G.isConnected() );
143 G.addEdge( 1, 0 );
144 G.checkConsistency();
145 BOOST_CHECK( G.isTree() );
146 BOOST_CHECK( G.isConnected() );
147 G.eraseNode( 1 );
148 G.checkConsistency();
149 BOOST_CHECK( G.isTree() );
150 BOOST_CHECK( G.isConnected() );
151 G.eraseNode( 0 );
152 BOOST_CHECK( G.isTree() );
153 BOOST_CHECK( G.isConnected() );
154 BOOST_CHECK_EQUAL( G.nrNodes(), 0 );
155 BOOST_CHECK_EQUAL( G.nrEdges(), 0 );
156
157 G.addNode();
158 G.addNode();
159 G.addNode();
160 G.addNode();
161 G.addEdge( 0, 1 );
162 G.addEdge( 2, 3 );
163 G.addEdge( 0, 3 );
164 G.checkConsistency();
165 G.eraseNode( 2 );
166 G.checkConsistency();
167 }
168
169
170 BOOST_AUTO_TEST_CASE( RandomAddEraseTest ) {
171 // check adding and erasing nodes and edges randomly
172 GraphAL G;
173 for( size_t maxN = 2; maxN < 50; maxN++ )
174 for( size_t repeats = 0; repeats < 10000; repeats++ ) {
175 size_t action = rnd( 5 );
176 size_t N = G.nrNodes();
177 size_t M = G.nrEdges();
178 size_t maxM = N * (N - 1) / 2;
179 if( action == 0 ) {
180 // add node
181 if( N < maxN )
182 G.addNode();
183 } else if( action == 1 ) {
184 // erase node
185 if( N > 0 )
186 G.eraseNode( rnd( N ) );
187 } else if( action == 2 || action == 3 ) {
188 // add edge
189 if( N >= 2 && M < maxM ) {
190 size_t n1 = 0;
191 do {
192 n1 = rnd( N );
193 } while( G.nb(n1).size() >= N - 1 );
194 size_t n2 = 0;
195 do {
196 n2 = rnd( N );
197 } while( G.hasEdge( n1, n2 ) );
198 G.addEdge( n1, n2 );
199 }
200 } else if( action == 4 ) {
201 // erase edge
202 if( M > 0 ) {
203 size_t n1 = 0;
204 do {
205 n1 = rnd( N );
206 } while( G.nb(n1).size() == 0 );
207 size_t n2 = 0;
208 do {
209 n2 = rnd( N );
210 } while( !G.hasEdge( n1, n2 ) );
211 G.eraseEdge( n1, n2 );
212 }
213 }
214 G.checkConsistency();
215 }
216 }
217
218
219 BOOST_AUTO_TEST_CASE( QueriesAndCreationTest ) {
220 // check queries and createGraph* functions
221
222 // createGraphFull
223 for( size_t N = 0; N < 20; N++ ) {
224 GraphAL G = createGraphFull( N );
225 BOOST_CHECK_EQUAL( G.nrNodes(), N );
226 BOOST_CHECK_EQUAL( G.nrEdges(), N > 0 ? N * (N-1) / 2 : 0 );
227 BOOST_CHECK( G.isConnected() );
228 BOOST_CHECK_EQUAL( G.isTree(), N < 3 );
229 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
230 bforeach( const Neighbor &n2, G.nb(n1) ) {
231 BOOST_CHECK( G.hasEdge( n1, n2 ) );
232 BOOST_CHECK( G.hasEdge( n2, n1 ) );
233 }
234 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
235 if( G.hasEdge( n1, n2 ) ) {
236 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
237 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
238 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
239 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
240 }
241 }
242 G.checkConsistency();
243 }
244
245 // createGraphGrid
246 for( size_t N1 = 0; N1 < 10; N1++ )
247 for( size_t N2 = 0; N2 < 10; N2++ ) {
248 GraphAL G = createGraphGrid( N1, N2, false );
249 BOOST_CHECK_EQUAL( G.nrNodes(), N1 * N2 );
250 BOOST_CHECK_EQUAL( G.nrEdges(), (N1 > 0 && N2 > 0) ? 2 * (N1-1) * (N2-1) + (N1-1) + (N2-1) : 0 );
251 BOOST_CHECK( G.isConnected() );
252 BOOST_CHECK_EQUAL( G.isTree(), (N1 <= 1) || (N2 <= 1) );
253 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
254 bforeach( const Neighbor &n2, G.nb(n1) ) {
255 BOOST_CHECK( G.hasEdge( n1, n2 ) );
256 BOOST_CHECK( G.hasEdge( n2, n1 ) );
257 }
258 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
259 if( G.hasEdge( n1, n2 ) ) {
260 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
261 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
262 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
263 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
264 }
265 }
266 G.checkConsistency();
267
268 G = createGraphGrid( N1, N2, true );
269 BOOST_CHECK_EQUAL( G.nrNodes(), N1 * N2 );
270 if( N1 == 0 || N2 == 0 )
271 BOOST_CHECK_EQUAL( G.nrEdges(), 0 );
272 else
273 BOOST_CHECK_EQUAL( G.nrEdges(), (N1 <= 2 ? (N1-1) : N1) * N2 + N1 * (N2 <= 2 ? (N2-1) : N2) );
274 BOOST_CHECK( G.isConnected() );
275 BOOST_CHECK_EQUAL( G.isTree(), (G.nrNodes() <= 2) );
276 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
277 bforeach( const Neighbor &n2, G.nb(n1) ) {
278 BOOST_CHECK( G.hasEdge( n1, n2 ) );
279 BOOST_CHECK( G.hasEdge( n2, n1 ) );
280 }
281 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
282 if( G.hasEdge( n1, n2 ) ) {
283 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
284 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
285 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
286 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
287 }
288 }
289 G.checkConsistency();
290 }
291
292 // createGraphGrid3D
293 for( size_t N1 = 0; N1 < 8; N1++ )
294 for( size_t N2 = 0; N2 < 8; N2++ )
295 for( size_t N3 = 0; N3 < 8; N3++ ) {
296 GraphAL G = createGraphGrid3D( N1, N2, N3, false );
297 BOOST_CHECK_EQUAL( G.nrNodes(), N1 * N2 * N3 );
298 BOOST_CHECK_EQUAL( G.nrEdges(), (N1 > 0 && N2 > 0 && N3 > 0) ? 3 * (N1-1) * (N2-1) * (N3-1) + 2 * (N1-1) * (N2-1) + 2 * (N1-1) * (N3-1) + 2 * (N2-1) * (N3-1) + (N1-1) + (N2-1) + (N3-1) : 0 );
299 BOOST_CHECK( G.isConnected() );
300 BOOST_CHECK_EQUAL( G.isTree(), (G.nrNodes() == 0) || (N1 <= 1 && N2 <= 1) || (N1 <= 1 && N3 <= 1) || (N2 <= 1 && N3 <= 1) );
301 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
302 bforeach( const Neighbor &n2, G.nb(n1) ) {
303 BOOST_CHECK( G.hasEdge( n1, n2 ) );
304 BOOST_CHECK( G.hasEdge( n2, n1 ) );
305 }
306 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
307 if( G.hasEdge( n1, n2 ) ) {
308 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
309 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
310 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
311 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
312 }
313 }
314 G.checkConsistency();
315
316 G = createGraphGrid3D( N1, N2, N3, true );
317 BOOST_CHECK_EQUAL( G.nrNodes(), N1 * N2 * N3 );
318 if( N1 == 0 || N2 == 0 || N3 == 0 )
319 BOOST_CHECK_EQUAL( G.nrEdges(), 0 );
320 else
321 BOOST_CHECK_EQUAL( G.nrEdges(), (N1 <= 2 ? (N1-1) : N1) * N2 * N3 + N1 * (N2 <= 2 ? (N2-1) : N2) * N3 + N1 * N2 * (N3 <= 2 ? (N3-1) : N3) );
322 BOOST_CHECK( G.isConnected() );
323 BOOST_CHECK_EQUAL( G.isTree(), (G.nrNodes() <= 2) );
324 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
325 bforeach( const Neighbor &n2, G.nb(n1) ) {
326 BOOST_CHECK( G.hasEdge( n1, n2 ) );
327 BOOST_CHECK( G.hasEdge( n2, n1 ) );
328 }
329 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
330 if( G.hasEdge( n1, n2 ) ) {
331 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
332 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
333 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
334 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
335 }
336 }
337 G.checkConsistency();
338 }
339
340 // createGraphLoop
341 for( size_t N = 0; N < 100; N++ ) {
342 GraphAL G = createGraphLoop( N );
343 BOOST_CHECK_EQUAL( G.nrNodes(), N );
344 if( N == 0 )
345 BOOST_CHECK_EQUAL( G.nrEdges(), 0 );
346 else if( N <= 2 )
347 BOOST_CHECK_EQUAL( G.nrEdges(), N-1 );
348 else
349 BOOST_CHECK_EQUAL( G.nrEdges(), N );
350 BOOST_CHECK( G.isConnected() );
351 BOOST_CHECK_EQUAL( G.isTree(), N <= 2 );
352 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
353 bforeach( const Neighbor &n2, G.nb(n1) ) {
354 BOOST_CHECK( G.hasEdge( n1, n2 ) );
355 BOOST_CHECK( G.hasEdge( n2, n1 ) );
356 }
357 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
358 if( G.hasEdge( n1, n2 ) ) {
359 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
360 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
361 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
362 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
363 }
364 }
365 G.checkConsistency();
366 }
367
368 // createGraphTree
369 for( size_t N = 0; N < 100; N++ ) {
370 GraphAL G = createGraphTree( N );
371 BOOST_CHECK_EQUAL( G.nrNodes(), N );
372 BOOST_CHECK_EQUAL( G.nrEdges(), N > 0 ? N - 1 : N );
373 BOOST_CHECK( G.isConnected() );
374 BOOST_CHECK( G.isTree() );
375 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
376 bforeach( const Neighbor &n2, G.nb(n1) ) {
377 BOOST_CHECK( G.hasEdge( n1, n2 ) );
378 BOOST_CHECK( G.hasEdge( n2, n1 ) );
379 }
380 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
381 if( G.hasEdge( n1, n2 ) ) {
382 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
383 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
384 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
385 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
386 }
387 }
388 G.checkConsistency();
389 }
390
391 // createGraphRegular
392 for( size_t N = 0; N < 50; N++ ) {
393 for( size_t d = 0; d < N && d <= 15; d++ ) {
394 if( (N * d) % 2 == 0 ) {
395 GraphAL G = createGraphRegular( N, d );
396 BOOST_CHECK_EQUAL( G.nrNodes(), N );
397 BOOST_CHECK_EQUAL( G.nrEdges(), d * N / 2 );
398 for( size_t n1 = 0; n1 < G.nrNodes(); n1++ ) {
399 BOOST_CHECK_EQUAL( G.nb(n1).size(), d );
400 bforeach( const Neighbor &n2, G.nb(n1) ) {
401 BOOST_CHECK( G.hasEdge( n1, n2 ) );
402 BOOST_CHECK( G.hasEdge( n2, n1 ) );
403 }
404 for( size_t n2 = 0; n2 < G.nrNodes(); n2++ )
405 if( G.hasEdge( n1, n2 ) ) {
406 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ), n2 );
407 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ), n1 );
408 BOOST_CHECK_EQUAL( G.nb( n1, G.findNb( n1, n2 ) ).iter, G.findNb( n1, n2 ) );
409 BOOST_CHECK_EQUAL( G.nb( n2, G.findNb( n2, n1 ) ).iter, G.findNb( n2, n1 ) );
410 }
411 }
412 G.checkConsistency();
413 }
414 }
415 }
416 }
417
418
419 BOOST_AUTO_TEST_CASE( StreamTest ) {
420 // check printDot
421 GraphAL G( 4 );
422 G.addEdge( 0, 1 );
423 G.addEdge( 0, 2 );
424 G.addEdge( 1, 3 );
425 G.addEdge( 2, 3 );
426 G.addEdge( 2, 2 );
427 G.addEdge( 3, 2 );
428
429 std::stringstream ss;
430 std::string s;
431
432 G.printDot( ss );
433 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "graph GraphAL {" );
434 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "node[shape=circle,width=0.4,fixedsize=true];" );
435 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx0;" );
436 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx1;" );
437 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx2;" );
438 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx3;" );
439 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx0 -- x1;" );
440 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx0 -- x2;" );
441 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx1 -- x3;" );
442 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx2 -- x3;" );
443 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "}" );
444
445 ss << G;
446 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "graph GraphAL {" );
447 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "node[shape=circle,width=0.4,fixedsize=true];" );
448 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx0;" );
449 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx1;" );
450 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx2;" );
451 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx3;" );
452 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx0 -- x1;" );
453 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx0 -- x2;" );
454 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx1 -- x3;" );
455 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "\tx2 -- x3;" );
456 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "}" );
457
458 BOOST_CHECK_EQUAL( G.toString(), "graph GraphAL {\nnode[shape=circle,width=0.4,fixedsize=true];\n\tx0;\n\tx1;\n\tx2;\n\tx3;\n\tx0 -- x1;\n\tx0 -- x2;\n\tx1 -- x3;\n\tx2 -- x3;\n}\n" );
459 }