COIN-OR::LEMON - Graph Library

Changeset 1071:2d583da4ba40 in lemon


Ignore:
Timestamp:
08/04/11 21:47:29 (13 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Parents:
1066:f9e3f73e17f1 (diff), 1067:54464584b157 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge #382

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • doc/lgf.dox

    r463 r1069  
    6464\endcode
    6565
    66 The \c \@arcs section is very similar to the \c \@nodes section,
    67 it again starts with a header line describing the names of the maps,
    68 but the \c "label" map is not obligatory here. The following lines
    69 describe the arcs. The first two tokens of each line are
    70 the source and the target node of the arc, respectively, then come the map
     66The \c \@arcs section is very similar to the \c \@nodes section, it
     67again starts with a header line describing the names of the maps, but
     68the \c "label" map is not obligatory here. The following lines
     69describe the arcs. The first two tokens of each line are the source
     70and the target node of the arc, respectively, then come the map
    7171values. The source and target tokens must be node labels.
    7272
     
    7979\endcode
    8080
     81If there is no map in the \c \@arcs section at all, then it must be
     82indicated by a sole '-' sign in the first line.
     83
     84\code
     85 @arcs
     86         -
     87 1   2
     88 1   3
     89 2   3
     90\endcode
     91
    8192The \c \@edges is just a synonym of \c \@arcs. The \@arcs section can
    8293also store the edge set of an undirected graph. In such case there is
    8394a conventional method for store arc maps in the file, if two columns
    84 has the same caption with \c '+' and \c '-' prefix, then these columns
     95have the same caption with \c '+' and \c '-' prefix, then these columns
    8596can be regarded as the values of an arc map.
    8697
  • doc/lgf.dox

    r1067 r1069  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/lgf_reader.h

    r956 r1070  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2010
     5 * Copyright (C) 2003-2011
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    965965        int index = 0;
    966966        while (_reader_bits::readToken(line, map)) {
     967          if(map == "-") {
     968              if(index!=0)
     969                throw FormatError("'-' is not allowed as a map name");
     970              else if (line >> std::ws >> c)
     971                throw FormatError("Extra character at the end of line");
     972              else break;
     973            }
    967974          if (maps.find(map) != maps.end()) {
    968975            std::ostringstream msg;
     
    18351842        int index = 0;
    18361843        while (_reader_bits::readToken(line, map)) {
     1844          if(map == "-") {
     1845              if(index!=0)
     1846                throw FormatError("'-' is not allowed as a map name");
     1847              else if (line >> std::ws >> c)
     1848                throw FormatError("Extra character at the end of line");
     1849              else break;
     1850            }
    18371851          if (maps.find(map) != maps.end()) {
    18381852            std::ostringstream msg;
  • lemon/lgf_reader.h

    r1067 r1070  
    102102    };
    103103
    104     template <typename _Graph, bool _dir, typename _Map,
     104    template <typename _GR, bool _dir, typename _Map,
    105105              typename _Converter = DefaultConverter<typename _Map::Value> >
    106     class GraphArcMapStorage : public MapStorageBase<typename _Graph::Edge> {
     106    class GraphArcMapStorage : public MapStorageBase<typename _GR::Edge> {
    107107    public:
    108108      typedef _Map Map;
    109109      typedef _Converter Converter;
    110       typedef _Graph Graph;
    111       typedef typename Graph::Edge Item;
     110      typedef _GR GR;
     111      typedef typename GR::Edge Item;
    112112      static const bool dir = _dir;
    113113
    114114    private:
    115       const Graph& _graph;
     115      const GR& _graph;
    116116      Map& _map;
    117117      Converter _converter;
    118118
    119119    public:
    120       GraphArcMapStorage(const Graph& graph, Map& map,
     120      GraphArcMapStorage(const GR& graph, Map& map,
    121121                         const Converter& converter = Converter())
    122122        : _graph(graph), _map(map), _converter(converter) {}
     
    174174    };
    175175
    176     template <typename Graph>
     176    template <typename GR>
    177177    struct GraphArcLookUpConverter {
    178       const Graph& _graph;
    179       const std::map<std::string, typename Graph::Edge>& _map;
    180 
    181       GraphArcLookUpConverter(const Graph& graph,
     178      const GR& _graph;
     179      const std::map<std::string, typename GR::Edge>& _map;
     180
     181      GraphArcLookUpConverter(const GR& graph,
    182182                              const std::map<std::string,
    183                                              typename Graph::Edge>& map)
     183                                             typename GR::Edge>& map)
    184184        : _graph(graph), _map(map) {}
    185185
    186       typename Graph::Arc operator()(const std::string& str) {
     186      typename GR::Arc operator()(const std::string& str) {
    187187        if (str.empty() || (str[0] != '+' && str[0] != '-')) {
    188188          throw FormatError("Item must start with '+' or '-'");
    189189        }
    190         typename std::map<std::string, typename Graph::Edge>
     190        typename std::map<std::string, typename GR::Edge>
    191191          ::const_iterator it = _map.find(str.substr(1));
    192192        if (it == _map.end()) {
     
    388388  }
    389389
    390   template <typename Digraph>
     390  template <typename DGR>
    391391  class DigraphReader;
    392392
    393   template <typename Digraph>
    394   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    395                                        std::istream& is = std::cin);
    396   template <typename Digraph>
    397   DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
    398   template <typename Digraph>
    399   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
     393  template <typename TDGR>
     394  DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is = std::cin);
     395  template <typename TDGR>
     396  DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn);
     397  template <typename TDGR>
     398  DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn);
    400399
    401400  /// \ingroup lemon_io
     
    420419  ///
    421420  ///\code
    422   /// DigraphReader<Digraph>(digraph, std::cin).
     421  /// DigraphReader<DGR>(digraph, std::cin).
    423422  ///   nodeMap("coordinates", coord_map).
    424423  ///   arcMap("capacity", cap_map).
     
    429428  ///\endcode
    430429  ///
    431   /// By default the reader uses the first section in the file of the
     430  /// By default, the reader uses the first section in the file of the
    432431  /// proper type. If a section has an optional name, then it can be
    433432  /// selected for reading by giving an optional name parameter to the
     
    449448  /// a single pass, because the arcs are not constructed when the node
    450449  /// maps are read.
    451   template <typename _Digraph>
     450  template <typename DGR>
    452451  class DigraphReader {
    453452  public:
    454453
    455     typedef _Digraph Digraph;
    456     TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
     454    typedef DGR Digraph;
    457455
    458456  private:
    459457
     458    TEMPLATE_DIGRAPH_TYPEDEFS(DGR);
    460459
    461460    std::istream* _is;
     
    463462    std::string _filename;
    464463
    465     Digraph& _digraph;
     464    DGR& _digraph;
    466465
    467466    std::string _nodes_caption;
     
    501500    /// Construct a directed graph reader, which reads from the given
    502501    /// input stream.
    503     DigraphReader(Digraph& digraph, std::istream& is = std::cin)
     502    DigraphReader(DGR& digraph, std::istream& is = std::cin)
    504503      : _is(&is), local_is(false), _digraph(digraph),
    505504        _use_nodes(false), _use_arcs(false),
     
    510509    /// Construct a directed graph reader, which reads from the given
    511510    /// file.
    512     DigraphReader(Digraph& digraph, const std::string& fn)
     511    DigraphReader(DGR& digraph, const std::string& fn)
    513512      : _is(new std::ifstream(fn.c_str())), local_is(true),
    514513        _filename(fn), _digraph(digraph),
     
    525524    /// Construct a directed graph reader, which reads from the given
    526525    /// file.
    527     DigraphReader(Digraph& digraph, const char* fn)
     526    DigraphReader(DGR& digraph, const char* fn)
    528527      : _is(new std::ifstream(fn)), local_is(true),
    529528        _filename(fn), _digraph(digraph),
     
    561560  private:
    562561
    563     template <typename DGR>
    564     friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
    565     template <typename DGR>
    566     friend DigraphReader<DGR> digraphReader(DGR& digraph,
    567                                             const std::string& fn);
    568     template <typename DGR>
    569     friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
     562    template <typename TDGR>
     563    friend DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is);
     564    template <typename TDGR>
     565    friend DigraphReader<TDGR> digraphReader(TDGR& digraph,
     566                                             const std::string& fn);
     567    template <typename TDGR>
     568    friend DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn);
    570569
    571570    DigraphReader(DigraphReader& other)
     
    594593  public:
    595594
    596     /// \name Reading rules
     595    /// \name Reading Rules
    597596    /// @{
    598597
     
    699698    /// @}
    700699
    701     /// \name Select section by name
     700    /// \name Select Section by Name
    702701    /// @{
    703702
     
    728727    /// @}
    729728
    730     /// \name Using previously constructed node or arc set
     729    /// \name Using Previously Constructed Node or Arc Set
    731730    /// @{
    732731
     
    848847        readLine();
    849848      }
    850       line.putback(c);
     849      if (readSuccess()) {
     850        line.putback(c);
     851      }
    851852    }
    852853
     
    11221123  public:
    11231124
    1124     /// \name Execution of the reader
     1125    /// \name Execution of the Reader
    11251126    /// @{
    11261127
     
    11951196  };
    11961197
     1198  /// \ingroup lemon_io
     1199  ///
     1200  /// \brief Return a \ref DigraphReader class
     1201  ///
     1202  /// This function just returns a \ref DigraphReader class.
     1203  ///
     1204  /// With this function a digraph can be read from an
     1205  /// \ref lgf-format "LGF" file or input stream with several maps and
     1206  /// attributes. For example, there is network flow problem on a
     1207  /// digraph, i.e. a digraph with a \e capacity map on the arcs and
     1208  /// \e source and \e target nodes. This digraph can be read with the
     1209  /// following code:
     1210  ///
     1211  ///\code
     1212  ///ListDigraph digraph;
     1213  ///ListDigraph::ArcMap<int> cm(digraph);
     1214  ///ListDigraph::Node src, trg;
     1215  ///digraphReader(digraph, std::cin).
     1216  ///  arcMap("capacity", cap).
     1217  ///  node("source", src).
     1218  ///  node("target", trg).
     1219  ///  run();
     1220  ///\endcode
     1221  ///
     1222  /// For a complete documentation, please see the \ref DigraphReader
     1223  /// class documentation.
     1224  /// \warning Don't forget to put the \ref DigraphReader::run() "run()"
     1225  /// to the end of the parameter list.
     1226  /// \relates DigraphReader
     1227  /// \sa digraphReader(TDGR& digraph, const std::string& fn)
     1228  /// \sa digraphReader(TDGR& digraph, const char* fn)
     1229  template <typename TDGR>
     1230  DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is) {
     1231    DigraphReader<TDGR> tmp(digraph, is);
     1232    return tmp;
     1233  }
     1234
    11971235  /// \brief Return a \ref DigraphReader class
    11981236  ///
    11991237  /// This function just returns a \ref DigraphReader class.
    12001238  /// \relates DigraphReader
    1201   template <typename Digraph>
    1202   DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
    1203     DigraphReader<Digraph> tmp(digraph, is);
     1239  /// \sa digraphReader(TDGR& digraph, std::istream& is)
     1240  template <typename TDGR>
     1241  DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn) {
     1242    DigraphReader<TDGR> tmp(digraph, fn);
    12041243    return tmp;
    12051244  }
     
    12091248  /// This function just returns a \ref DigraphReader class.
    12101249  /// \relates DigraphReader
    1211   template <typename Digraph>
    1212   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    1213                                        const std::string& fn) {
    1214     DigraphReader<Digraph> tmp(digraph, fn);
     1250  /// \sa digraphReader(TDGR& digraph, std::istream& is)
     1251  template <typename TDGR>
     1252  DigraphReader<TDGR> digraphReader(TDGR& digraph, const char* fn) {
     1253    DigraphReader<TDGR> tmp(digraph, fn);
    12151254    return tmp;
    12161255  }
    12171256
    1218   /// \brief Return a \ref DigraphReader class
    1219   ///
    1220   /// This function just returns a \ref DigraphReader class.
    1221   /// \relates DigraphReader
    1222   template <typename Digraph>
    1223   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
    1224     DigraphReader<Digraph> tmp(digraph, fn);
    1225     return tmp;
    1226   }
    1227 
    1228   template <typename Graph>
     1257  template <typename GR>
    12291258  class GraphReader;
    1230  
    1231   template <typename Graph>
    1232   GraphReader<Graph> graphReader(Graph& graph,
    1233                                  std::istream& is = std::cin);
    1234   template <typename Graph>
    1235   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
    1236   template <typename Graph>
    1237   GraphReader<Graph> graphReader(Graph& graph, const char *fn);
     1259
     1260  template <typename TGR>
     1261  GraphReader<TGR> graphReader(TGR& graph, std::istream& is = std::cin);
     1262  template <typename TGR>
     1263  GraphReader<TGR> graphReader(TGR& graph, const std::string& fn);
     1264  template <typename TGR>
     1265  GraphReader<TGR> graphReader(TGR& graph, const char *fn);
    12381266
    12391267  /// \ingroup lemon_io
     
    12521280  /// arc map.  Similarly, an attribute can be read into an arc, if
    12531281  /// it's value is an edge label prefixed with \c '+' or \c '-'.
    1254   template <typename _Graph>
     1282  template <typename GR>
    12551283  class GraphReader {
    12561284  public:
    12571285
    1258     typedef _Graph Graph;
    1259     TEMPLATE_GRAPH_TYPEDEFS(Graph);
     1286    typedef GR Graph;
    12601287
    12611288  private:
     1289
     1290    TEMPLATE_GRAPH_TYPEDEFS(GR);
    12621291
    12631292    std::istream* _is;
     
    12651294    std::string _filename;
    12661295
    1267     Graph& _graph;
     1296    GR& _graph;
    12681297
    12691298    std::string _nodes_caption;
     
    13031332    /// Construct an undirected graph reader, which reads from the given
    13041333    /// input stream.
    1305     GraphReader(Graph& graph, std::istream& is = std::cin)
     1334    GraphReader(GR& graph, std::istream& is = std::cin)
    13061335      : _is(&is), local_is(false), _graph(graph),
    13071336        _use_nodes(false), _use_edges(false),
     
    13121341    /// Construct an undirected graph reader, which reads from the given
    13131342    /// file.
    1314     GraphReader(Graph& graph, const std::string& fn)
     1343    GraphReader(GR& graph, const std::string& fn)
    13151344      : _is(new std::ifstream(fn.c_str())), local_is(true),
    13161345        _filename(fn), _graph(graph),
     
    13271356    /// Construct an undirected graph reader, which reads from the given
    13281357    /// file.
    1329     GraphReader(Graph& graph, const char* fn)
     1358    GraphReader(GR& graph, const char* fn)
    13301359      : _is(new std::ifstream(fn)), local_is(true),
    13311360        _filename(fn), _graph(graph),
     
    13621391
    13631392  private:
    1364     template <typename GR>
    1365     friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
    1366     template <typename GR>
    1367     friend GraphReader<GR> graphReader(GR& graph, const std::string& fn);
    1368     template <typename GR>
    1369     friend GraphReader<GR> graphReader(GR& graph, const char *fn);
     1393    template <typename TGR>
     1394    friend GraphReader<TGR> graphReader(TGR& graph, std::istream& is);
     1395    template <typename TGR>
     1396    friend GraphReader<TGR> graphReader(TGR& graph, const std::string& fn);
     1397    template <typename TGR>
     1398    friend GraphReader<TGR> graphReader(TGR& graph, const char *fn);
    13701399
    13711400    GraphReader(GraphReader& other)
     
    13941423  public:
    13951424
    1396     /// \name Reading rules
     1425    /// \name Reading Rules
    13971426    /// @{
    13981427
     
    14591488      _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
    14601489      _reader_bits::MapStorageBase<Edge>* backward_storage =
    1461         new _reader_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
     1490        new _reader_bits::GraphArcMapStorage<GR, false, Map>(_graph, map);
    14621491      _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
    14631492      return *this;
     
    14731502      checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
    14741503      _reader_bits::MapStorageBase<Edge>* forward_storage =
    1475         new _reader_bits::GraphArcMapStorage<Graph, true, Map, Converter>
     1504        new _reader_bits::GraphArcMapStorage<GR, true, Map, Converter>
    14761505        (_graph, map, converter);
    14771506      _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
    14781507      _reader_bits::MapStorageBase<Edge>* backward_storage =
    1479         new _reader_bits::GraphArcMapStorage<Graph, false, Map, Converter>
     1508        new _reader_bits::GraphArcMapStorage<GR, false, Map, Converter>
    14801509        (_graph, map, converter);
    14811510      _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
     
    15351564    /// Add an arc reading rule to reader.
    15361565    GraphReader& arc(const std::string& caption, Arc& arc) {
    1537       typedef _reader_bits::GraphArcLookUpConverter<Graph> Converter;
     1566      typedef _reader_bits::GraphArcLookUpConverter<GR> Converter;
    15381567      Converter converter(_graph, _edge_index);
    15391568      _reader_bits::ValueStorageBase* storage =
     
    15451574    /// @}
    15461575
    1547     /// \name Select section by name
     1576    /// \name Select Section by Name
    15481577    /// @{
    15491578
     
    15741603    /// @}
    15751604
    1576     /// \name Using previously constructed node or edge set
     1605    /// \name Using Previously Constructed Node or Edge Set
    15771606    /// @{
    15781607
     
    16951724        readLine();
    16961725      }
    1697       line.putback(c);
     1726      if (readSuccess()) {
     1727        line.putback(c);
     1728      }
    16981729    }
    16991730
     
    19692000  public:
    19702001
    1971     /// \name Execution of the reader
     2002    /// \name Execution of the Reader
    19722003    /// @{
    19732004
     
    20432074  };
    20442075
     2076  /// \ingroup lemon_io
     2077  ///
     2078  /// \brief Return a \ref GraphReader class
     2079  ///
     2080  /// This function just returns a \ref GraphReader class.
     2081  ///
     2082  /// With this function a graph can be read from an
     2083  /// \ref lgf-format "LGF" file or input stream with several maps and
     2084  /// attributes. For example, there is weighted matching problem on a
     2085  /// graph, i.e. a graph with a \e weight map on the edges. This
     2086  /// graph can be read with the following code:
     2087  ///
     2088  ///\code
     2089  ///ListGraph graph;
     2090  ///ListGraph::EdgeMap<int> weight(graph);
     2091  ///graphReader(graph, std::cin).
     2092  ///  edgeMap("weight", weight).
     2093  ///  run();
     2094  ///\endcode
     2095  ///
     2096  /// For a complete documentation, please see the \ref GraphReader
     2097  /// class documentation.
     2098  /// \warning Don't forget to put the \ref GraphReader::run() "run()"
     2099  /// to the end of the parameter list.
     2100  /// \relates GraphReader
     2101  /// \sa graphReader(TGR& graph, const std::string& fn)
     2102  /// \sa graphReader(TGR& graph, const char* fn)
     2103  template <typename TGR>
     2104  GraphReader<TGR> graphReader(TGR& graph, std::istream& is) {
     2105    GraphReader<TGR> tmp(graph, is);
     2106    return tmp;
     2107  }
     2108
    20452109  /// \brief Return a \ref GraphReader class
    20462110  ///
    20472111  /// This function just returns a \ref GraphReader class.
    20482112  /// \relates GraphReader
    2049   template <typename Graph>
    2050   GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
    2051     GraphReader<Graph> tmp(graph, is);
     2113  /// \sa graphReader(TGR& graph, std::istream& is)
     2114  template <typename TGR>
     2115  GraphReader<TGR> graphReader(TGR& graph, const std::string& fn) {
     2116    GraphReader<TGR> tmp(graph, fn);
    20522117    return tmp;
    20532118  }
     
    20572122  /// This function just returns a \ref GraphReader class.
    20582123  /// \relates GraphReader
    2059   template <typename Graph>
    2060   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
    2061     GraphReader<Graph> tmp(graph, fn);
    2062     return tmp;
    2063   }
    2064 
    2065   /// \brief Return a \ref GraphReader class
    2066   ///
    2067   /// This function just returns a \ref GraphReader class.
    2068   /// \relates GraphReader
    2069   template <typename Graph>
    2070   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
    2071     GraphReader<Graph> tmp(graph, fn);
     2124  /// \sa graphReader(TGR& graph, std::istream& is)
     2125  template <typename TGR>
     2126  GraphReader<TGR> graphReader(TGR& graph, const char* fn) {
     2127    GraphReader<TGR> tmp(graph, fn);
    20722128    return tmp;
    20732129  }
     
    21682224  public:
    21692225
    2170     /// \name Section readers
     2226    /// \name Section Readers
    21712227    /// @{
    21722228
     
    21802236    /// whitespaces are trimmed from each processed string.
    21812237    ///
    2182     /// For example let's see a section, which contain several
     2238    /// For example, let's see a section, which contain several
    21832239    /// integers, which should be inserted into a vector.
    21842240    ///\code
     
    22592315        readLine();
    22602316      }
    2261       line.putback(c);
     2317      if (readSuccess()) {
     2318        line.putback(c);
     2319      }
    22622320    }
    22632321
     
    22652323
    22662324
    2267     /// \name Execution of the reader
     2325    /// \name Execution of the Reader
    22682326    /// @{
    22692327
     
    23242382  };
    23252383
     2384  /// \ingroup lemon_io
     2385  ///
    23262386  /// \brief Return a \ref SectionReader class
    23272387  ///
    23282388  /// This function just returns a \ref SectionReader class.
     2389  ///
     2390  /// Please see SectionReader documentation about the custom section
     2391  /// input.
     2392  ///
    23292393  /// \relates SectionReader
     2394  /// \sa sectionReader(const std::string& fn)
     2395  /// \sa sectionReader(const char *fn)
    23302396  inline SectionReader sectionReader(std::istream& is) {
    23312397    SectionReader tmp(is);
     
    23372403  /// This function just returns a \ref SectionReader class.
    23382404  /// \relates SectionReader
     2405  /// \sa sectionReader(std::istream& is)
    23392406  inline SectionReader sectionReader(const std::string& fn) {
    23402407    SectionReader tmp(fn);
     
    23462413  /// This function just returns a \ref SectionReader class.
    23472414  /// \relates SectionReader
     2415  /// \sa sectionReader(std::istream& is)
    23482416  inline SectionReader sectionReader(const char* fn) {
    23492417    SectionReader tmp(fn);
     
    24472515
    24482516
    2449     /// \name Node sections
     2517    /// \name Node Sections
    24502518    /// @{
    24512519
     
    24732541    /// @}
    24742542
    2475     /// \name Arc/Edge sections
     2543    /// \name Arc/Edge Sections
    24762544    /// @{
    24772545
     
    25312599    /// @}
    25322600
    2533     /// \name Attribute sections
     2601    /// \name Attribute Sections
    25342602    /// @{
    25352603
     
    25572625    /// @}
    25582626
    2559     /// \name Extra sections
     2627    /// \name Extra Sections
    25602628    /// @{
    25612629
     
    26002668        readLine();
    26012669      }
    2602       line.putback(c);
     2670      if (readSuccess()) {
     2671        line.putback(c);
     2672      }
    26032673    }
    26042674
     
    26312701  public:
    26322702
    2633     /// \name Execution of the contents reader
     2703    /// \name Execution of the Contents Reader
    26342704    /// @{
    26352705
  • test/CMakeLists.txt

    r1066 r1071  
    3434  heap_test
    3535  kruskal_test
     36  lgf_test
    3637  maps_test
    3738  matching_test
  • test/CMakeLists.txt

    r1067 r1071  
    11INCLUDE_DIRECTORIES(
    2   ${CMAKE_SOURCE_DIR}
     2  ${PROJECT_SOURCE_DIR}
    33  ${PROJECT_BINARY_DIR}
    44)
    55
    6 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
     6LINK_DIRECTORIES(
     7  ${PROJECT_BINARY_DIR}/lemon
     8)
     9
     10SET(TEST_WITH_VALGRIND "NO" CACHE STRING
     11  "Run the test with valgrind (YES/NO).")
     12SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.")
    713
    814SET(TESTS
     15  adaptors_test
     16  bellman_ford_test
    917  bfs_test
     18  circulation_test
     19  connectivity_test
    1020  counter_test
    1121  dfs_test
     
    1323  dijkstra_test
    1424  dim_test
     25  edge_set_test
    1526  error_test
     27  euler_test
     28  fractional_matching_test
     29  gomory_hu_test
    1630  graph_copy_test
    1731  graph_test
    1832  graph_utils_test
     33  hao_orlin_test
    1934  heap_test
    2035  kruskal_test
    2136  lgf_test
    2237  maps_test
     38  matching_test
     39  max_cardinality_search_test
     40  max_clique_test
     41  min_cost_arborescence_test
     42  min_cost_flow_test
     43  min_mean_cycle_test
     44  nagamochi_ibaraki_test
     45  path_test
     46  planarity_test
     47  preflow_test
     48  radix_sort_test
    2349  random_test
    24   path_test
     50  suurballe_test
    2551  time_measure_test
    26   unionfind_test)
     52  unionfind_test
     53)
     54
     55IF(LEMON_HAVE_LP)
     56  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     57    ADD_EXECUTABLE(lp_test lp_test.cc)
     58  ELSE()
     59    ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc)
     60  ENDIF()
     61
     62  SET(LP_TEST_LIBS lemon)
     63
     64  IF(LEMON_HAVE_GLPK)
     65    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES})
     66  ENDIF()
     67  IF(LEMON_HAVE_CPLEX)
     68    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
     69  ENDIF()
     70  IF(LEMON_HAVE_CLP)
     71    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES})
     72  ENDIF()
     73
     74  TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS})
     75  ADD_TEST(lp_test lp_test)
     76  ADD_DEPENDENCIES(check lp_test)
     77
     78  IF(WIN32 AND LEMON_HAVE_GLPK)
     79    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
     80    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     81    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
     82      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
     83      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
     84      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     85    )
     86  ENDIF()
     87
     88  IF(WIN32 AND LEMON_HAVE_CPLEX)
     89    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
     90    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     91    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
     92      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     93    )
     94  ENDIF()
     95ENDIF()
     96
     97IF(LEMON_HAVE_MIP)
     98  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     99    ADD_EXECUTABLE(mip_test mip_test.cc)
     100  ELSE()
     101    ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc)
     102  ENDIF()
     103
     104  SET(MIP_TEST_LIBS lemon)
     105
     106  IF(LEMON_HAVE_GLPK)
     107    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES})
     108  ENDIF()
     109  IF(LEMON_HAVE_CPLEX)
     110    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
     111  ENDIF()
     112  IF(LEMON_HAVE_CBC)
     113    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES})
     114  ENDIF()
     115
     116  TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS})
     117  ADD_TEST(mip_test mip_test)
     118  ADD_DEPENDENCIES(check mip_test)
     119
     120  IF(WIN32 AND LEMON_HAVE_GLPK)
     121    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
     122    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     123    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
     124      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
     125      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
     126      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     127    )
     128  ENDIF()
     129
     130  IF(WIN32 AND LEMON_HAVE_CPLEX)
     131    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
     132    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     133    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
     134      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     135    )
     136  ENDIF()
     137ENDIF()
    27138
    28139FOREACH(TEST_NAME ${TESTS})
    29   ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
     140  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     141    ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
     142  ELSE()
     143    ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
     144  ENDIF()
    30145  TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
    31   ADD_TEST(${TEST_NAME} ${TEST_NAME})
    32 ENDFOREACH(TEST_NAME)
     146    IF(TEST_WITH_VALGRIND)
     147      ADD_TEST(${TEST_NAME}
     148        valgrind --error-exitcode=1 ${VALGRIND_FLAGS}
     149        ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} )
     150    ELSE()
     151      ADD_TEST(${TEST_NAME} ${TEST_NAME})
     152    ENDIF()
     153  ADD_DEPENDENCIES(check ${TEST_NAME})
     154ENDFOREACH()
  • test/Makefile.am

    r1021 r1071  
    3232        test/heap_test \
    3333        test/kruskal_test \
     34        test/lgf_test \
    3435        test/maps_test \
    3536        test/matching_test \
     
    8182test_graph_test_SOURCES = test/graph_test.cc
    8283test_graph_utils_test_SOURCES = test/graph_utils_test.cc
     84test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
    8385test_heap_test_SOURCES = test/heap_test.cc
    8486test_kruskal_test_SOURCES = test/kruskal_test.cc
    85 test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
     87test_lgf_test_SOURCES = test/lgf_test.cc
    8688test_lp_test_SOURCES = test/lp_test.cc
    8789test_maps_test_SOURCES = test/maps_test.cc
  • test/Makefile.am

    r1067 r1071  
     1if USE_VALGRIND
     2TESTS_ENVIRONMENT=$(top_srcdir)/scripts/valgrind-wrapper.sh
     3endif
     4
    15EXTRA_DIST += \
    26        test/CMakeLists.txt
     
    48noinst_HEADERS += \
    59        test/graph_test.h \
    6         test/test_tools.h
     10        test/test_tools.h
    711
    812check_PROGRAMS += \
     13        test/adaptors_test \
     14        test/bellman_ford_test \
    915        test/bfs_test \
    10         test/counter_test \
     16        test/circulation_test \
     17        test/connectivity_test \
     18        test/counter_test \
    1119        test/dfs_test \
    1220        test/digraph_test \
    1321        test/dijkstra_test \
    14         test/dim_test \
     22        test/dim_test \
     23        test/edge_set_test \
    1524        test/error_test \
     25        test/euler_test \
     26        test/fractional_matching_test \
     27        test/gomory_hu_test \
    1628        test/graph_copy_test \
    1729        test/graph_test \
    1830        test/graph_utils_test \
     31        test/hao_orlin_test \
    1932        test/heap_test \
    2033        test/kruskal_test \
    2134        test/lgf_test \
    22         test/maps_test \
    23         test/random_test \
    24         test/path_test \
    25         test/test_tools_fail \
    26         test/test_tools_pass \
    27         test/time_measure_test \
     35        test/maps_test \
     36        test/matching_test \
     37        test/max_cardinality_search_test \
     38        test/max_clique_test \
     39        test/min_cost_arborescence_test \
     40        test/min_cost_flow_test \
     41        test/min_mean_cycle_test \
     42        test/nagamochi_ibaraki_test \
     43        test/path_test \
     44        test/planarity_test \
     45        test/preflow_test \
     46        test/radix_sort_test \
     47        test/random_test \
     48        test/suurballe_test \
     49        test/test_tools_fail \
     50        test/test_tools_pass \
     51        test/time_measure_test \
    2852        test/unionfind_test
     53
     54test_test_tools_pass_DEPENDENCIES = demo
     55
     56if HAVE_LP
     57check_PROGRAMS += test/lp_test
     58endif HAVE_LP
     59if HAVE_MIP
     60check_PROGRAMS += test/mip_test
     61endif HAVE_MIP
    2962
    3063TESTS += $(check_PROGRAMS)
    3164XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
    3265
     66test_adaptors_test_SOURCES = test/adaptors_test.cc
     67test_bellman_ford_test_SOURCES = test/bellman_ford_test.cc
    3368test_bfs_test_SOURCES = test/bfs_test.cc
     69test_circulation_test_SOURCES = test/circulation_test.cc
    3470test_counter_test_SOURCES = test/counter_test.cc
     71test_connectivity_test_SOURCES = test/connectivity_test.cc
    3572test_dfs_test_SOURCES = test/dfs_test.cc
    3673test_digraph_test_SOURCES = test/digraph_test.cc
    3774test_dijkstra_test_SOURCES = test/dijkstra_test.cc
    3875test_dim_test_SOURCES = test/dim_test.cc
     76test_edge_set_test_SOURCES = test/edge_set_test.cc
    3977test_error_test_SOURCES = test/error_test.cc
     78test_euler_test_SOURCES = test/euler_test.cc
     79test_fractional_matching_test_SOURCES = test/fractional_matching_test.cc
     80test_gomory_hu_test_SOURCES = test/gomory_hu_test.cc
    4081test_graph_copy_test_SOURCES = test/graph_copy_test.cc
    4182test_graph_test_SOURCES = test/graph_test.cc
    4283test_graph_utils_test_SOURCES = test/graph_utils_test.cc
     84test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
    4385test_heap_test_SOURCES = test/heap_test.cc
    4486test_kruskal_test_SOURCES = test/kruskal_test.cc
    4587test_lgf_test_SOURCES = test/lgf_test.cc
     88test_lp_test_SOURCES = test/lp_test.cc
    4689test_maps_test_SOURCES = test/maps_test.cc
     90test_mip_test_SOURCES = test/mip_test.cc
     91test_matching_test_SOURCES = test/matching_test.cc
     92test_max_cardinality_search_test_SOURCES = test/max_cardinality_search_test.cc
     93test_max_clique_test_SOURCES = test/max_clique_test.cc
     94test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc
     95test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc
     96test_min_mean_cycle_test_SOURCES = test/min_mean_cycle_test.cc
     97test_nagamochi_ibaraki_test_SOURCES = test/nagamochi_ibaraki_test.cc
    4798test_path_test_SOURCES = test/path_test.cc
     99test_planarity_test_SOURCES = test/planarity_test.cc
     100test_preflow_test_SOURCES = test/preflow_test.cc
     101test_radix_sort_test_SOURCES = test/radix_sort_test.cc
     102test_suurballe_test_SOURCES = test/suurballe_test.cc
    48103test_random_test_SOURCES = test/random_test.cc
    49104test_test_tools_fail_SOURCES = test/test_tools_fail.cc
Note: See TracChangeset for help on using the changeset viewer.