修改顶点属性在一个boost ::图 [英] Modifying vertex properties in a Boost::Graph

查看:205
本文介绍了修改顶点属性在一个boost ::图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何使用boost ::图形存储一些信息。但是,我想绑在每个顶点的信息。在该库的文档盯着揭示是(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.

推荐答案

有关使用捆绑的性质是什么?

What about using bundled properties?

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";

[...]

和等。

我用BGL了很多,捆绑性质的工作实在是简单(的看到文档)。

I use BGL a lot and working with bundled properties is really straightforward (see the docs).

其他类型的顶点属性的,我使用非常频繁的外部属性。你可以声明的std ::矢量适当的大小,并把它们作为大部分的时间和大部分的算法性能。

The other type of vertex property that I use very often are external properties. You can declare std::vectors of the appropriate size and use them as properties most of the times and in most of the algorithms.

这篇关于修改顶点属性在一个boost ::图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆