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