[boost][graph] write_graphviz problem

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);" so write_graphviz function get the vertex property with the tag of type vertex_id. By default, the type vertex_id is the enum boost::vertex_index which do reference to the type boost::vertex_index_t; This property is intrinsically in the type boost::adjacency_list<vecS, vecS> because the vertex_descriptor is the index of the vertex. And so all work fine with the function write_graphviz With the type boost::adjacency_list<vecS, listS>, this property is not available. TOOOOOO 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 ?? Thank David Callu

On 8/6/07, David Callu <ledocc@gmail.com> 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

2007/8/7, Aaron Windsor <aaron.windsor@gmail.com>:
On 8/6/07, David Callu <ledocc@gmail.com> 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@lists.boost.org 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
participants (2)
-
Aaron Windsor
-
David Callu