[BGL] Problem implementing dijkstra

Hello everyone. I've got a small problem when trying to use the dijkstra-shortest-path algorithm. The error reported by the compiler is: 'void put<void*,void*>(T *,ptrdiff_t,const V &)' : cannot convert parameter 2 from 'void *' to 'ptrdiff_t' Can anyone give me a hint what I am missing? Thanks. Thomas. I made up a small example with the compiler error I receive (VS2005)
>>> problem.cpp
#include <boost/graph/adjacency_list.hpp> #include <boost/graph/graph_traits.hpp> #include <boost/graph/dijkstra_shortest_paths.hpp> #include <boost/graph/properties.hpp> #include <vector> //defining vertex properties typedef boost::property<boost::vertex_name_t, std::string> VName; typedef boost::property<boost::vertex_index_t, int, VName> VIndex; typedef boost::property<boost::vertex_index_t, int, VIndex> VertexProperties; //defining edge properties typedef boost::property<boost::edge_weight_t, int> EdgeProperties; typedef boost::adjacency_list <boost::listS, boost::listS, boost::directedS, VertexProperties, EdgeProperties> PespGraph_t; typedef boost::graph_traits < PespGraph_t >::vertex_descriptor Pesp_Vertex; typedef boost::graph_traits < PespGraph_t >::edge_descriptor Pesp_Edge; int main(int argc, char* argv[]) { PespGraph_t g; Pesp_Vertex v1, v2; v1 = boost::add_vertex(g); boost::put(boost::vertex_name, g, v1, "Vertex 1"); boost::put(boost::vertex_index, g, v1, 1); v2 = boost::add_vertex(g); boost::put(boost::vertex_name, g, v2, "Vertex 2"); boost::put(boost::vertex_index, g, v2, 2); Pesp_Edge e; bool inserted; tie(e,inserted) = boost::add_edge(v1, v2, g); boost::put(boost::edge_weight, g, e, 10); std::vector<Pesp_Vertex> pred(boost::num_vertices(g)); std::vector<int> dist(boost::num_vertices(g)); dijkstra_shortest_paths(g, v1, boost::predecessor_map(&pred[0])); return 0; }
>>> compiler output 1>------ Build started: Project: playground, Configuration: Debug Win32
1>Compiling... 1>problem.cpp 1>c:\boost\include\boost-1_33_1\boost\graph\dijkstra_shortest_paths.hpp(251) : error C2664: 'void put<void*,void*>(T *,ptrdiff_t,const V &)' : cannot convert parameter 2 from 'void *' to 'ptrdiff_t' 1> with 1> [ 1> T=void *, 1> V=void * 1> ] 1> There is no context in which this conversion is possible 1> c:\boost\include\boost-1_33_1\boost\graph\dijkstra_shortest_paths.hpp(291) : see reference to function template instantiation 'void boost::dijkstra_shortest_paths<VertexListGraph,boost::dijkstra_visitor<>,void**__w64 ,DistanceMap,WeightMap,IndexMap,std::less<_Ty>,boost::closed_plus<T>,int,int,ColorMap>(const VertexListGraph &,void *,PredecessorMap,DistanceMap,WeightMap,IndexMap,Compare,Combine,DistInf,DistZero,DijkstraVisitor,ColorMap)' being compiled 1> with 1> [ 1> VertexListGraph=PespGraph_t, 1> DistanceMap=boost::iterator_property_map<std::_Vector_iterator<int,std::allocator<int>>,boost::adj_list_vertex_property_map<Graph,int,const int &,boost::vertex_index_t>,int,int &>, 1> WeightMap=boost::adj_list_edge_property_map<boost::directed_tag,int,const int &,void *,const boost::property<boost::edge_weight_t,int>,boost::edge_weight_t>, 1> IndexMap=boost::adj_list_vertex_property_map<Graph,int,const int &,boost::vertex_index_t>, 1> _Ty=D, 1> T=D, 1> ColorMap=boost::iterator_property_map<std::_Vector_iterator<boost::default_color_type,std::allocator<boost::default_color_type>>,boost::adj_list_vertex_property_map<Graph,int,const int &,boost::vertex_index_t>,boost::default_color_type,boost::default_color_type &>, 1> PredecessorMap=void **__w64 , 1> Compare=std::less<D>, 1> Combine=boost::closed_plus<D>, 1> DistInf=int, 1> DistZero=int, 1> DijkstraVisitor=boost::dijkstra_visitor<> 1> ] 1> c:\boost\include\boost-1_33_1\boost\graph\dijkstra_shortest_paths.hpp(321) : see reference to function template instantiation 'void boost::detail::dijkstra_dispatch2<VertexListGraph,boost::iterator_property_map<RandomAccessIterator,IndexMap,T,R>,WeightMap,IndexMap,Params,boost::iterator_property_map<std::_Vector _iterator<_Ty,_Alloc>,IndexMap,boost::default_color_type,boost::default_color_type &>>(const VertexListGraph &,void *,DistanceMap,WeightMap,IndexMap,const Params &,ColorMap)' being compiled 1> with 1> [ 1> VertexListGraph=PespGraph_t, 1> RandomAccessIterator=std::_Vector_iterator<int,std::allocator<int>>, 1> IndexMap=boost::adj_list_vertex_property_map<Graph,int,const int &,boost::vertex_index_t>, 1> T=int, 1> R=int &, 1> WeightMap=boost::adj_list_edge_property_map<boost::directed_tag,int,const int &,void *,const boost::property<boost::edge_weight_t,int>,boost::edge_weight_t>, 1> Params=boost::bgl_named_params<void **__w64 ,boost::vertex_predecessor_t,boost::no_property>, 1> _Ty=boost::default_color_type, 1> _Alloc=std::allocator<boost::default_color_type>, 1> DistanceMap=boost::iterator_property_map<std::_Vector_iterator<int,std::allocator<int>>,boost::adj_list_vertex_property_map<Graph,int,const int &,boost::vertex_index_t>,int,int &>, 1> ColorMap=boost::iterator_property_map<std::_Vector_iterator<boost::default_color_type,std::allocator<boost::default_color_type>>,boost::adj_list_vertex_property_map<Graph,int,const int &,boost::vertex_index_t>,boost::default_color_type,boost::default_color_type &> 1> ] 1> c:\boost\include\boost-1_33_1\boost\graph\dijkstra_shortest_paths.hpp(341) : see reference to function template instantiation 'void boost::detail::dijkstra_dispatch1<VertexListGraph,boost::detail::error_property_not_found,boost::adj_list_edge_property_map<Directed,Value,Ref,Vertex,Property,Tag>,boost::adj_list_vertex_property_map<Graph,ValueType,Reference,boost::vertex_index_t>,boost::bgl_named_params<T,boost::vertex_predecessor_t,Base>,boost::detail::error_property_not_found>(const VertexListGraph &,void *,DistanceMap,WeightMap,IndexMap,const Params &,ColorMap)' being compiled 1> with 1> [ 1> VertexListGraph=PespGraph_t, 1> Directed=boost::directed_tag, 1> Value=int, 1> Ref=const int &, 1> Vertex=void *, 1> Property=const boost::property<boost::edge_weight_t,int>, 1> Tag=boost::edge_weight_t, 1> Graph=Graph, 1> ValueType=int, 1> Reference=const int &, 1> T=void **__w64 , 1> Base=boost::no_property, 1> DistanceMap=boost::detail::error_property_not_found, 1> WeightMap=boost::adj_list_edge_property_map<boost::directed_tag,int,const int &,void *,const boost::property<boost::edge_weight_t,int>,boost::edge_weight_t>, 1> IndexMap=boost::adj_list_vertex_property_map<Graph,int,const int &,boost::vertex_index_t>, 1> Params=boost::bgl_named_params<void **__w64 ,boost::vertex_predecessor_t,boost::no_property>, 1> ColorMap=boost::detail::error_property_not_found 1> ] 1> c:\dokumente und einstellungen\gelzi.mediber\eigene dateien\visual studio 2005\projects\playground\playground.cpp(43) : see reference to function template instantiation 'void boost::dijkstra_shortest_paths<PespGraph_t,void**__w64 ,boost::vertex_predecessor_t,boost::no_property>(const VertexListGraph &,void *,const boost::bgl_named_params<T,Tag,Base> &)' being compiled 1> with 1> [ 1> VertexListGraph=PespGraph_t, 1> T=void **__w64 , 1> Tag=boost::vertex_predecessor_t, 1> Base=boost::no_property 1> ] 1>playground - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
participants (1)
-
Thomas Gelzhaeuser