$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Douglas Gregor (dgregor_at_[hidden])
Date: 2007-06-28 09:00:28
Jonas Gabriel wrote:
> Good afternoon,
>
> Inside a dijkstra visitor I would like to change the edge weights at 
> some point, so in my visitor I'm trying to make a property map called 
> weight :
>
> >    template <class Edge, class Graph>
> >    void examine_edge (Edge e, Graph& g) {
> >        typename property_map<Graph, edge_weight_t>::type weight;
> >        weight=get(edge_weight, g);
The "Graph" you get will actually be a const Graph. So you should 
probably make the parameter to examine_edge a const Graph& and then 
either use the "const_type" of the property map:
   template <class Edge, class Graph>
   void examine_edge (Edge e, const Graph& g) {
       typename property_map<Graph, edge_weight_t>::const_type weight;
       weight=get(edge_weight, g);
Or const_cast away the constness of the Graph, if you need to modify the 
weights:
   template <class Edge, class Graph>
   void examine_edge (Edge e, const Graph& cg) {
       Graph& g = const_cast<Graph&>(cg);
       typename property_map<Graph, edge_weight_t>::type weight;
       weight=get(edge_weight, g);
    - Doug