Search code examples
c++boostgrapha-starboost-graph

astar_search on a graph with listS as the vertex container?


It seems that boost::astar_search doesn't like graphs with boost::listS as the vertex container.

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

The graph definition above compiles normally when I changed the second template parameter into boost::vecS while it refuses to compile when I use boost::listS.

I'm not really sure (since template error messages refuse to be understood by normal human beings) but it seems the problem is because the algorithm needs access to operator[] for some reason. Which doesn't exist if you do use listS. I'm not really sure why random access is required since conceptually you can see which neighbor exist for a particular vertex from the edge list anyway.

Is there anything I can do to make astar_search accepts listS?

EDIT: here's the error message when trying to compile (using g++) the above code. Mind you that it compiles fine when I changed the second boost::listS into boost::vecS

this line is interesting in particular i.e. it seems to complain about (or lack thereof) 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>]'

this is the complete (and unwieldy) error messages:

/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

Solution

  • boost::detail::error_property_not_found&, boost::vertex_index_t that's the important part of the error. Only adjacency lists with vecS as their VertexList have an internal vertex_index property map by default. If you really want to use a listS (I believe the only advantage it has is that the removal of vertices is simpler) you need to either create an internal vertex index property map by using boost::property<boost::vertex_index_t, int, WaypointNode> in your graph declaration and then initialize it like this or this:

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

    or you can create an external vertex index property map, initalize it like this and then invoke astar_search with the named parameter 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));
    

    This problem is not exclusive to astar_search and both of these solutions can be used with most algorithms in the Boost.Graph library.