这个
following
代码(代码段1)编译良好:
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
#include <boost/graph/graph_utility.hpp>
using namespace boost;
typedef adjacency_list_traits<vecS, vecS, directedS> Traits_vvd;
typedef adjacency_list_traits<vecS, vecS, undirectedS> Traits_vvu;
typedef adjacency_list<
vecS, vecS, directedS,
property<
vertex_index_t, int,
property<vertex_color_t, boost::default_color_type,
property<vertex_distance_t, double,
property<vertex_predecessor_t, Traits_vvd::edge_descriptor>
> > >,
property<
edge_index_t, int,
property<edge_capacity_t, double,
property<edge_weight_t, double,
property<edge_residual_capacity_t, double,
property<edge_reverse_t, Traits_vvd::edge_descriptor>
> > > > >
Graph_vvd;
class MAXFLOW_ {
public:
double solve_max_flow(int s, int t){
double retval = boykov_kolmogorov_max_flow(g, s, t);
return retval;
}
private:
Graph_vvd g;
};
int main(){
return 0;
}
但是,在移除时
vertex_distance_t
和
vertex_predecessor_t
从图表中,我们有
this
未能编译的代码(代码段2):
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
#include <boost/graph/graph_utility.hpp>
using namespace boost;
typedef adjacency_list_traits<vecS, vecS, directedS> Traits_vvd;
typedef adjacency_list_traits<vecS, vecS, undirectedS> Traits_vvu;
typedef adjacency_list<
vecS, vecS, directedS,
property<
vertex_index_t, int,
property<vertex_color_t, boost::default_color_type
> >,
property<
edge_index_t, int,
property<edge_capacity_t, double,
property<edge_weight_t, double,
property<edge_residual_capacity_t, double,
property<edge_reverse_t, Traits_vvd::edge_descriptor>
> > > > >
Graph_vvd;
class MAXFLOW_ {
public:
double solve_max_flow(int s, int t){
double retval = boykov_kolmogorov_max_flow(g, s, t);
return retval;
}
private:
Graph_vvd g;
};
int main(){
return 0;
}
代码段1和代码段2之间的唯一区别是,在第二个代码段中,没有与相关的顶点属性
顶点_距离_t
和
顶点_前置器_t
.
我的问题是:
(1) 编译错误
here
是我无法理解的。有没有办法开始理解这些错误,然后找出一个遗漏了指定算法正确运行所需的属性,在这种情况下,使用boykov_kolmogorov方法找到最大流量的算法?
(2) 通过boost文档中提供的此算法的代码示例
here
,实际上顶点具有所需的属性:
property < vertex_name_t, std::string,
property < vertex_index_t, long,
property < vertex_color_t, boost::default_color_type,
property < vertex_distance_t, long,
property < vertex_predecessor_t, Traits::edge_descriptor > > > > >,
但此代码也有一些不必要的属性,例如
vertex_name_t
没有它,Snippet 1编译得很好。有没有办法找出最基本的属性集来指定boost算法的正确运行?