/* -*- mode: C++; indent-tabs-mode: nil; -*-
* This file is a part of LEMON, a generic C++ optimization library.
* Copyright (C) 2003-2010
* 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/list_graph.h>
#include <lemon/circulation.h>
#include <lemon/lgf_reader.h>
#include <lemon/concepts/digraph.h>
#include <lemon/concepts/maps.h>
void checkCirculationCompile()
typedef concepts::Digraph Digraph;
typedef Digraph::Node Node;
typedef Digraph::Arc Arc;
typedef concepts::ReadMap<Arc,VType> CapMap;
typedef concepts::ReadMap<Node,VType> SupplyMap;
typedef concepts::ReadWriteMap<Arc,VType> FlowMap;
typedef concepts::WriteMap<Node,bool> BarrierMap;
typedef Elevator<Digraph, Digraph::Node> Elev;
typedef LinkedElevator<Digraph, Digraph::Node> LinkedElev;
typedef Circulation<Digraph, CapMap, CapMap, SupplyMap>
::SetStandardElevator<LinkedElev>
::Create CirculationType;
CirculationType circ_test(g, lcap, ucap, supply);
const CirculationType& const_circ_test = circ_test;
const CirculationType::Elevator& elev = const_circ_test.elevator();
circ_test.elevator(const_cast<CirculationType::Elevator&>(elev));
CirculationType::Tolerance tol = const_circ_test.tolerance();
circ_test.tolerance(tol);
v = const_circ_test.flow(a);
const FlowMap& fm = const_circ_test.flowMap();
b = const_circ_test.barrier(n);
const_circ_test.barrierMap(bar);
ignore_unused_variable_warning(fm);
template <class G, class LM, class UM, class DM>
void checkCirculation(const G& g, const LM& lm, const UM& um,
Circulation<G, LM, UM, DM> circ(g, lm, um, dm);
check(ret, "A feasible solution should have been found.");
check(circ.checkFlow(), "The found flow is corrupt.");
check(!circ.checkBarrier(), "A barrier should not have been found.");
check(!ret, "A feasible solution should not have been found.");
check(circ.checkBarrier(), "The found barrier is corrupt.");
typedef ListDigraph Digraph;
DIGRAPH_TYPEDEFS(Digraph);
std::istringstream input(test_lgf);
DigraphReader<Digraph>(g,input).
delta[s] = 7; delta[t] = -7;
checkCirculation(g, lo, up, delta, true);
delta[s] = 13; delta[t] = -13;
checkCirculation(g, lo, up, delta, true);
delta[s] = 6; delta[t] = -6;
checkCirculation(g, lo, up, delta, false);
delta[s] = 14; delta[t] = -14;
checkCirculation(g, lo, up, delta, false);
delta[s] = 7; delta[t] = -13;
checkCirculation(g, lo, up, delta, true);
delta[s] = 5; delta[t] = -15;
checkCirculation(g, lo, up, delta, true);
delta[s] = 10; delta[t] = -11;
checkCirculation(g, lo, up, delta, true);
delta[s] = 11; delta[t] = -10;
checkCirculation(g, lo, up, delta, false);