int main() {
	int N = 0, M = 0;

	while (cin >> N >> M) {
		int graph[N][maxn];
		for(int i = 0; i < N; ++i){
			for(int j = 0; j < N; ++j){
				graph[i][j] = 0;
			}
		}

		int A = 0, B = 0, C = 0;

		while (M > 0) {
			cin >> A >> B >> C;

			graph[A + 1][B + 1] += C;
			graph[B + 1][A + 1] += C;

			--M;
		}

		Stoer_Wagner sw;
		sw.init(N, graph);
		int minCut = sw.Min_Cut();
		cout << minCut << endl;
	}

	return 0;
}
Example #2
0
bool input(void)
{
    int n;
    if(scanf("%d",&n)==EOF) return false;
    sw.init(n);
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)
            scanf("%d",&sw.G[i][j]);
    return true;
}
Example #3
0
void solve(void)
{
    sw.solve();
    printf("%d\n",sw.ans);
}