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/core/lightweight_test.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
21using namespace boost;
22
23int main(int argc, char** argv)
24{
25
26 typedef rand48 RandomGenerator;
27
28 typedef adjacency_list< vecS, vecS, directedS > Graph;
29
30 RandomGenerator gen;
31
32 size_t N = 100;
33 size_t M = 1000;
34 double p = 0.05;
35
36 // Test Erdos-Renyi generator
37 {
38 erdos_renyi_iterator< RandomGenerator, Graph > start(gen, N, p);
39 erdos_renyi_iterator< RandomGenerator, Graph > end;
40
41 while (start != end)
42 ++start;
43
44 BOOST_TEST(start == end);
45 }
46
47 {
48 sorted_erdos_renyi_iterator< RandomGenerator, Graph > start(gen, N, p);
49 sorted_erdos_renyi_iterator< RandomGenerator, Graph > end;
50
51 while (start != end)
52 ++start;
53
54 BOOST_TEST(start == end);
55 }
56
57 // Test Small World generator
58 {
59 small_world_iterator< RandomGenerator, Graph > start(gen, N, M, p);
60 small_world_iterator< RandomGenerator, Graph > end;
61
62 while (start != end)
63 ++start;
64
65 BOOST_TEST(start == end);
66 }
67
68 // Test SSCA generator
69 {
70 ssca_iterator< RandomGenerator, Graph > start(gen, N, 5, 0.5, 5, p);
71 ssca_iterator< RandomGenerator, Graph > end;
72
73 while (start != end)
74 ++start;
75
76 BOOST_TEST(start == end);
77 }
78
79 // Test Mesh generator
80 {
81 mesh_iterator< Graph > start(N, N);
82 mesh_iterator< Graph > end;
83
84 while (start != end)
85 ++start;
86
87 BOOST_TEST(start == end);
88 }
89
90 // Test R-MAT generator
91 double a = 0.57, b = 0.19, c = 0.19, d = 0.05;
92
93 {
94 rmat_iterator< RandomGenerator, Graph > start(gen, N, M, a, b, c, d);
95 rmat_iterator< RandomGenerator, Graph > end;
96
97 while (start != end)
98 ++start;
99
100 BOOST_TEST(start == end);
101 }
102
103 {
104 unique_rmat_iterator< RandomGenerator, Graph > start(
105 gen, N, M, a, b, c, d);
106 unique_rmat_iterator< RandomGenerator, Graph > end;
107
108 while (start != end)
109 ++start;
110
111 BOOST_TEST(start == end);
112 }
113
114 {
115 sorted_unique_rmat_iterator< RandomGenerator, Graph > start(
116 gen, N, M, a, b, c, d);
117 sorted_unique_rmat_iterator< RandomGenerator, Graph > end;
118
119 while (start != end)
120 ++start;
121
122 BOOST_TEST(start == end);
123 }
124
125 {
126 sorted_unique_rmat_iterator< RandomGenerator, Graph > start(
127 gen, N, M, a, b, c, d, true);
128 sorted_unique_rmat_iterator< RandomGenerator, Graph > end;
129
130 while (start != end)
131 ++start;
132
133 BOOST_TEST(start == end);
134 }
135
136 return boost::report_errors();
137}
138

source code of boost/libs/graph/test/generator_test.cpp