|
Boost : |
From: hankel_o_fung_at_[hidden]
Date: 2001-09-04 16:27:43
The VC namespace bug "abs is not a member of std" showed up
when I tried the following johnson all-pairs shortest path test.
I am using VC 6.0 SP5 + boost.graph 1.22.0. Any way to get around
the problem?
Cheers,
Hankel
#include <boost/graph/johnson_all_pairs_shortest.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <limits>
#include <iostream>
//#define USE_AN_EARLIER_VERSION
int main()
{
using namespace std;
using namespace boost;
#ifdef USE_AN_EARLIER_VERSION
// boost.graph 1.21.1 or earlier versions
typedef adjacency_list<vecS, vecS, directedS, no_property,
property<edge_weight_t, int> > TMP_GRAPH;
#else
// boost.graph 1.21.2 or later versions???
typedef adjacency_list<vecS, vecS, directedS, no_property,
property<edge_weight_t, int,
property<edge_weight2_t, int> > > TMP_GRAPH;
#endif
int const infinity = numeric_limits<int>::max();
int const N(4);
TMP_GRAPH tmp(N);
vector<vector<int> > distance(N, vector<int>(N, infinity));
property_map<TMP_GRAPH, edge_weight_t>::type w
= get(edge_weight, tmp);
vector<int> d(N, infinity);
vector<int> h(N);
vector<default_color_type> c(N);
add_edge(0,1,tmp);
add_edge(1,0,tmp);
add_edge(0,2,tmp);
add_edge(3,1,tmp);
// 0 <-> 1
//
// | ^
// v |
//
// 2 3
TMP_GRAPH::edge_iterator ei, eend;
for (tie(ei,eend) = edges(tmp); ei != eend; ++ei)
put(edge_weight, tmp, *ei, 1);
#ifdef USE_AN_EARLIER_VERSION
// boost.graph 1.21.1 or earlier versions
johnson_all_pairs_shortest_paths
(tmp, distance, d.begin(), h.begin(), w, c.begin(),
get(vertex_index, tmp));
#else
// boost.graph 1.21.2 or later versions???
johnson_all_pairs_shortest_paths
(tmp, distance, distance_map(d.begin()));
#endif
for (int i=0; i<N; ++i)
{
for (int j=0; j<N; ++j)
cout << distance[i][j] << ' ';
cout << endl;
}
cout << endl;
return 0;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk