3 #include "test_tools.h"
4 #include <lemon/smart_graph.h>
5 #include <lemon/lgf_reader.h>
6 #include <lemon/gomory_hu.h>
10 using namespace lemon;
12 typedef SmartGraph Graph;
35 GRAPH_TYPEDEFS(Graph);
36 typedef Graph::EdgeMap<int> IntEdgeMap;
37 typedef Graph::NodeMap<bool> BoolNodeMap;
39 int cutValue(const Graph& graph, const BoolNodeMap& cut,
40 const IntEdgeMap& capacity) {
43 for (EdgeIt e(graph); e != INVALID; ++e) {
47 if (cut[s] != cut[t]) {
57 IntEdgeMap capacity(graph);
59 std::istringstream input(test_lgf);
60 GraphReader<Graph>(graph, input).
61 edgeMap("capacity", capacity).run();
63 GomoryHu<Graph> ght(graph, capacity);
66 for (NodeIt u(graph); u != INVALID; ++u) {
67 for (NodeIt v(graph); v != u; ++v) {
68 Preflow<Graph, IntEdgeMap> pf(graph, capacity, u, v);
70 BoolNodeMap cm(graph);
71 ght.minCutMap(u, v, cm);
72 check(pf.flowValue() == ght.minCutValue(u, v), "Wrong cut 1");
73 check(cm[u] != cm[v], "Wrong cut 3");
74 check(pf.flowValue() == cutValue(graph, cm, capacity), "Wrong cut 2");
77 for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a)
79 check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt");
82 for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,true);n!=INVALID;++n)
84 for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,false);n!=INVALID;++n)
86 check(sum == countNodes(graph), "Problem with MinCutNodeIt");