Dijkstra Shortest Path with VertexList = ListS in boost graph

前端 未结 2 628
北恋
北恋 2020-11-30 12:57

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

2条回答
  •  野性不改
    2020-11-30 13:28

    If somebody is interested in the solution, Creating an associative_property_map as suggested in the previous answer solved the issue:

       typedef std::mapIndexMap;
       IndexMap mapIndex;
       boost::associative_property_map 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 >

提交回复
热议问题