Boost::graph Create external property map for storing edges color

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: boost::dynamic_properties p; p.property("color", MY_MAP); because I would like to write this property to ".dot" file using write_viz() function. Many thanks in advance for any help, Regards, --Dmitry

On Dec 10, 2005, at 10:28 AM, Dmitriy Bufistov wrote:
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
participants (2)
-
Dmitriy Bufistov
-
Douglas Gregor