Boost logo

Boost Users :

From: James Jackson (james.jackson_at_[hidden])
Date: 2008-01-24 05:47:12


Hi,

I am trying to use the BGL to model a simple directed graph with
internal edge properties. Following the example given in the
documentation[1], I have done the following (with question-irrelevant
padding removed):

-------------------------------
#include <boost/graph/adjacency_list.hpp>
#include <boost/property_map.hpp>

typedef boost::property<boost::edge_weight_t, double> EdgeProperties;
typedef boost::adjacency_list<boost::vecS, boost::vecS,
boost::directedS, boost::no_property, EdgeProperties> NetworkGraph;
typedef std::pair<int, int> Edge;

NetworkGraph g(5);
boost::add_edge(0, 1, g);
boost::add_edge(0, 2, g);
boost::add_edge(1, 3, g);
boost::add_edge(2, 3, g);
boost::add_edge(3, 4, g);

boost::property_map<NetworkGraph, boost::edge_weight_t>::type weights
= boost::get(boost::edge_weight_t(), g);
weights[0] = 1.0;
weights[1] = 1.0;
weights[2] = 1.0;
weights[3] = 1.0;
weights[4] = 1.0;
-------------------------------

Which all looks fairly kosher. However, attempting to compile this
results in a error on each of the weights assignment lines:

"error: no match for 'operator[]' in 'weights[0]'

Using the syntax boost::put(weights, 0, 1.0) just moves this error
inside a parameter_set template definition. Can anybody shed any light
on this? For the record this is on MacOS X 10.5.1, with GCC 4.0.1
(i686-apple-darwin9-gcc-4.0.1).

Regards,
James Jackson.

[1] interior_property_map.cpp


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net