-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexampleGC.cpp
More file actions
38 lines (34 loc) · 991 Bytes
/
exampleGC.cpp
File metadata and controls
38 lines (34 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include "maxflow/graph.h"
using namespace std;
// Use the library to compute a minimum cut on the following graph:
//
// SOURCE
// / \
// 1/ \6
// / 4 \
// node0 -----> node1
// | <----- |
// | 3 |
// \ /
// 5\ /1
// \ /
// SINK
void testGCuts() {
Graph<int,int,int> g(2, 1); // estimated # of nodes/edges
g.add_node(2);
g.add_tweights( 0, /* capacities */ 1, 5 );
g.add_tweights( 1, /* capacities */ 6, 1 );
g.add_edge( 0, 1, /* capacities */ 4, 3 );
int flow = g.maxflow();
cout << "Flow = " << flow << endl;
for (int i=0;i<2;i++)
if (g.what_segment(i) == Graph<int,int,int>::SOURCE)
cout << i << " is in the SOURCE set" << endl;
else
cout << i << " is in the SINK set" << endl;
}
int main() {
testGCuts();
return 0;
}