Fix multiple executions in matchings (fract. mathcings) (#356)
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;
54 GomoryHu<Graph, CapMap> gh_test(g, cap);
55 const GomoryHu<Graph, CapMap>&
56 const_gh_test = gh_test;
60 n = const_gh_test.predNode(n);
61 v = const_gh_test.predValue(n);
62 d = const_gh_test.rootDist(n);
63 v = const_gh_test.minCutValue(n, n);
64 v = const_gh_test.minCutMap(n, n, cut);
67 GRAPH_TYPEDEFS(Graph);
68 typedef Graph::EdgeMap<int> IntEdgeMap;
69 typedef Graph::NodeMap<bool> BoolNodeMap;
71 int cutValue(const Graph& graph, const BoolNodeMap& cut,
72 const IntEdgeMap& capacity) {
75 for (EdgeIt e(graph); e != INVALID; ++e) {
79 if (cut[s] != cut[t]) {
89 IntEdgeMap capacity(graph);
91 std::istringstream input(test_lgf);
92 GraphReader<Graph>(graph, input).
93 edgeMap("capacity", capacity).run();
95 GomoryHu<Graph> ght(graph, capacity);
98 for (NodeIt u(graph); u != INVALID; ++u) {
99 for (NodeIt v(graph); v != u; ++v) {
100 Preflow<Graph, IntEdgeMap> pf(graph, capacity, u, v);
102 BoolNodeMap cm(graph);
103 ght.minCutMap(u, v, cm);
104 check(pf.flowValue() == ght.minCutValue(u, v), "Wrong cut 1");
105 check(cm[u] != cm[v], "Wrong cut 2");
106 check(pf.flowValue() == cutValue(graph, cm, capacity), "Wrong cut 3");
109 for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a)
111 check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt");
114 for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,true);n!=INVALID;++n)
116 for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,false);n!=INVALID;++n)
118 check(sum == countNodes(graph), "Problem with MinCutNodeIt");