简体   繁体   English

使用boost :: adjacency_list的自定义边缘属性遍历边缘

[英]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.

相关问题 从boost :: adjacency_list获取边缘属性(包括相关顶点) - Getting edge properties (including related vertices) from boost::adjacency_list 带有 vecS 的 adjacency_list 上的`boost::edge()` 的运行时复杂度是多少? - What is the runtime complexity of `boost::edge()` on an adjacency_list with vecS? boost :: adjacency_list如何在remove_edge之后保持有效的边缘描述符 - How does boost::adjacency_list keep valid edge descriptors after remove_edge 为什么使用 vecS 作为 OutEdgeList 模板参数的 boost adjacency_list 在遍历时使边无效? - Why does a boost adjacency_list using vecS as OutEdgeList template parameter invalidate edges on traversal? 如何在boost :: adjacency_list中置换节点? - How to permute nodes in a boost::adjacency_list? Boost.Graph:保存和加载带有名称的boost :: adjacency_list - Boost.Graph: saving and loading a boost::adjacency_list with a name 有没有一种简单的方法来找出boost :: adjacency_list是否为空? - Is there a simple way to find out if a boost::adjacency_list is empty? 从boost :: adjacency_list图中删除多个顶点 - Removing multiple vertices from a boost::adjacency_list graph 交换两个 boost::adjacency_list 图,类似于 std::swap - Swapping two boost::adjacency_list graphs, akin to std::swap 提升图adjacency_list,检索节点的父级 - boost graph adjacency_list, retrieving a node's parents
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM