Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52216 - trunk/libs/graph/test
From: jewillco_at_[hidden]
Date: 2009-04-06 12:59:39


Author: jewillco
Date: 2009-04-06 12:59:38 EDT (Mon, 06 Apr 2009)
New Revision: 52216
URL: http://svn.boost.org/trac/boost/changeset/52216

Log:
Added generator_test from Nick Edmonds
Added:
   trunk/libs/graph/test/generator_test.cpp (contents, props changed)
Text files modified:
   trunk/libs/graph/test/CMakeLists.txt | 1 +
   trunk/libs/graph/test/Jamfile.v2 | 1 +
   2 files changed, 2 insertions(+), 0 deletions(-)

Modified: trunk/libs/graph/test/CMakeLists.txt
==============================================================================
--- trunk/libs/graph/test/CMakeLists.txt (original)
+++ trunk/libs/graph/test/CMakeLists.txt 2009-04-06 12:59:38 EDT (Mon, 06 Apr 2009)
@@ -18,6 +18,7 @@
 boost_test_run(relaxed_heap_test ARGS 5000 15000)
 boost_test_compile(edge_list_cc)
 boost_test_compile(filtered_graph_cc)
+boost_test_run(generator_test)
 boost_test_run(graph)
 boost_test_compile(graph_concepts)
 boost_test_run(graphviz_test

Modified: trunk/libs/graph/test/Jamfile.v2
==============================================================================
--- trunk/libs/graph/test/Jamfile.v2 (original)
+++ trunk/libs/graph/test/Jamfile.v2 2009-04-06 12:59:38 EDT (Mon, 06 Apr 2009)
@@ -50,6 +50,7 @@
     [ run relaxed_heap_test.cpp : 5000 15000 ]
     [ compile edge_list_cc.cpp ]
     [ compile filtered_graph_cc.cpp ]
+ [ run generator_test.cpp ]
     [ run graph.cpp ]
     [ compile graph_concepts.cpp ]
     [ run graphviz_test.cpp

Added: trunk/libs/graph/test/generator_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/graph/test/generator_test.cpp 2009-04-06 12:59:38 EDT (Mon, 06 Apr 2009)
@@ -0,0 +1,115 @@
+#include <boost/random.hpp>
+#include <boost/test/minimal.hpp>
+
+#include <boost/graph/rmat_graph_generator.hpp>
+#include <boost/graph/small_world_generator.hpp>
+#include <boost/graph/ssca_graph_generator.hpp>
+#include <boost/graph/erdos_renyi_generator.hpp>
+#include <boost/graph/mesh_graph_generator.hpp>
+
+#include <boost/graph/adjacency_list.hpp>
+
+using namespace boost;
+
+int test_main(int argc, char** argv) {
+
+ typedef rand48 RandomGenerator;
+
+ typedef adjacency_list<vecS, vecS, directedS> Graph;
+
+ RandomGenerator gen;
+
+ size_t N = 100;
+ size_t M = 1000;
+ double p = 0.05;
+
+ // Test Erdos-Renyi generator
+ {
+ erdos_renyi_iterator<RandomGenerator, Graph> start(gen, N, p);
+ erdos_renyi_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ {
+ sorted_erdos_renyi_iterator<RandomGenerator, Graph> start(gen, N, p);
+ sorted_erdos_renyi_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ // Test Small World generator
+ {
+ small_world_iterator<RandomGenerator, Graph> start(gen, N, M, p);
+ small_world_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ // Test SSCA generator
+ {
+ ssca_iterator<RandomGenerator, Graph> start(gen, N, 5, 0.5, 5, p);
+ ssca_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ // Test Mesh generator
+ {
+ mesh_iterator<Graph> start(N, N);
+ mesh_iterator<Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ // Test R-MAT generator
+ double a = 0.57, b = 0.19, c = 0.19, d = 0.05;
+
+ {
+ rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d);
+ rmat_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ {
+ unique_rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d);
+ unique_rmat_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ {
+ sorted_unique_rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d);
+ sorted_unique_rmat_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ {
+ sorted_unique_rmat_iterator<RandomGenerator, Graph> start(gen, N, M, a, b, c, d, true);
+ sorted_unique_rmat_iterator<RandomGenerator, Graph> end;
+
+ while (start != end) ++start;
+
+ BOOST_CHECK(start == end);
+ }
+
+ return 0;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk