在使用listS作为顶点容器的图形上的astar_search?

时间:2012-12-09 18:11:21

标签: c++ boost graph a-star boost-graph

似乎boost::astar_search不喜欢以boost::listS作为顶点容器的图形。

typedef boost::adjacency_list<
    boost::listS,
    boost::listS,
    boost::undirectedS,
    WaypointNode,
    boost::property<boost::edge_weight_t, float> >
Waypoint;

当我使用boost::vecS时,当我将第二个模板参数更改为boost::listS而拒绝编译时,上面的图形定义正常编译。

我不太确定(因为模板错误消息拒绝被普通人理解)但似乎问题是因为算法由于某种原因需要访问operator[]。如果您使用listS,则不存在。我不确定为什么需要随机访问,因为从概念上你可以看到边缘列表中特定顶点存在哪个邻居。

我可以做些什么让astar_search接受listS

编辑: 这是尝试编译(使用g++)上述代码时的错误消息。请注意,当我将第二个boost::listS更改为boost::vecS

时,它编译得很好

这条线特别有意思,即它似乎抱怨(或缺乏)operator[]

/usr/local/Cellar/boost/1.49.0/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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/include/boost/property_map/property_map.hpp:361:   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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/include/boost/graph/astar_search.hpp:288:   instantiated from 'void boost::astar_search(const VertexListGraph&, typename boost::graph_traits<G>::vertex_descriptor, AStarHeuristic, AStarVisitor, PredecessorMap, CostMap, DistanceMap, WeightMap, VertexIndexMap, ColorMap, CompareFunction, CombineFunction, CostInf, CostZero) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS>, AStarHeuristic = DistanceHeuristic<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS> >, AStarVisitor = WaypointNodeVisitor<void*>, PredecessorMap = boost::dummy_property_map, CostMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, DistanceMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, float, const float&, void*, const boost::property<boost::edge_weight_t, float, boost::no_property>, boost::edge_weight_t>, VertexIndexMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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>, ColorMap = boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, CompareFunction = std::less<float>, CombineFunction = boost::closed_plus<float>, CostInf = float, CostZero = float]'
/usr/local/Cellar/boost/1.49.0/include/boost/graph/astar_search.hpp:330:   instantiated from 'void boost::astar_search(const VertexListGraph&, typename boost::graph_traits<G>::vertex_descriptor, AStarHeuristic, const boost::bgl_named_params<P, T, R>&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS>, AStarHeuristic = DistanceHeuristic<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS> >, P = WaypointNodeVisitor<void*>, T = boost::graph_visitor_t, R = boost::no_property]'
Pathfinding.h:28:   instantiated from here
/usr/local/Cellar/boost/1.49.0/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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/include/boost/smart_ptr/shared_array.hpp:103: note: candidates are: T& boost::shared_array<T>::operator[](ptrdiff_t) const [with T = boost::default_color_type]
/usr/local/Cellar/boost/1.49.0/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 = float, IndexMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/include/boost/property_map/property_map.hpp:361:   instantiated from 'void boost::put(const boost::put_get_helper<Reference, PropertyMap>&, K, const V&) [with PropertyMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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 = float&, K = void*, V = float]'
/usr/local/Cellar/boost/1.49.0/include/boost/graph/astar_search.hpp:289:   instantiated from 'void boost::astar_search(const VertexListGraph&, typename boost::graph_traits<G>::vertex_descriptor, AStarHeuristic, AStarVisitor, PredecessorMap, CostMap, DistanceMap, WeightMap, VertexIndexMap, ColorMap, CompareFunction, CombineFunction, CostInf, CostZero) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS>, AStarHeuristic = DistanceHeuristic<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS> >, AStarVisitor = WaypointNodeVisitor<void*>, PredecessorMap = boost::dummy_property_map, CostMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, DistanceMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, float, const float&, void*, const boost::property<boost::edge_weight_t, float, boost::no_property>, boost::edge_weight_t>, VertexIndexMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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>, ColorMap = boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, CompareFunction = std::less<float>, CombineFunction = boost::closed_plus<float>, CostInf = float, CostZero = float]'
/usr/local/Cellar/boost/1.49.0/include/boost/graph/astar_search.hpp:330:   instantiated from 'void boost::astar_search(const VertexListGraph&, typename boost::graph_traits<G>::vertex_descriptor, AStarHeuristic, const boost::bgl_named_params<P, T, R>&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS>, AStarHeuristic = DistanceHeuristic<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS> >, P = WaypointNodeVisitor<void*>, T = boost::graph_visitor_t, R = boost::no_property]'
Pathfinding.h:28:   instantiated from here
/usr/local/Cellar/boost/1.49.0/include/boost/property_map/shared_array_property_map.hpp:36: error: no match for 'operator[]' in '((const boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/include/boost/smart_ptr/shared_array.hpp:103: note: candidates are: T& boost::shared_array<T>::operator[](ptrdiff_t) const [with T = float]
/usr/local/Cellar/boost/1.49.0/include/boost/property_map/vector_property_map.hpp: In member function 'typename std::iterator_traits<typename std::vector<T, std::allocator<_CharT> >::iterator>::reference boost::vector_property_map<T, IndexMap>::operator[](const typename boost::property_traits<IndexMap>::key_type&) const [with T = long unsigned int, IndexMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/include/boost/property_map/property_map.hpp:361:   instantiated from 'void boost::put(const boost::put_get_helper<Reference, PropertyMap>&, K, const V&) [with PropertyMap = boost::vector_property_map<long unsigned int, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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 = long unsigned int&, K = void*, V = size_t]'
/usr/local/Cellar/boost/1.49.0/include/boost/graph/detail/d_ary_heap.hpp:118:   instantiated from 'void boost::d_ary_heap_indirect<Value, Arity, IndexInHeapPropertyMap, DistanceMap, Compare, Container>::push(const Value&) [with Value = void*, long unsigned int Arity = 4ul, IndexInHeapPropertyMap = boost::vector_property_map<long unsigned int, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, DistanceMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, Compare = std::less<float>, Container = std::vector<void*, std::allocator<void*> >]'
/usr/local/Cellar/boost/1.49.0/include/boost/graph/breadth_first_search.hpp:74:   instantiated from 'void boost::breadth_first_visit(const IncidenceGraph&, typename boost::graph_traits<G>::vertex_descriptor, Buffer&, BFSVisitor, ColorMap) [with IncidenceGraph = boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS>, Buffer = boost::d_ary_heap_indirect<void*, 4ul, boost::vector_property_map<long unsigned int, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, std::less<float>, std::vector<void*, std::allocator<void*> > >, BFSVisitor = boost::detail::astar_bfs_visitor<DistanceHeuristic<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS> >, WaypointNodeVisitor<void*>, boost::d_ary_heap_indirect<void*, 4ul, boost::vector_property_map<long unsigned int, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, std::less<float>, std::vector<void*, std::allocator<void*> > >, boost::dummy_property_map, boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, boost::adj_list_edge_property_map<boost::undirected_tag, float, const float&, void*, const boost::property<boost::edge_weight_t, float, boost::no_property>, boost::edge_weight_t>, boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, boost::closed_plus<float>, std::less<float> >, ColorMap = boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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/local/Cellar/boost/1.49.0/include/boost/graph/astar_search.hpp:260:   instantiated from 'void boost::astar_search_no_init(const VertexListGraph&, typename boost::graph_traits<G>::vertex_descriptor, AStarHeuristic, AStarVisitor, PredecessorMap, CostMap, DistanceMap, WeightMap, ColorMap, VertexIndexMap, CompareFunction, CombineFunction, CostInf, CostZero) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS>, AStarHeuristic = DistanceHeuristic<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, boost::no_property>, boost::no_property, boost::listS> >, AStarVisitor = WaypointNodeVisitor<void*>, PredecessorMap = boost::dummy_property_map, CostMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, DistanceMap = boost::shared_array_property_map<float, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, float, const float&, void*, const boost::property<boost::edge_weight_t, float, boost::no_property>, boost::edge_weight_t>, ColorMap = boost::shared_array_property_map<boost::default_color_type, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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> >, VertexIndexMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, WaypointNode, boost::property<boost::edge_weight_t, float, 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>, CompareFunction = std::less<float>, CombineFunction = boost::closed_plus<float>, CostInf = float, CostZero = float]'

make[2]: *** [build/Debug/GNU-MacOSX/BotManager.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

2 个答案:

答案 0 :(得分:3)

boost::detail::error_property_not_found&, boost::vertex_index_t这是错误的重要部分。默认情况下,只有vecS作为其VertexList的邻接列表具有内部vertex_index属性映射。如果你真的想使用listS(我相信它的唯一优势就是删除顶点更简单)你需要在图形声明中使用boost::property<boost::vertex_index_t, int, WaypointNode>创建一个内部顶点索引属性映射,然后初始化它就像thisthis

typedef boost::adjacency_list<
    boost::listS,
    boost::listS,
    boost::undirectedS,
    boost::property<boost::vertex_index_t, int, WaypointNode>,
    boost::property<boost::edge_weight_t, float> >
Waypoint;
Waypoint waypoint_graph;
...
add_vertex(boost::property<boost::vertex_index_t, int,WaypointNode>(0, waypoint_node_0), graph);
add_vertex(boost::property<boost::vertex_index_t, int,WaypointNode>(1, waypoint_node_1), graph);
...
astar_search(waypoint_graph, start, my_heuristic, boost::visitor(my_visitor));

或者您可以创建外部顶点索引属性映射,像this一样初始化它,然后使用命名参数astar_search调用vertex_index_map

typedef boost::adjacency_list<
    boost::listS,
    boost::listS,
    boost::undirectedS,
    WaypointNode,
    boost::property<boost::edge_weight_t, float> >
Waypoint;
Waypoint waypoint_graph;
...
add_vertex(waypoint_node_0, graph);
add_vertex(waypoint_node_1, graph);
...
typedef map<typename boost::graph_traits<Waypoint>::vertex_descriptor, size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
size_t i=0;
BGL_FORALL_VERTICES(v, waypoint_graph, Waypoing)
{
   put(propmapIndex, v, i++);
}
...
astar_search(waypoint_graph, start, my_heuristic, boost::visitor(my_visitor).vertex_index_map(propmapIndex));

此问题并非astar_search所独有,而且这两种解决方案都可以与Boost.Graph库中的大多数算法一起使用。

答案 1 :(得分:1)

我不是100%肯定,但我认为我之前使用listS测试了astar_search。我替换了以下图形类型的vecS:

boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::property<boost::edge_weight_t, Cost> >

我发现example在使用listS的adjecency_list上执行Dijkstra的最短路径。看看那个。我的例子在评论了许多依赖于向量的东西之后编译,但是它仍然存在predecessor_map和distance_map的问题。该示例使用property_map替换那些。