Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75066 - trunk/libs/graph/test
From: jewillco_at_[hidden]
Date: 2011-10-19 16:03:02


Author: jewillco
Date: 2011-10-19 16:03:00 EDT (Wed, 19 Oct 2011)
New Revision: 75066
URL: http://svn.boost.org/trac/boost/changeset/75066

Log:
Refactored and added test graph from Andre Dau
Text files modified:
   trunk/libs/graph/test/biconnected_components_test.cpp | 49 ++++++++++++++++++++++++++-------------
   1 files changed, 33 insertions(+), 16 deletions(-)

Modified: trunk/libs/graph/test/biconnected_components_test.cpp
==============================================================================
--- trunk/libs/graph/test/biconnected_components_test.cpp (original)
+++ trunk/libs/graph/test/biconnected_components_test.cpp 2011-10-19 16:03:00 EDT (Wed, 19 Oct 2011)
@@ -77,23 +77,11 @@
   } else std::cout << "OK." << std::endl;
 }
 
-int test_main(int argc, char* argv[])
-{
- std::size_t n = 100;
- std::size_t m = 500;
- std::size_t seed = 1;
+typedef adjacency_list<listS, vecS, undirectedS,
+ no_property, EdgeProperty> Graph;
+typedef graph_traits<Graph>::vertex_descriptor Vertex;
 
- if (argc > 1) n = lexical_cast<std::size_t>(argv[1]);
- if (argc > 2) m = lexical_cast<std::size_t>(argv[2]);
- if (argc > 3) seed = lexical_cast<std::size_t>(argv[3]);
-
- typedef adjacency_list<listS, vecS, undirectedS,
- no_property, EdgeProperty> Graph;
- typedef graph_traits<Graph>::vertex_descriptor Vertex;
-
- Graph g(n);
- minstd_rand gen(seed);
- generate_random_graph(g, n, m, gen);
+bool test_graph(Graph& g) { // Returns false on failure
   std::vector<Vertex> art_points;
 
   std::cout << "Computing biconnected components & articulation points... ";
@@ -127,5 +115,34 @@
     out << "}\n";
   }
 
+ return any_errors;
+}
+
+int test_main(int argc, char* argv[])
+{
+ std::size_t n = 100;
+ std::size_t m = 500;
+ std::size_t seed = 1;
+
+ if (argc > 1) n = lexical_cast<std::size_t>(argv[1]);
+ if (argc > 2) m = lexical_cast<std::size_t>(argv[2]);
+ if (argc > 3) seed = lexical_cast<std::size_t>(argv[3]);
+
+ {
+ Graph g(n);
+ minstd_rand gen(seed);
+ generate_random_graph(g, n, m, gen);
+ if (test_graph(g)) return 1;
+ }
+
+ {
+ Graph g(4);
+ add_edge(2, 3, g);
+ add_edge(0, 3, g);
+ add_edge(0, 2, g);
+ add_edge(1, 0, g);
+ if (test_graph(g)) return 1;
+ }
+
   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