3 #include "test_tools.h"
4 #include <lemon/smart_graph.h>
5 #include <lemon/concepts/graph.h>
6 #include <lemon/concepts/maps.h>
7 #include <lemon/lgf_reader.h>
8 #include <lemon/gomory_hu.h>
12 using namespace lemon;
14 typedef SmartGraph Graph;
37 void checkGomoryHuCompile()
40 typedef concepts::Graph Graph;
42 typedef Graph::Node Node;
43 typedef Graph::Edge Edge;
44 typedef concepts::ReadMap<Edge, Value> CapMap;
45 typedef concepts::ReadWriteMap<Node, bool> CutMap;
53 ::lemon::ignore_unused_variable_warning(v,d);
55 GomoryHu<Graph, CapMap> gh_test(g, cap);
56 const GomoryHu<Graph, CapMap>&
57 const_gh_test = gh_test;
61 n = const_gh_test.predNode(n);
62 v = const_gh_test.predValue(n);
63 d = const_gh_test.rootDist(n);
64 v = const_gh_test.minCutValue(n, n);
65 v = const_gh_test.minCutMap(n, n, cut);
68 GRAPH_TYPEDEFS(Graph);
69 typedef Graph::EdgeMap<int> IntEdgeMap;
70 typedef Graph::NodeMap<bool> BoolNodeMap;
72 int cutValue(const Graph& graph, const BoolNodeMap& cut,
73 const IntEdgeMap& capacity) {
76 for (EdgeIt e(graph); e != INVALID; ++e) {
80 if (cut[s] != cut[t]) {
90 IntEdgeMap capacity(graph);
92 std::istringstream input(test_lgf);
93 GraphReader<Graph>(graph, input).
94 edgeMap("capacity", capacity).run();
96 GomoryHu<Graph> ght(graph, capacity);
99 for (NodeIt u(graph); u != INVALID; ++u) {
100 for (NodeIt v(graph); v != u; ++v) {
101 Preflow<Graph, IntEdgeMap> pf(graph, capacity, u, v);
103 BoolNodeMap cm(graph);
104 ght.minCutMap(u, v, cm);
105 check(pf.flowValue() == ght.minCutValue(u, v), "Wrong cut 1");
106 check(cm[u] != cm[v], "Wrong cut 2");
107 check(pf.flowValue() == cutValue(graph, cm, capacity), "Wrong cut 3");
110 for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a)
112 check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt");
115 for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,true);n!=INVALID;++n)
117 for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,false);n!=INVALID;++n)
119 check(sum == countNodes(graph), "Problem with MinCutNodeIt");