开发者

Boost.Graph example 4 dynamic_properties error

开发者 https://www.devze.com 2023-02-25 11:07 出处:网络
Running Boost.Graph example 4 for QT gives flowing error: no match for call to \'(boost::dynamic_properties)(std::bacic_ostream>&,unsigned int)\' graphvic.hpp

Running Boost.Graph example 4 for QT gives flowing error:

no match for call to '(boost::dynamic_properties)(std::bacic_ostream>&,unsigned int)' graphvic.hpp

The error occurs at the following line of the 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;
}

I am unable to find out the reason for the error. Below is the Boost.Graph example 4 code. Please help me.

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>
  > Gr开发者_开发问答aph;

  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();
  }

Thanks, Prakash


You can change write_graphviz to write_graphviz_dp and try again, it should work, however, i have no idea about the story underneath. could someone give some explanations?


there is invalid call for a function get(). The second parameter should be a graph, not a vertex descriptor. Additionaly, you did not specify what is it vertex_id. May be you've meant vertext_name_t?

0

精彩评论

暂无评论...
验证码 换一张
取 消