I am quite new to Boost graph. I am trying to adapt an example for finding Dijkstra Shortest Path algorithm which used VertexList = vecS. I changed the vertex container to L
BGL actually has an example of using dijkstra_shortest_paths
with listS/listS, but it's not linked to from the HTML documentation: http://www.boost.org/doc/libs/release/libs/graph/example/dijkstra-example-listS.cpp
What the error message is trying to tell you (error: no match for ‘operator=’ in ‘index.boost::adj_list_vertex_property_map...ValueType = boost::detail::error_property_not_found...
) is that there is no per-vertex storage for the vertex_index_t
property, which is what adj_list_vertex_property_map
needs. To fix the problem you can either change your Graph
typedef
to include per-vertex storage for the vertex_index_t
property or use an "external" property map such as associative_property_map
.
The dijkstra-example-listS.cpp
example uses the approach of changing the graph typedef
. To use this approach in your code, you could define:
typedef boost::adjacency_list <boost::listS, boost::listS, boost::directedS,
boost::property<boost::vertex_name_t, std::string, boost::property<boost::vertex_index_t, int> >,
boost::property<boost::edge_weight_t, Weight> > Graph;
If somebody is interested in the solution, Creating an associative_property_map as suggested in the previous answer solved the issue:
typedef std::map<vertex_desc, size_t>IndexMap;
IndexMap mapIndex;
boost::associative_property_map<IndexMap> propmapIndex(mapIndex);
//indexing the vertices
int i=0;
BGL_FORALL_VERTICES(v, g, pGraph)
{
boost::put(propmapIndex, v, i++);
}
Then pass this Vertex index map to the dijkstra_shortest_paths() call as a named parameter. PS: BGL_FORALL_VERTICES() is defined in < boost/graph/iteration/iteration_macros.hpp >