我正在尝试理解如何使用boost库构建图形并运行stoer_wagner_min_cut
算法。
到目前为止,我已经使用adjacency_matrix
容器构建了图形。
问题在于如何使stoer_wagner_min_cut
正常工作。我阅读了this文档,并遇到了两个问题:
- "图形类型必须是Vertex List Graph和Incidence Graph的模型。"
WeightMap weights
作为输入。
第一部分是什么意思?adjacency_matrix
是某种类型的"Vertex List Graph和Incidence Graph"吗?有没有示例?
此外,图中所有边的权重都为1。我不明白如何组装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, ..?..);
}
如何定义这个静态属性映射以返回值为1的int值?我有点困扰。 另外,我看到
stoer_wagner_min_cut
的返回值是parity_map
(ParityMap必须是可写属性映射的模型,并且其值类型应该是bool类型)。我对构建和使用这些映射有点困惑,希望能得到一些指导和示例。
谢谢。