1 // Copyright 2009 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Authors: Nicholas Edmonds
8 // Andrew Lumsdaine
9
10 #include <boost/random.hpp>
11 #include <boost/test/minimal.hpp>
12
13 #include <boost/graph/rmat_graph_generator.hpp>
14 #include <boost/graph/small_world_generator.hpp>
15 #include <boost/graph/ssca_graph_generator.hpp>
16 #include <boost/graph/erdos_renyi_generator.hpp>
17 #include <boost/graph/mesh_graph_generator.hpp>
18
19 #include <boost/graph/adjacency_list.hpp>
20
21 using namespace boost;
22
test_main(int argc,char ** argv)23 int test_main(int argc, char** argv) {
24
25 typedef rand48 RandomGenerator;
26
27 typedef adjacency_list<vecS, vecS, directedS> Graph;
28
29 RandomGenerator gen;
30
31 size_t N = 100;
32 size_t M = 1000;
33 double p = 0.05;
34
35 // Test Erdos-Renyi generator
36 {
37 erdos_renyi_iterator<RandomGenerator, Graph> start(gen, N, p);
38 erdos_renyi_iterator<RandomGenerator, Graph> end;
39
40 while (start != end) ++start;
41
42 BOOST_CHECK(start == end);
43 }
44
45 {
46 sorted_erdos_renyi_iterator<RandomGenerator, Graph> start(gen, N, p);
47 sorted_erdos_renyi_iterator<RandomGenerator, Graph> end;
48
49 while (start != end) ++start;
50
51 BOOST_CHECK(start == end);
52 }
53
54 // Test Small World generator
55 {
56 small_world_iterator<RandomGenerator, Graph> start(gen, N, M, p);
57 small_world_iterator<RandomGenerator, Graph> end;
58
59 while (start != end) ++start;
60
61 BOOST_CHECK(start == end);
62 }
63
64 // Test SSCA generator
65 {
66 ssca_iterator<RandomGenerator, Graph> start(gen, N, 5, 0.5, 5, p);
67 ssca_iterator<RandomGenerator, Graph> end;
68
69 while (start != end) ++start;
70
71 BOOST_CHECK(start == end);
72 }
73
74 // Test Mesh generator
75 {
76 mesh_iterator<Graph> start(N, N);
77 mesh_iterator<Graph> end;
78
79 while (start != end) ++start;
80
81 BOOST_CHECK(start == end);
82 }
83
84 // Test R-MAT generator
85 double a = 0.57, b = 0.19, c = 0.19, d = 0.05;
86
87 {
88 rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d);
89 rmat_iterator<RandomGenerator, Graph> end;
90
91 while (start != end) ++start;
92
93 BOOST_CHECK(start == end);
94 }
95
96 {
97 unique_rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d);
98 unique_rmat_iterator<RandomGenerator, Graph> end;
99
100 while (start != end) ++start;
101
102 BOOST_CHECK(start == end);
103 }
104
105 {
106 sorted_unique_rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d);
107 sorted_unique_rmat_iterator<RandomGenerator, Graph> end;
108
109 while (start != end) ++start;
110
111 BOOST_CHECK(start == end);
112 }
113
114 {
115 sorted_unique_rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d, true);
116 sorted_unique_rmat_iterator<RandomGenerator, Graph> end;
117
118 while (start != end) ++start;
119
120 BOOST_CHECK(start == end);
121 }
122
123 return 0;
124 }
125