3

似乎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::listSboost::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
4

2 回答 2

3

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

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));

或者您可以创建一个外部顶点索引属性映射,像这样初始化它,然后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 库中的大多数算法一起使用。

于 2012-12-10T06:12:52.260 回答
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> >

我在使用 listS 的 adjecency_list 上找到了一个执行 Dijkstra 最短路径的示例看看那个。我的示例是在注释掉了很多依赖于向量的东西之后编译的,但是它仍然存在前任地图和距离地图的问题。该示例替换了那些使用 property_map 的示例。

于 2012-12-09T21:29:00.690 回答