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 中修改顶点属性
基础教程推荐
- 提升 ASIO 流缓冲 2021-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- c++ STL设置差异 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
