Boost logo

Boost Users :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-07-06 22:35:09


On Jul 6, 2005, at 12:23 PM, Todd A. Gibson wrote:
> Among my attempts, here's a typical one that won't compile:
>
> typedef typename std::map<Edge, double> EdgeMap;
> EdgeMap myedges;
> //...
> boost::associative_property_map< EdgeMap > edge_assoc_map(myedges);
> brandes_betweenness_centrality(g, ...
> .edge_centrality_map(edge_assoc_map) ...)
>
> Can someone enlighten me?

I can try :)

The code above fails because edge descriptors can't be ordered via <. A
future version of the BGL might support this operation, but for now...

External edge property maps are typically constructed using an
edge_index_t property. So, if you add property<edge_index_t,
std::size_t> to the edge properties of your GraphType, then keep them
numbered, e.g.:

typename graph_traits<GraphType>::edge_iterator ei, ei_end;
std::size_t index = 0;
for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++index)
   put(edge_index, g, *ei, index);

Then you'll be able to build an external property map from a vector:

std::vector<double> edge_cent(num_edges(g));
brandes_betweenness_centrality(g, ..,
   .edge_centrality_map(make_iterator_property_map(edge_cent.begin(),
get(edge_index, g))...);

        Doug


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