2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-30 07:52:10 +00:00

Whackin' a few buglets

[SVN r24451]
This commit is contained in:
Douglas Gregor
2004-08-13 02:53:11 +00:00
parent e0356c30ca
commit 83ed711d3c
2 changed files with 11 additions and 8 deletions

View File

@@ -16,6 +16,7 @@
#include <iterator>
#include <vector>
#include <limits>
#include <cmath>
namespace boost {
namespace detail { namespace graph {
@@ -103,6 +104,8 @@ namespace boost {
deriv_type
compute_partial_derivative(vertex_descriptor m, vertex_descriptor i)
{
using std::sqrt;
deriv_type result(0, 0);
if (i != m) {
weight_type x_diff = position[m].x - position[i].x;
@@ -140,6 +143,8 @@ namespace boost {
// The actual Kamada-Kawai spring layout algorithm implementation
bool run()
{
using std::sqrt;
// Compute d_{ij} and place it in the distance matrix
if (!johnson_all_pairs_shortest_paths(g, distance, index, weight,
weight_type(0)))

View File

@@ -6,8 +6,8 @@
#include <queue>
#include <boost/property_map.hpp>
#include <boost/test/minimal.hpp>
#include <stdlib.h>
#include <math.h>
#include <boost/random/uniform_01.hpp>
#include <boost/random/linear_congruential.hpp>
using namespace boost;
@@ -219,6 +219,9 @@ void randomly_add_edges(MutableGraph& g, double edge_probability)
const bool is_undirected =
is_same<directed_category, undirected_tag>::value;
minstd_rand gen;
uniform_01<minstd_rand, double> rand_gen(gen);
typedef typename graph_traits<MutableGraph>::vertex_descriptor vertex;
typename graph_traits<MutableGraph>::vertex_iterator vi, vi_end;
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
@@ -228,7 +231,7 @@ void randomly_add_edges(MutableGraph& g, double edge_probability)
while (wi != vi_end) {
vertex w = *wi++;
if (v != w) {
if (drand48() < edge_probability) add_edge(v, w, g);
if (rand_gen() < edge_probability) add_edge(v, w, g);
}
}
}
@@ -459,11 +462,6 @@ int test_main(int, char*[])
run_wheel_test((Graph*)0, 15);
long seed = time(0);
std::cout << "Random seed = " << seed << std::endl;
srand48(seed);
random_unweighted_test((Graph*)0, 500);
return 0;