【发布时间】:2012-11-30 01:38:56
【问题描述】:
我有一个名为“test.dot”的文件,类似于,
graph {
0;
1;
0 -- 1;
}
//EOF
我想使用 boost 图形库读取文件。
#include <boost/graph/graphviz.hpp>
using namespace std;
using namespace boost;
int main(int,char*[])
{
typedef adjacency_list< vecS, vecS, undirectedS, property<vertex_color_t,int> > Graph;
Graph g(0);
dynamic_properties dp;
auto index = get(vertex_color, g);
dp.property("node_id", index);
ifstream fin("test.dot");
read_graphviz(fin, g, dp);
}
但是,在这个源代码中,我必须附加另一个属性(vertex_color_t)来存储“node_id”。 在我的简单示例中,它与“node_index”相同。
有没有办法可以识别它们以节省内存?我不想引入额外的属性。
【问题讨论】:
-
代码中的
node_index在哪里?只是更改node_id属性的名称(请参阅read_graphviz文档以了解如何做到这一点)就足够了吗?
标签: c++ boost boost-graph