很抱歉这个新手问题,但我正在努力开始使用 BGL。我正在尝试深度优先搜索:
boost::default_dfs_visitor vis;
boost::depth_first_search( graph, boost::visitor(vis) );
而且我收到了大量有关颜色图的错误消息:
In file included from /usr/include/boost/graph/named_function_params.hpp:22,
from /usr/include/boost/graph/depth_first_search.hpp:21,
from main.cc:6:
/usr/include/boost/property_map/shared_array_property_map.hpp: In member function 'T& boost::shared_array_property_map<T, IndexMap>::operator[](typename boost::property_traits<IndexMap>::key_type) const [with T = boost::default_color_type, IndexMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t>]':
/usr/include/boost/property_map/property_map.hpp:324: instantiated from 'void boost::put(const boost::put_get_helper<Reference, PropertyMap>&, K, const V&) [with PropertyMap = boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >, Reference = boost::default_color_type&, K = void*, V = boost::default_color_type]'
/usr/include/boost/graph/depth_first_search.hpp:196: instantiated from 'void boost::depth_first_search(const VertexListGraph&, DFSVisitor, ColorMap, typename boost::graph_traits<Graph>::vertex_descriptor) [with VertexListGraph = boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, DFSVisitor = boost::dfs_visitor<boost::null_visitor>, ColorMap = boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >]'
/usr/include/boost/graph/depth_first_search.hpp:295: instantiated from 'void boost::depth_first_search(const VertexListGraph&, const boost::bgl_named_params<P, T, R>&) [with VertexListGraph = TreeGraph::graph_type, P = boost::dfs_visitor<boost::null_visitor>, T = boost::graph_visitor_t, R = boost::no_property]'
main.cc:272: instantiated from here
/usr/include/boost/property_map/shared_array_property_map.hpp:36: error: no match for 'operator[]' in '((const boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >*)this)->boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >::data[boost::get [with PropertyMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t>, Reference = const boost::detail::error_property_not_found&, K = void*](((const boost::put_get_helper<const boost::detail::error_property_not_found&, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >&)((const boost::put_get_helper<const boost::detail::error_property_not_found&, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >*)(&((const boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >*)this)->boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, boost::property<boost::vertex_treegraphnode_t, TreeGraph::node, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >::index))), ((void* const&)((void* const*)(& v))))]'
/usr/include/boost/smart_ptr/shared_array.hpp:85: note: candidates are: T& boost::shared_array<T>::operator[](ptrdiff_t) const [with T = boost::default_color_type]
depth_first_search 的文档说有一个默认值,而且我看到许多不提供自己的颜色图的示例,所以我不确定为什么会出现问题。
我的图表类型是:
typedef
boost::adjacency_list<
boost::vecS, boost::listS, boost::directedS,
boost::property<boost::vertex_treegraphnode_t, TreeGraph::node>
>
graph_type;
我想也许是因为我有一个自定义属性图,可能会覆盖 depth_first_search 需要的一些颜色图默认值,但我补充说:
boost::property<boost::vertex_color_t, boost::default_color_type>
到财产清单,这也无济于事。
我尝试使用外部 color_map 进行 depth_first 搜索,但这似乎也没有帮助。
关于我可能做错了什么的任何想法?
谢谢。