OKlibrary  0.2.1.6
MinimumTransversalsMongen.cpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 13.6.2009 (Swansea)
00002 /* Copyright 2009, 2010 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00043 #include <iostream>
00044 #include <set>
00045 #include <vector>
00046 
00047 #include <boost/lexical_cast.hpp>
00048 
00049 #include <OKlib/Programming/Utilities/OrderRelations/OrderConstructions.hpp>
00050 #include <OKlib/Combinatorics/Hypergraphs/Transversals/Bounded/VertexBranching.hpp>
00051 
00052 #include <OKlib/Combinatorics/Hypergraphs/Transversals/Bounded/MinimumTransversalsMongen.hpp>
00053 
00054 namespace {
00055 
00056   using OKlib::Combinatorics::Hypergraphs::Transversals::Bounded::vertex_type;
00057   using OKlib::Combinatorics::Hypergraphs::Transversals::Bounded::hyperedge_list_type;
00058   using OKlib::Combinatorics::Hypergraphs::Transversals::Bounded::parameter_type;
00059 
00060   template <class> struct GeneratorWrapper {
00061     typedef ::vertex_type vertex_type;
00062     typedef ::hyperedge_list_type hyperedge_list_type;
00063     hyperedge_list_type operator() (const vertex_type n) const {
00064       return ::OKlib::Combinatorics::Hypergraphs::Transversals::Bounded::generator(n);
00065     }
00066   };
00067 
00068   enum {
00069     error_parameters = 1
00070   };
00071 
00072   const std::string version = "0.0.3";
00073 
00074 }
00075 
00076 int main(const int argc, const char* const argv[]) {
00077 
00078   if (argc == 1) {
00079     std::cerr << "ERROR[MinimumTransversalsMongen]:\n"
00080       " At least one parameter is required, the maximal number of vertices.\n";
00081     return error_parameters;
00082   }
00083 
00084   const vertex_type N = boost::lexical_cast<vertex_type>(argv[1]);
00085   {
00086     parameter_type P; P.reserve(argc-2);
00087     for (int i = 2; i < argc; ++i)
00088       P.push_back(boost::lexical_cast<vertex_type>(argv[i]));
00089     ::OKlib::Combinatorics::Hypergraphs::Transversals::Bounded::initialise(N, P);
00090   }
00091 
00092   using OKlib::Combinatorics::Hypergraphs::Transversals::Bounded::hyperedge_type;
00093   typedef OKlib::Programming::Utilities::OrderRelations::SizeLessThan<std::less<hyperedge_type> > hyperedge_ordering_type;
00094   typedef std::set<hyperedge_type, hyperedge_ordering_type> set_system_type;
00095 
00096   using namespace OKlib::Combinatorics::Hypergraphs::Transversals;
00097   typedef Bounded::Minimum_transversals_mongen<set_system_type, GeneratorWrapper, Bounded::TrivialOutput> mtrans_mongen_type;
00098   typedef mtrans_mongen_type::generator_type generator_type;
00099   typedef mtrans_mongen_type::output_type output_type;
00100   output_type out(std::cout);
00101 
00102   mtrans_mongen_type()(N, generator_type(), out);
00103 
00104 }
00105