2011-04-12 3 views
0

가 흐르는 부여합니다 오류 : (부스트 : dynamic_properties를) '을 호출Boost.Graph 예 4 dynamic_properties QT에 대한 Boost.Graph 예 4 실행 오류

없는 경기 (표준 : bacic_ostream> &, 부호없는 int)를 'graphvic.hpp는

오류는 graphvic.hpp의 다음 줄에서 발생

for(boost::tie(i,end) = vertices(g); i != end; ++i) { 
     out << escape_dot_string(get(vertex_id, *i)); 
     vpw(out, *i); //print vertex attributes 
     out << ";" << std::endl; 
} 

내가 오류의 원인을 찾을 수 없습니다입니다. 아래는 Boost.Graph 예제 4 코드입니다. 도와주세요.

typedef boost::adjacency_list 
    < 
    boost::vecS, 
    boost::vecS, 
    boost::undirectedS, 
    boost::property<boost::vertex_name_t,std::string>, 
    boost::property<boost::edge_weight_t,double>, 
    boost::property<boost::graph_name_t,std::string> 
    > Graph; 

    Graph g; 

    std::vector<std::string> names; 
    names.push_back("Mr_A"); 
    names.push_back("Mrs_B"); 
    names.push_back("Dr_C"); 
    names.push_back("Prof_D"); 

    const Graph::vertex_descriptor v0 = boost::add_vertex(names[0],g); 
    const Graph::vertex_descriptor v1 = boost::add_vertex(names[1],g); 
    const Graph::vertex_descriptor v2 = boost::add_vertex(names[2],g); 
    const Graph::vertex_descriptor v3 = boost::add_vertex(names[3],g); 

    std::vector<double> frequencies; 
    frequencies.push_back(0.9); 
    frequencies.push_back(0.5); 
    frequencies.push_back(0.6); 
    frequencies.push_back(0.1); 

    boost::add_edge(v0,v1,frequencies[0],g); 
    boost::add_edge(v1,v2,frequencies[1],g); 
    boost::add_edge(v2,v3,frequencies[2],g); 
    boost::add_edge(v0,v3,frequencies[3],g); 

    //Writing graph to file 
    { 
    std::ofstream f("test.dot"); 

    boost::dynamic_properties p; 
    p.property("label", boost::get(boost::edge_weight, g)); 
    p.property("weight", boost::get(boost::edge_weight, g)); 
    p.property("node_id", boost::get(boost::vertex_name, g)); 
    boost::write_graphviz(f,g,p); 
    f.close(); 
    } 

덕분에, 프라 카쉬

답변

0

기능 get()에 대한 잘못된 호출이 있습니다. 두 번째 매개 변수는 꼭지점 설명자가 아닌 그래프 여야합니다. Additionaly, 당신은 그것이 무엇인지 지정하지 않았다 vertex_id. 당신은 vertext_name_t을 의미 했습니까?

+0

답장을 보내 주셔서 감사합니다. write_graphviz의 문서를 기반으로 write_graphviz를 호출하는 것이 옳습니다. 문서 도구 : write_graphviz (std :: ostream & out, const VertexAndEdgeListGraph & g, VertexPropertyWriter vpw); \t \t \t 그래서 write_graphviz (f, g, p) 호출이 정확합니다. \t vertex_id에 대해서는 이미 graphvic.hpp에 있습니다. 나는 그 부분을 건드리지 않았다, 나는 단지 그 오류 을 가지고있다. 그리고 graphvic.hpp에서 그 코드에 에러 포인트가있다. –

1

write_graphviz를 write_graphviz_dp로 변경하고 다시 시도해보십시오. 작동해야하지만, 아래의 이야기에 대해서는 잘 모릅니다. 누군가가 설명을 해줄 수 있습니까?