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