2
boost graph library Dijkstra example 코드의 일부 문제가 있습니다. 내 버전이 enum과 Letter를 사용하지 않도록 정수로 변경했습니다. 그것은 for 루프와 tie 함수뿐만 아니라 첫 번째 호출을 제외한 다른 tie 호출에 대해서 불평합니다.C++ 부스트 그래프 라이브러리 - Dijkstra 예제
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);
}
이 부분 나누기 :
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
: 여기
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++;
}
오류입니다
어떤 도움을 주시면 감사하겠습니다.
vertices는 가져온 라이브러리의 일부이며, std :: pair –
Jim
다른 점은 알고 계십니까? – Jim
@ 짐 : 나는 내 원래 추측을 고수한다. 따옴표로 묶인 코드를 변경 한 것처럼 보입니다. 이제는 제 이론을지지하는듯한'vertices.size()'를 보았습니다. 클래스'std :: vector'가'operator()'를 구현하지 않는 변수'vertices'로 함수'vertices()'를 숨 깁니다. 이것은 오류가 말하는 것입니다. –