[英]Iterating through edges with custom defined edge properties of boost::adjacency_list
I'm working on a simulation program which uses boost::adjacency_list to represent a graph. 我正在开发一个使用boost :: adjacency_list表示图形的仿真程序。 The edges have costume designed properties
边缘具有服装设计的属性
struct edge_data{
const float linear_cost, const_cost;
std::queue<*Agent> agents;
edge_data(float lin, float con) : linear_cost(lin),const_cost(con) {}
};
After trying several ways, I haven't found a way to create a property_map which returns the full EdgeData for each edge, or any other way to iterate through and modify edges. 在尝试了几种方法之后,我还没有找到创建为每个边缘返回完整EdgeData的property_map的方法,或以其他方式遍历和修改边缘的方法。 Is it possible, and if so, how?
有可能,如果可以,如何?
You ask the edge bundle from the graph, either 您可以从图中询问边缘束
using the boost::edge_bundle_t
property map: 使用
boost::edge_bundle_t
属性图:
auto pmap = boost::get(boost::edge_bundle, my_graph); edge_data& data = pmap[my_edge_descriptor];
using the convenience accessors: 使用便捷访问器:
edge_data& data = mygraph[my_edge_descriptor];
or using specific property maps for a sub-property: 或将特定的属性映射用于子属性:
auto costmap = boost::get(&edge_data::linear_cost, my_graph); float cost = costmap[my_edge_descriptor];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.