在自定义图形类型上使用 boost::p ush_relabel 算法

Using boost::push_relabel algorithm on customised graph-type

本文关键字:ush 算法 relabel boost 图形 自定义 类型      更新时间:2023-10-16

我的图有以下声明

struct vertex_info 
{
  std::string name;
  std::string label;    
  unsigned int type;
  bool isND; 
};
struct edge_info 
{
  std::string name;
  long capacity;
  long residualCapacity;
  long rev;
};
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS
  , vertex_info, edge_info > expr_graph_t;

我构建了一个具有sourcesink节点的图形(流网络(flowG。现在我想使用提升图库中给出push_relabel方法计算最大流量。我调用该函数如下.

  push_relabel_max_flow(flowG, source, sink
      , get(&edge_info::capacity, flowG)
      , get(&edge_info::residualCapacity, flowG)
      , get(&edge_info::rev, flowG)
      , get(boost::vertex_index, flowG)
      );

编译器 (g++( 正在生成长错误消息(粘贴在此处(。我怀疑我无法将正确类型的映射传递给函数。函数签名在 boost-doc 中可用。

文档中给出了许多示例,但他们使用的图表与我的图表不同。我不能更改图形声明,否则很多代码会损坏。我不习惯提升property_map概念。

此解决方案是由于 llonesmiz。

问题是reverse_edge_map需要一个属性映射,其中 key_type= edge_descriptor 和 value_type= edge_descriptor 而我使用的那个有 value_type= long 。我宣布revadjacency_list_traits<vecS,vecS,bidirectionalS>::edge_descriptor.它编译了我认为我生成了一个赛格错误,我认为这是函数逻辑的问题,而不是函数原型的问题。