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;

上記のグラフ定義は、2番目のテンプレートパラメータをに変更すると正常にコンパイルさboost::vecSれますが、を使用するとコンパイルが拒否されますboost::listS

よくわかりませんが(テンプレートのエラーメッセージは通常の人間には理解されないため)、問題はアルゴリズムがoperator[]何らかの理由でアクセスする必要があるためと思われます。を使用する場合、これは存在しませんlistS。とにかくエッジリストから特定の頂点にどのネイバーが存在するかを概念的に確認できるため、ランダムアクセスが必要な理由はよくわかりません。

astar_search受け入れるために私にできることはありますlistSか?

編集:g++上記のコードを(使用して)コンパイルしようとしたときのエラーメッセージは次のとおりです。boost::listS2番目をに変更したときに正常にコンパイルされることに注意してください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
4

2 に答える 2

3

boost::detail::error_property_not_found&, boost::vertex_index_tそれがエラーの重要な部分です。VertexListとしてvecSを使用する隣接リストのみが、デフォルトで内部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_searchvertex_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でダイクストラの最短経路を実行するを見つけました。それを見てください。私の例は、ベクトルに依存する多くのものをコメントアウトした後にコンパイルされましたが、それでもpredecessor_mapとdistance_mapに問題があります。この例は、property_mapを使用する例を置き換えます。

于 2012-12-09T21:29:00.690 に答える