提振.图例4 dynamic_properties错误
Boost.Graph example 4 dynamic_properties error
正在运行Boost。图例4给出了QT的流动错误:
不匹配调用'(boost::dynamic_properties)(std::bacic_ostream>&,unsigned 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。图例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();
}
谢谢,普拉卡什
您可以将write_graphviz更改为write_graphviz_dp并再试一次,它应该可以工作,但是,我不知道下面的故事。有人能解释一下吗?
函数get()
的调用无效。第二个参数应该是一个图,而不是一个顶点描述符。另外,您没有指定它是什么vertex_id
。也许你指的是vertext_name_t
?
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'