|
Boost : |
From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2006-02-19 06:59:49
The following patch resolves some infinite loops that kill regression
tests.
Graph library is not supported on Borland compilers, so the following
patch is mostly useful to:
i/ people running regular regressions on this compiler
ii/ someone trying to get a working port of graph library on Borland
I am holding back other partial-fixes to boost-graph until I can show a
reasonably large subset of the the library passing the tests. This one
is a bit of a killer though:
cvs diff -u -wb -- graph\random.hpp (in directory
E:\sourceforge\devel\boost\boost\)
Index: graph/random.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/graph/random.hpp,v
retrieving revision 1.5
diff -u -w -b -r1.5 random.hpp
--- graph/random.hpp 24 Mar 2005 15:06:44 -0000 1.5
+++ graph/random.hpp 19 Feb 2006 11:50:46 -0000
@@ -32,9 +32,13 @@
random_vertex(Graph& g, RandomNumGen& gen)
{
if (num_vertices(g) > 1) {
+ #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581))
+ std::size_t n = std::random( num_vertices(g) );
+ #else
uniform_int<> distrib(0, num_vertices(g)-1);
variate_generator<RandomNumGen&, uniform_int<> > rand_gen(gen,
distrib);
std::size_t n = rand_gen();
+ #endif
typename graph_traits<Graph>::vertex_iterator
i = vertices(g).first;
while (n-- > 0) ++i; // std::advance not VC++ portable
@@ -47,10 +51,15 @@
typename graph_traits<Graph>::edge_descriptor
random_edge(Graph& g, RandomNumGen& gen) {
if (num_edges(g) > 1) {
+ #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581))
+ typename graph_traits<Graph>::edges_size_type
+ n = std::random( num_edges(g) );
+ #else
uniform_int<> distrib(0, num_edges(g)-1);
variate_generator<RandomNumGen&, uniform_int<> > rand_gen(gen,
distrib);
typename graph_traits<Graph>::edges_size_type
n = rand_gen();
+ #endif
typename graph_traits<Graph>::edge_iterator
i = edges(g).first;
while (n-- > 0) ++i; // std::advance not VC++ portable
I still need to investigate why boost::random is not working correctly,
but in practice the random number generators used here produce an
endless stream of zeros, which sends the 'find me another vertex' logic
into an infinte loop.
-- AlisdairM
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk