【发布时间】:2015-04-28 17:49:35
【问题描述】:
我有我的自定义顶点和边属性
namespace boost {
enum vertex_diagonal_t{vertex_diagonal = 999};
BOOST_INSTALL_PROPERTY(vertex, diagonal);
}
namespace boost {
enum edge_dominance_t{edge_dominance = 998};
BOOST_INSTALL_PROPERTY(edge, dominance);
}
我用boost::property创建我的邻接列表
typedef boost::adjacency_list<
boost::listS,
boost::vecS,
boost::bidirectionalS,
boost::property<boost::vertex_diagonal_t, const khut::diagonal*>,
boost::property<boost::edge_dominance_t, float>
> diagonal_dominance_graph;
typedef boost::property_map<diagonal_dominance_graph, boost::vertex_diagonal_t>::type diagonal_map_type;
typedef boost::property_map<diagonal_dominance_graph, boost::edge_dominance_t>::type dominance_map_type;
现在我想遍历我自己的容器并添加顶点
diagonal_dominance_graph graph;
for(storage_type::const_iterator i = repo_begining.begin(); i != repo_begining.end(); ++i){
diagonal_dominance_graph::vertex_descriptor dia_vertex = boost::add_vertex(graph);
//>> ?? HOW CAN I write Properties to dia_vertex HERE ?
//boost::property<boost::vertex_diagonal_t, const khut::diagonal*> p;
//boost::put(p, dia_vertex);
}
我没有得到的是如何通过vertex_descriptor 设置顶点的属性。可能是我缺少一个简单的功能。
请在我的示例中,我不需要任何使 BGL 更加复杂的东西,或者清理和重组类型的东西。我只需要知道如何通过vertex_descriptor 或edge_descriptor 读/写属性
【问题讨论】:
标签: c++ boost graph boost-graph