Modifying vertex properties in a Boost::Graph(在 Boost::Graph 中修改顶点属性)
问题描述
我想弄清楚如何使用 boost::graph 来存储一些信息.但是,我想将信息与每个顶点相关联.盯着库的文档揭示了(a)写得很糟糕的文档,或者(b),我显然没有我想象的那么擅长 C++.选择两个.
I am trying to figure out how to use boost::graph to store some information. However, there is information I want tied to each vertex. Staring at the documentation for the library reveals either(a)badly written documentation, or (b), I'm obviously not as good at C++ as I thought. Pick two.
我正在寻找一个简单的使用示例.
I am looking for a simple example use.
推荐答案
捆绑的属性使用起来很简单:
Bundled properties are straightforward to use:
using namespace boost;
struct vertex_info {
std::string whatever;
int othervalue;
std::vector<int> some_values;
};
typedef adjacency_list<vecS, vecS, undirectedS, vertex_info> graph_t;
graph_t g(n);
g[0].whatever = "Vertex 0";
[...]
等等.
另请参阅文档.
另一种非常有用的顶点属性是外部属性.您可以声明适当大小的 std::vectors
并将它们用作属性.
The other type of vertex property that are very useful are external properties. You can declare std::vectors
of the appropriate size and use them as properties.
这篇关于在 Boost::Graph 中修改顶点属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Boost::Graph 中修改顶点属性


基础教程推荐
- 这个宏可以转换成函数吗? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01