Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2006-06-27 09:27:33


On Jun 22, 2006, at 10:55 AM, Thomas Hanne wrote:

> Hi,
>
> I am currently using an adjacency_list for calculating shortest paths
> using BGL. Now I would like to make the edge weights time-dependent
> by calling some own function during the algorithm. Unfortunately,
> I did not really get things working as described in the book "The
> Boost
> Graph Library" with respect to self-defined property maps. (Or
> should I
> use a visitor for that purpose?)

You can create a new property map that calculates weights however you
want, e.g.,

struct my_weight_map {
   typedef /*the edge_descriptor type*/ key_type;
   typedef double value_type;
   typedef value_type reference;
   typedef boost::readable_property_map_tag category;

   // data used by my_weight_map
};

double get(const my_weight_map& m, /* the edge_descriptor type*/ edge) {
   return /* compute weight */;
}

Then, instead of passing "gewichte" to dijkstra_shortest_path, pass
my_weight_map();
        
        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