|
Boost Users : |
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-12-12 10:13:21
On Dec 10, 2005, at 10:28 AM, Dmitriy Bufistov wrote:
> Hello everybody,
> I have desperated to find solution to my, I believe, simple problem
> which is in the following:
> construct "external" property map for storing edges color, this map
> should be suitable for such usage:
It's a problem that is, unfortunately, too hard to solve. We're
working to make this easier in the next release of the BGL. If you're
not overly concerned about performance, you can build a
std::map<edge_descriptor, data-type, Compare> data;
Then, to turn it into a property map and attach it to
dynamic_properties, use:
boost::dynamic_properties p;
p.property("color", make_assoc_property_map(data));
So, what's Compare? If your graph has no parallel edges, you can
order based on the source and target of the two edges, e.g.,
source(u, g) < source(v, g) || (source, u, g) == source(v, g) &&
target(u, g) < target(v, g))
Alternatively, if you're using adjacency_list you can use this little
hack:
struct edge_less_than
: public std::binary_function<edge_descriptor,edge_descriptor,
bool> {
bool operator()(const edge_descriptor& __x, const
edge_descriptor& __y) const
{
return __x.second.get_property() < __y.second.get_property();
}
};
There's a bit more information here:
http://article.gmane.org/gmane.comp.lib.boost.user/6984
http://article.gmane.org/gmane.comp.lib.boost.user/6988
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