/* -*- mode: C++; indent-tabs-mode: nil; -*-
* This file is a part of LEMON, a generic C++ optimization library.
* Copyright (C) 2003-2009
* 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/lgf_reader.h>
#include <lemon/howard.h>
#include <lemon/concepts/digraph.h>
#include <lemon/concept_check.h>
" len1 len2 len3 len4 c1 c2 c3 c4\n"
"3 7 -4 -4 -4 -4 0 0 0 0\n"
"6 4 -1 -1 -1 -1 0 0 0 0\n"
"7 7 4 4 4 -1 0 0 0 1\n";
// Check the interface of an MMC algorithm
template <typename GR, typename Value>
const Constraints& me = *this;
::template SetPath<ListPath<GR> >
::template SetLargeValue<Value>
MmcAlg mmc(me.g, me.length);
const MmcAlg& const_mmc = mmc;
v = const_mmc.cycleLength();
i = const_mmc.cycleArcNum();
d = const_mmc.cycleMean();
typedef concepts::ReadMap<typename GR::Arc, Value> LM;
// Perform a test with the given parameters
void checkMmcAlg(const SmartDigraph& gr,
const SmartDigraph::ArcMap<int>& lm,
const SmartDigraph::ArcMap<int>& cm,
check(alg.cycleMean() == static_cast<double>(length) / size,
check(alg.cycleLength() == length && alg.cycleArcNum() == size,
SmartDigraph::ArcMap<int> cycle(gr, 0);
for (typename MMC::Path::ArcIt a(alg.cycle()); a != INVALID; ++a) {
for (SmartDigraph::ArcIt a(gr); a != INVALID; ++a) {
check(cm[a] == cycle[a], "Wrong path");
// Class for comparing types
template <typename T1, typename T2>
static const int result = 0;
static const int result = 1;
#ifdef LEMON_HAVE_LONG_LONG
typedef long long long_int;
typedef concepts::Digraph GR;
typedef Howard<GR, concepts::ReadMap<GR::Arc, int> > IntMmcAlg;
typedef Howard<GR, concepts::ReadMap<GR::Arc, float> > FloatMmcAlg;
checkConcept<MmcClassConcept<GR, int>, IntMmcAlg>();
checkConcept<MmcClassConcept<GR, float>, FloatMmcAlg>();
if (IsSameType<IntMmcAlg::LargeValue, long_int>::result == 0)
check(false, "Wrong LargeValue type");
if (IsSameType<FloatMmcAlg::LargeValue, double>::result == 0)
check(false, "Wrong LargeValue type");
IntArcMap l1(gr), l2(gr), l3(gr), l4(gr);
IntArcMap c1(gr), c2(gr), c3(gr), c4(gr);
std::istringstream input(test_lgf);
digraphReader(gr, input).
checkMmcAlg<Howard<GR, IntArcMap> >(gr, l1, c1, 6, 3);
checkMmcAlg<Howard<GR, IntArcMap> >(gr, l2, c2, 5, 2);
checkMmcAlg<Howard<GR, IntArcMap> >(gr, l3, c3, 0, 1);
checkMmcAlg<Howard<GR, IntArcMap> >(gr, l4, c4, -1, 1);