i'm trying boost::graph header library, still can't add verticles graph.
here how use add_vertex function :
void graphmanager::addtograph(vertexproperties node){ //no error, not need vertex_t v = boost::add_vertex(graph); //compilation error vertex_t v = boost::add_vertex(node, graph); /*...*/ }
my definitions here :
#ifndef graph_definition_h #define graph_definition_h #include <boost/graph/adjacency_list.hpp> #include "matchedword.h" typedef matchedword* vertexproperties; struct edgeproperties { int distance; edgeproperties() : distance(0) {} edgeproperties(int d) : distance(d) {} }; struct graphproperties { }; typedef boost::adjacency_list< boost::vecs, boost::vecs, boost::undirecteds, boost::property<vertexproperties, boost::vertex_bundle_t>, boost::property<edgeproperties, boost::edge_bundle_t>, boost::property<graphproperties, boost::graph_bundle_t> > graph; typedef boost::graph_traits<graph>::vertex_descriptor vertex_t; typedef boost::graph_traits<graph>::edge_descriptor edge_t; #endif // graph_definition_h
any idea ? thanks.
error: no matching function call 'add_vertex(matchedword*&, graph&)' candidates are: [...] template typename config::vertex_descriptor boost::add_vertex(const typename config::vertex_property_type&, boost::adj_list_impl&)
note: template argument deduction/substitution failed:
note: 'graph {aka boost::adjacency_list, boost::property, boost::property >}' is not derived 'boost::adj_list_impl'
i not understand meaning of error output.
it easier use bundled properties.
something this:
// class hold bundled properties vertex // in case, have pointer matchedword object class vertex_props { public: matchedword * pmw; };
define graph type bundled properties
typedef boost::adjacency_list< boost::vecs, boost::vecs, boost::undirecteds, vertex_props, ... > graph_t;
now can add vertex specified bundled properties this
void graphmanager::addtograph(matchedword * node){ graph[ boost::add_vertex(graph) ].pmw = node; ...
Comments
Post a Comment