C++ 用boost库求图的最小割
我试图了解如何用boost库构建图形并运行C++ 用boost库求图的最小割,c++,algorithm,boost,graph,C++,Algorithm,Boost,Graph,我试图了解如何用boost库构建图形并运行stoer\u wagner\u min\u cut算法 到目前为止,我用邻接矩阵容器构建了这个图 问题在于如何使stoer\u wagner\u min\u cut工作。我红了 文档和我遇到了两件事: “图形类型必须是顶点列表图和关联图的模型。” WeightMap权重作为输入 第一部分是什么意思?邻接矩阵是某种类型的“顶点列表图和关联图”吗?有这样的例子吗 此外,图中的所有边的权重均为1。我不知道如何组装WeightMap weights。找不到任何
stoer\u wagner\u min\u cut
算法
到目前为止,我用邻接矩阵
容器构建了这个图
问题在于如何使stoer\u wagner\u min\u cut工作。我红了
文档和我遇到了两件事:
WeightMap权重
作为输入WeightMap weights
。找不到任何例子
编辑:
这就是我能做到的-
#include <boost/graph/adjacency_matrix.hpp>
#include <boost/graph/stoer_wagner_min_cut.hpp>
#include <boost/property_map/property_map.h>
using namespace boost;
typedef adjacency_matrix<undirectedS> UGraph;
void main()
{
static_property_map<UGraph, int>; // im not sure about UGraph
G = buildGraph(); // this function works fine
parity_map = stoer_wagner_min_cut(G, ..?..);
}
#包括
#包括
#包括
使用名称空间boost;
typedef邻接矩阵;
void main()
{
静态属性映射;//我不确定UGraph
G=buildGraph();//此函数工作正常
奇偶性映射=斯托尔瓦格纳最小割(G,…?);
}
如何定义此静态属性映射以返回int值1?我有点纠结于此。
我还看到,stoer\u wagner\u min\u cut
的返回值是ParityMap
(ParityMap必须是可写属性映射的模型,其值类型应该是bool类型)
我在建筑和使用这些地图方面有点困难,我很乐意得到一些指导和例子
谢谢
#include <boost/functional/hash.hpp>
#include <boost/graph/adjacency_matrix.hpp>
#include <boost/graph/stoer_wagner_min_cut.hpp>
#include <boost/property_map/property_map.hpp>
using namespace boost;
typedef adjacency_matrix<undirectedS> UGraph;
UGraph buildGraph() {
UGraph g(10);
// todo
return g;
}
#include <iostream>
int main() {
UGraph g = buildGraph(); // this function works fine
int i = stoer_wagner_min_cut(g, boost::make_static_property_map<UGraph::edge_descriptor>(1));
std::cout << "i: " << i << "\n";
}
#包括
#包括
#包括
#包括
使用名称空间boost;
typedef邻接矩阵;
UGraph buildGraph(){
UGG(10);
//待办事项
返回g;
}
#包括
int main(){
UGraph g=buildGraph();//此函数工作正常
inti=stoer_wagner_min_cut(g,boost::make_static_property_map(1));
std::不能一次问一个问题。如果你想要具体的指导,你需要包含具体的代码。奇偶校验映射不是返回值。它是可选的输出参数。谢谢你的回答,我理解你写的内容,但仍然无法为此编写代码。我添加了一些代码,可能现在它更具体了。谢谢。