我的算法的一部分需要计算具有整数容量的网络中的最大流量。我想使用 boost::edmonds_karp_max_flow 算法来找到最大流量。
我尝试阅读文档,但这对我来说非常困难,因为我以前从未使用过 BGL。我创建了如下图,其中Edge
必须将权重属性用作图中边的容量。
struct Vertex{
int id;
bool flag;
};
struct Edge{
int weight;
};
typedef boost::adjacency_list<
boost::listS,
boost::vecS,
boost::undirectedS,
Vertex,
Edge
>MyGraph;
我的目标是编写以下函数
int max_flow( const MyGraph& gr, int u, int v) {
// compute the maximum flow between vertices with ids u,v
}
有人可以用一个例子告诉我如何实现这个功能吗?