Boost logo

Boost Users :

From: David Callu (ledocc_at_[hidden])
Date: 2007-08-07 14:55:53


2007/8/7, Aaron Windsor <aaron.windsor_at_[hidden]>:
>
> On 8/6/07, David Callu <ledocc_at_[hidden]> wrote:
> > Hi,
> >
> > I try to write my graph to std::cout with boost::write_graphviz.
> > In the example boost/libs/graph/example/graphviz.cpp,
> > the graph used is a
> > boost::adjacency_list<vecS, vecS, directedS,
> > property<vertex_name_t,
> > std::string>,
> > property<edge_weight_t,
> double> >
> >
> > and all work fine.
> >
> >
> > my graph is a
> >
> > boost::adjacency_list<listS, listS, bidirectedS,
> > property<my_vertex_t,
> my_vertex>,
> > property<my_edge_t, my_edge>,
> > property<my_graph_t, my_graph>
> ,
> > listS >
> >
> > If a do "write_graphviz(std::cout, g);"
> > I have a very big error. (why BGL didn't use boost concept check
> ???)
> > I search in boost code and i found !!!
> > In the file boost/graph/graphviz.hpp line 257 (boost 1.34)
> > "out << get(vertex_id, *i);"
>
> <snip>
>
> >
> > In the complete signature function :
> > void write_graphviz(std::ostream &, const VertexListGraph & g
> > vertexPropertyWrite vpw,
> > EdgePropertyWriter epw,
> > GraphPropertyWriter gpw,
> > VertexID vertex_id);
> >
> >
> > I can give the property_tag to used in the function.
> > But, In opposition to other BGL algorithm which accept an external
> > PropertyMap,
> > this property must be in the graph. And I don't want to add a index
> > property.
> >
> >
> > Question :
> > How to use write_graphviz algorithm with
> boost::adjacency_list<listS,
> > listS> ?
> >
> > Is there a magic boost property tag to use with a
> > boost::adjacency_list<listS, listS>
> > like the boost::vertex_index_t tag and the
> boost::adjacency_list<vecS,
> > vecS>
> >
> > is there another solution ??
>
> Hi David,
>
> write_graphviz takes a parameter "vertex_id", of type "VertexID",
> where VertexID is any type that models the readable property map
> concept. If you don't provide one, the algorithm looks for one by
> calling get(vertex_index, g) - which gets the interior vertex index.
> The vertex_id parameter is an actual property map - it's supposed to
> map each vertex in the graph to a distinct non-negative integer in the
> range [0,1,...,num_vertices(g)). If, as you say, you don't want to add
> an interior property to do this, you need to (1) create an exterior
> property map and pass it as the vertex_id parameter (see
> http://tinyurl.com/yhju58 for more information on how to do this) and
> (2) explicitly pass this vertex index map to the function, instead of
> allowing it to default to the interior index.
>
> Regards,
> Aaron
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Aaron,

     Thanks for the answer.
     I use boost::associative_property_map< MyMap > id_map;
     All work fine.

Best Regards
David Callu



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