在自定义图形类型上使用 boost::p ush_relabel 算法
Using boost::push_relabel algorithm on customised graph-type
我的图有以下声明
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;
我构建了一个具有source
和sink
节点的图形(流网络(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
。我宣布rev
为adjacency_list_traits<vecS,vecS,bidirectionalS>::edge_descriptor
.它编译了我认为我生成了一个赛格错误,我认为这是函数逻辑的问题,而不是函数原型的问题。
相关文章:
- 为什么这个运算符<重载函数对 STL 算法不可见?
- 基于ELO的团队匹配算法
- C++选择排序算法中的逻辑错误
- 有没有办法将谓词中的元素偏移量传递给 std 算法?
- C++A*算法并不总是在路径中具有目标节点
- 排序算法c++
- 构建可组合有向图(扫描仪生成器的汤普森构造算法)
- 算法问题:查找从堆栈中弹出的所有序列
- 下面是排序算法O(n)吗
- KMP算法和LPS表构造的运行时间
- 为什么我的排序算法会更改数组值
- 求最大元素位置的分治算法
- 具有非整数边容量的最大流量的Dinic算法
- 到连接组件算法的问题(递归)
- STL算法函数在多个一维容器上的使用
- 读取最后一行代码算法 - c++ 时出现问题
- 括号更改 O(n) 算法
- std::unordered_map 搜索算法是如何实现的?
- 如何实现高效的算法来计算大型数据集的多个不同值?
- 如何在 Mac 上使用 c++17 并行标准库算法?