c + + Boost图库 - Dijkstra算法为例 [英] C++ Boost Graph Library - Dijkstra Example

查看:169
本文介绍了c + + Boost图库 - Dijkstra算法为例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,从的 Boost图库Dijkstra算法例如。我改变它,使我的版本不使用枚举和信,而只是整数。它抱怨for循环和连接的功能,以及除了第一其他领带呼叫。

I am having some problems with the code from boost graph library Dijkstra example. I changed it so that my version doesn't use enums and Letter rather just integers. It complains about the for loop and the tie function, as well as other tie calls except for the first.

Declerations:

Declerations:

  typedef std::pair<int, int> Edge;

  const int num_edges = num_edge;
  Edge edge_array[num_edges];
  int weights[num_edges];

  int size = 0;
  for(itora = edges.begin(); itora != edges.end(); ++itora){
    int u = *itora;
    ++itora;
    int v = *itora;
    ++itora;

    weights[size] = *itora;
    edge_array[size] = Edge(u,v);

    size++;
  }


  graph_traits<graph_t>::vertex_iterator i, iend;
  #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
  graph_t g(vertices.size());
  property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g); 

  std::vector<vertex_descriptor> msvc_vertices;
  for (boost::tie(i, iend) = vertices(g); i != iend; ++i){
    msvc_vertices.push_back(*i);
  }

  for (std::size_t j = 0; j < num_edges; ++j) {
    edge_descriptor e; bool inserted;
    boost::tie(e, inserted) = add_edge(msvc_vertices[edge_array[j].first], 
                                       msvc_vertices[edge_array[j].second], g); 
    weightmap[e] = weights[j];
  }

不破:

for (boost::tie(i, iend) = vertices(g); i != iend; ++i){
  msvc_vertices.push_back(*i);
}

这部分减免:

graph_traits<graph_t>::vertex_iterator xi, xiend;
for (boost::tie(xi, xiend) = vertices(g); xi != xiend; ++xi) {
  indexmap[*xi] = c;
  name[*xi] = '0' + c;
  c++;
}

以下是错误:

x.cc: In function 'int main(int, char**)':
x.cc:141: error: no match for call to '(std::vector<int, std::allocator<int> >) (main(int, char**)::graph_t&)'
gmake: *** [x.o] Error 1

任何帮助将大大AP preciated,我真的不知道是什么错误是抱怨...

Any help would be greatly appreciated, I don't really know what the error is complaining about...

推荐答案

你创建一个局部变量的std ::矢量&lt;&INT GT;顶点某处未加引号code?

Did you create a local variable std::vector<int> vertices somewhere in the unquoted code?

这篇关于c + + Boost图库 - Dijkstra算法为例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆