Boost logo

Boost Users :

Subject: Re: [Boost-users] Why can't I use boost graph write_graphviz with OutEdgeList=listS and VertexList=listS
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-04-25 17:04:23

On Mon, 25 Apr 2011, Allan Nielsen wrote:

> Hi
>> The write_graphviz function requires a vertex_index map, which is not
>> provided by default by graphs with listS as the vertex container.  You can
>> add that property explicitly to a listS graph, and fill it in before the
>> write_graphviz call (after any changes to the graph vertices).
> Thanks.... But it is not clear to me how to do this (sorry, i'am quite
> new to BGL)
> If I would just like to use the vertes_descriptor pointers as lables,
> what would that look like??

Try something like this (not tested):

#include <boost/lexical_cast.hpp>

struct vertex_desc_node_id_map {
   template <typename T>
   friend std::string get(const vertex_desc_node_id_map&, const T& x) {
     return boost::lexical_cast<std::string>(x);

namespace boost {
   template <>
   struct property_traits<vertex_desc_node_id_map> {
     typedef std::string value_type;
     typedef std::string& reference;
     typedef void key_type;
     typedef readable_property_map_tag category;

and then add '"node_id", vertex_desc_node_id_map());' (where
"dp" is your dynamic_properties object) before calling write_graphviz_dp.

> Do you know about an example I could look at??

No, I don't.

-- Jeremiah Willcock

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at