小编srk*_*ish的帖子

具有VertexList的Dijkstra最短路径=增强图中的ListS

我对Boost图表很新.我试图调整一个例子来找到使用VertexList = vecS的Dijkstra最短路径算法.我将顶点容器更改为ListS.我了解到,如果我们使用listS,我们必须提供自己的vertex_index才能使算法正常工作.

int main(int, char *[])
{
  typedef float Weight;
  typedef boost::property<boost::edge_weight_t, Weight> WeightProperty;
  typedef boost::property<boost::vertex_name_t, std::string> NameProperty;
  typedef boost::property<boost::vertex_index_t, int> IndexProperty;

  typedef boost::adjacency_list < boost::listS, boost::listS, boost::directedS,
  NameProperty, WeightProperty > Graph;

  typedef boost::graph_traits < Graph >::vertex_descriptor Vertex;
  typedef boost::graph_traits <Graph>::vertex_iterator Viter;

  typedef boost::property_map < Graph, boost::vertex_index_t >::type IndexMap;
  typedef boost::property_map < Graph, boost::vertex_name_t >::type NameMap;

  typedef boost::iterator_property_map < Vertex*, IndexMap, Vertex, Vertex& > PredecessorMap;
  typedef boost::iterator_property_map < Weight*, IndexMap, Weight, Weight& > DistanceMap;

  Graph g;


  Vertex v0 = …
Run Code Online (Sandbox Code Playgroud)

c++ boost graph dijkstra

9
推荐指数
2
解决办法
6443
查看次数

标签 统计

boost ×1

c++ ×1

dijkstra ×1

graph ×1