question on property tags and bundled properties.

Hi, I am attempting use bundled properties for my graph processing. My attempt to 'write_graphviz' fails because of a lack of an vertex_index as an internal property. But how does one specify this? Named params do not seem to be an option. Being new to the template meta programming game, I am having some trouble figuring out how to make this work. Code snippet below is the simplest that would reproduce my problem. Thanks in advance for any clues/hints on how to proceed. -sr #include <boost/graph/adjacency_list.hpp> #include <boost/graph/topological_sort.hpp> #include <boost/graph/graphviz.hpp> using namespace boost; using namespace std; class A { public: // dummy class }; typedef struct VertexProperties { A* a; std::size_t index; boost::default_color_type color; } VertexProperties; typedef struct EdgeProperties { A* a; } EdgeProperties; int main(void) { typedef adjacency_list<vecS, listS, directedS, VertexProperties, EdgeProperties> Graph; Graph g(3); property_map<Graph, std::size_t VertexProperties::*>::type id = get(&VertexProperties::index, g); property_map<Graph, boost::default_color_type VertexProperties::*>::type color = get(&VertexProperties::color, g); boost::graph_traits<Graph>::vertex_iterator vi, viend; int vnum = 0; for (boost::tie(vi,viend) = vertices(g); vi != viend; ++vi) { id[*vi] = vnum++; } add_edge(vertex(0, g), vertex(1, g), g); add_edge(vertex(2, g), vertex(1, g), g); typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor; std::vector< vertex_descriptor > c; // Just check to ensure that all is ok. topological_sort(g, std::back_inserter(c), color_map(color). vertex_index_map(id)); // See error below... property_map<Graph, vertex_index_t>::const_type ver_idx = get(vertex_index_t(),g); remove_edge(vertex(0, g), vertex(1, g), g); remove_edge(vertex(2, g), vertex(1, g), g); return 0; }; // ------------- C:\test>cl /EHsc /IC:\CheckMate\boost\boost_1_32_0 btest.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50215.44 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. btest.cpp btest.cpp(53) : error C2440: 'initializing' : cannot convert from 'boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>' to 'boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>' with [ Graph=Graph, ValueType=boost::detail::error_property_not_found, Reference=boost::detail::error_property_not_found &, Tag=boost::vertex_index_t ] and [ Graph=Graph, ValueType=boost::detail::error_property_not_found, Reference=const boost::detail::error_property_not_found &, Tag=boost::vertex_index_t ] No constructor could take the source type, or constructor overload resolution was ambiguous

On Jul 13, 2005, at 9:01 AM, sr kumar wrote:
I am attempting use bundled properties for my graph processing. My attempt to 'write_graphviz' fails because of a lack of an vertex_index as an internal property.
But how does one specify this? Named params do not seem to be an option. Being new to the template meta programming game, I am having some trouble figuring out how to make this work.
We've fixed write_graphviz so that it takes an (optional) index_map. This change will be in the upcoming Boost 1.33.0.
#include <boost/graph/adjacency_list.hpp> #include <boost/graph/topological_sort.hpp> #include <boost/graph/graphviz.hpp>
using namespace boost; using namespace std;
class A { public: // dummy class };
typedef struct VertexProperties { A* a; std::size_t index; boost::default_color_type color; } VertexProperties;
typedef struct EdgeProperties { A* a; } EdgeProperties;
int main(void) {
typedef adjacency_list<vecS, listS, directedS, VertexProperties, EdgeProperties> Graph;
If you need a quick fix (other than getting Boost from CVS), you can actually mix bundled properties with non-bundled properties. For instance, if you remove the "index" member from VertexProperties you can then do this: typedef adjacency_list<vecS, listS, directedS, property<vertex_index_t, std::size_t, VertexProperties>, EdgeProperties> Graph; I hope it helps! Doug
participants (2)
-
Doug Gregor
-
sr kumar