I am trying to use Boost's graph algorithms (djikstra, bfs etc) and I want the edge weights to be one by default, without having to set them every time I add edges. Is that possible?
Asked
Active
Viewed 124 times
1 Answers
1
Use a weigh_map of static_property_map
:
This property map wraps a copy of some particular object, and returns a copy of that object whenever a key object is input.
template <typename KeyType, typename ValueType> static_property_map<KeyType, ValueType> make_static_property_map(const ValueType& value);
So boost::make_static_property_map(1)
would be enough to use as weight
map argument to either of those algorithms.
In case you want default values, with possible exceptions, use e.g. function_property_map
to do the evaluation.

sehe
- 374,641
- 47
- 450
- 633