
Hi, Christian, Seems the error message you have does not indicate to your specialized functions. It is more likely of incorrect BFS call. Does the call of boost::get(vertex_index, g) returns a vertex_index property map? The bundled property maps can be understood from its implementaion, I think. Just take a look: http://svn.boost.org/svn/boost/trunk/boost/graph/properties.hpp #ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES template<typename Graph, typename Descriptor, typename Bundle, typename T> struct bundle_property_map : put_get_helper<T&, bundle_property_map<Graph, Descriptor, Bundle, T> > { typedef Descriptor key_type; typedef T value_type; typedef T& reference; typedef lvalue_property_map_tag category; bundle_property_map() { } bundle_property_map(Graph* g_, T Bundle::* pm_) : g(g_), pm(pm_) {} reference operator[](key_type k) const { return (*g)[k].*pm; } private: Graph* g; T Bundle::* pm; }; //The gr So, 1. bundled_property_map is a propery_map 2. In order to use it like it is your graph class need operator[](Vertex) and operator[](Edge) functions be defined. Assume that each vertex of you graph has associated properties struct edgeinfo_t { //A lot of properties}; then the return type of operator[](Edge) is edgeinfo_t& 3 (just in case). T Bundle::* pm; Is a pointer member to the edge or vertex properties. Variable of this type is not a real pointer. Its value isa shift from the beginning of the structure till the given structure member. It can take values like 0,4, 10 etc. It can be used like this: struct EP { int m; } int EP::* pm = &EP::m; //Set to 0 EP s; std::cout << s.*pm << std::endl; 4. If your graph is not a class at all you can: a) Modify the line : reference operator[](key_type k) const { return (*g)[k].*pm; } as you need. b) Write a simple subscript adapter: struct subscriptAdaptor { typedef nodeinfo_t vertex_bundled; typedef edgeinfo_t edge_bundled; subscriptAdaptor(Graph const &g) : m_g(g) {} edgeinfo_t& operator[](Edge &e) { edgeinfo_t& r = *(edgeinfo_t*)get_data(e); return r; } nodeinfo_t& operator[](Vertex &n) { nodeinfo_t& r = *(nodeinfo_t*)get_data(n); return r; } private: Graph const &m_g; }; and then use it: typedef boost::bundle_property_map<Graph, Edge, edgeinfo_t, int> em_t; or equivalently typedef boost::property_map<Graph, int edgeinfo_t::*>::type em_t; Graph g; subscriptAdaptor sa(g); em_t em(sa, &edgeinfo_t::id); //em is an edge property_map 5. If you edgeinfo_t structure has some functions you can slightly modify the standard bundle_property_map and make it to use pointer to member function instead of pointer to member. (Untested) That is all, in brief. Hope this will help. Dmitry Christiaan Putter wrote:
Hi guys,
Thanks for the clarification Dave, after struggling for for 2 days I wasn't so sure any more. Still not getting it right though.
It seems the basic structure of the BGL interface works on my graph. I can run a bfs with "visitor(default_bfs_visitor())" , and it [snip]
Node* s = _network.getNodes().value(20);
bfs_name_printer vis(); breadth_first_search(_network, s, visitor(vis));
Passing my own visitor causes the whole thing not to compile, with the error message:
*********************************** ***********************************
[a lot of g++ compilation errors]
N:\_devel\_workspace\GWISeo\src\core\solution.cpp:186: instantiated from here N:/_tools/boost_1_35_0/boost/graph/named_function_params.hpp:662: error: invalid conversion from `bfs_name_printer (*)()' to `int'
etc. etc.
*********************************** ***********************************
I'm quite sure their must be something I've left out or done wrong when writing the BGL interface for my graph. If anybody can point me in the right direction I'd be very grateful.
And advice on how to implement the bundle concept in my own graph would be great too.
Have a nice day, Christiaan
2008/7/9 David Abrahams <dave@boostpro.com>: