/* -*- mode: C++; indent-tabs-mode: nil; -*-
* This file is a part of LEMON, a generic C++ optimization library.
* Copyright (C) 2003-2011
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
#include <lemon/smart_graph.h>
#include <lemon/concepts/graph.h>
#include <lemon/concepts/maps.h>
#include <lemon/lgf_reader.h>
#include <lemon/gomory_hu.h>
typedef SmartGraph Graph;
void checkGomoryHuCompile()
typedef concepts::Graph Graph;
typedef Graph::Node Node;
typedef Graph::Edge Edge;
typedef concepts::ReadMap<Edge, Value> CapMap;
typedef concepts::ReadWriteMap<Node, bool> CutMap;
GomoryHu<Graph, CapMap> gh_test(g, cap);
const GomoryHu<Graph, CapMap>&
n = const_gh_test.predNode(n);
v = const_gh_test.predValue(n);
d = const_gh_test.rootDist(n);
v = const_gh_test.minCutValue(n, n);
v = const_gh_test.minCutMap(n, n, cut);
typedef Graph::EdgeMap<int> IntEdgeMap;
typedef Graph::NodeMap<bool> BoolNodeMap;
int cutValue(const Graph& graph, const BoolNodeMap& cut,
const IntEdgeMap& capacity) {
for (EdgeIt e(graph); e != INVALID; ++e) {
IntEdgeMap capacity(graph);
std::istringstream input(test_lgf);
GraphReader<Graph>(graph, input).
edgeMap("capacity", capacity).run();
GomoryHu<Graph> ght(graph, capacity);
for (NodeIt u(graph); u != INVALID; ++u) {
for (NodeIt v(graph); v != u; ++v) {
Preflow<Graph, IntEdgeMap> pf(graph, capacity, u, v);
check(pf.flowValue() == ght.minCutValue(u, v), "Wrong cut 1");
check(cm[u] != cm[v], "Wrong cut 2");
check(pf.flowValue() == cutValue(graph, cm, capacity), "Wrong cut 3");
for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a)
check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt");
for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,true);n!=INVALID;++n)
for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,false);n!=INVALID;++n)
check(sum == countNodes(graph), "Problem with MinCutNodeIt");