Changeset 1070:c8c8801db0a4 in lemon
- Timestamp:
- 08/04/11 21:33:17 (13 years ago)
- Branch:
- 1.2
- Parents:
- 1065:b522385b2a0d (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
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/lgf.dox
r463 r1069 64 64 \endcode 65 65 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 butthe \c "label" map is not obligatory here. The following lines69 describe the arcs. The first two tokens of each line are 70 the sourceand the target node of the arc, respectively, then come the map66 The \c \@arcs section is very similar to the \c \@nodes section, it 67 again starts with a header line describing the names of the maps, but 68 the \c "label" map is not obligatory here. The following lines 69 describe the arcs. The first two tokens of each line are the source 70 and the target node of the arc, respectively, then come the map 71 71 values. The source and target tokens must be node labels. 72 72 … … 79 79 \endcode 80 80 81 If there is no map in the \c \@arcs section at all, then it must be 82 indicated 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 81 92 The \c \@edges is just a synonym of \c \@arcs. The \@arcs section can 82 93 also store the edge set of an undirected graph. In such case there is 83 94 a conventional method for store arc maps in the file, if two columns 84 ha sthe same caption with \c '+' and \c '-' prefix, then these columns95 have the same caption with \c '+' and \c '-' prefix, then these columns 85 96 can be regarded as the values of an arc map. 86 97 -
doc/lgf.dox
r1067 r1069 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/lgf_reader.h
r956 r1070 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-201 05 * Copyright (C) 2003-2011 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 965 965 int index = 0; 966 966 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 } 967 974 if (maps.find(map) != maps.end()) { 968 975 std::ostringstream msg; … … 1835 1842 int index = 0; 1836 1843 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 } 1837 1851 if (maps.find(map) != maps.end()) { 1838 1852 std::ostringstream msg; -
lemon/lgf_reader.h
r1067 r1070 102 102 }; 103 103 104 template <typename _G raph, bool _dir, typename _Map,104 template <typename _GR, bool _dir, typename _Map, 105 105 typename _Converter = DefaultConverter<typename _Map::Value> > 106 class GraphArcMapStorage : public MapStorageBase<typename _G raph::Edge> {106 class GraphArcMapStorage : public MapStorageBase<typename _GR::Edge> { 107 107 public: 108 108 typedef _Map Map; 109 109 typedef _Converter Converter; 110 typedef _G raph Graph;111 typedef typename G raph::Edge Item;110 typedef _GR GR; 111 typedef typename GR::Edge Item; 112 112 static const bool dir = _dir; 113 113 114 114 private: 115 const G raph& _graph;115 const GR& _graph; 116 116 Map& _map; 117 117 Converter _converter; 118 118 119 119 public: 120 GraphArcMapStorage(const G raph& graph, Map& map,120 GraphArcMapStorage(const GR& graph, Map& map, 121 121 const Converter& converter = Converter()) 122 122 : _graph(graph), _map(map), _converter(converter) {} … … 174 174 }; 175 175 176 template <typename G raph>176 template <typename GR> 177 177 struct GraphArcLookUpConverter { 178 const G raph& _graph;179 const std::map<std::string, typename G raph::Edge>& _map;180 181 GraphArcLookUpConverter(const G raph& graph,178 const GR& _graph; 179 const std::map<std::string, typename GR::Edge>& _map; 180 181 GraphArcLookUpConverter(const GR& graph, 182 182 const std::map<std::string, 183 typename G raph::Edge>& map)183 typename GR::Edge>& map) 184 184 : _graph(graph), _map(map) {} 185 185 186 typename G raph::Arc operator()(const std::string& str) {186 typename GR::Arc operator()(const std::string& str) { 187 187 if (str.empty() || (str[0] != '+' && str[0] != '-')) { 188 188 throw FormatError("Item must start with '+' or '-'"); 189 189 } 190 typename std::map<std::string, typename G raph::Edge>190 typename std::map<std::string, typename GR::Edge> 191 191 ::const_iterator it = _map.find(str.substr(1)); 192 192 if (it == _map.end()) { … … 388 388 } 389 389 390 template <typename D igraph>390 template <typename DGR> 391 391 class DigraphReader; 392 392 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); 400 399 401 400 /// \ingroup lemon_io … … 420 419 /// 421 420 ///\code 422 /// DigraphReader<D igraph>(digraph, std::cin).421 /// DigraphReader<DGR>(digraph, std::cin). 423 422 /// nodeMap("coordinates", coord_map). 424 423 /// arcMap("capacity", cap_map). … … 429 428 ///\endcode 430 429 /// 431 /// By default the reader uses the first section in the file of the430 /// By default, the reader uses the first section in the file of the 432 431 /// proper type. If a section has an optional name, then it can be 433 432 /// selected for reading by giving an optional name parameter to the … … 449 448 /// a single pass, because the arcs are not constructed when the node 450 449 /// maps are read. 451 template <typename _Digraph>450 template <typename DGR> 452 451 class DigraphReader { 453 452 public: 454 453 455 typedef _Digraph Digraph; 456 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 454 typedef DGR Digraph; 457 455 458 456 private: 459 457 458 TEMPLATE_DIGRAPH_TYPEDEFS(DGR); 460 459 461 460 std::istream* _is; … … 463 462 std::string _filename; 464 463 465 D igraph& _digraph;464 DGR& _digraph; 466 465 467 466 std::string _nodes_caption; … … 501 500 /// Construct a directed graph reader, which reads from the given 502 501 /// input stream. 503 DigraphReader(D igraph& digraph, std::istream& is = std::cin)502 DigraphReader(DGR& digraph, std::istream& is = std::cin) 504 503 : _is(&is), local_is(false), _digraph(digraph), 505 504 _use_nodes(false), _use_arcs(false), … … 510 509 /// Construct a directed graph reader, which reads from the given 511 510 /// file. 512 DigraphReader(D igraph& digraph, const std::string& fn)511 DigraphReader(DGR& digraph, const std::string& fn) 513 512 : _is(new std::ifstream(fn.c_str())), local_is(true), 514 513 _filename(fn), _digraph(digraph), … … 525 524 /// Construct a directed graph reader, which reads from the given 526 525 /// file. 527 DigraphReader(D igraph& digraph, const char* fn)526 DigraphReader(DGR& digraph, const char* fn) 528 527 : _is(new std::ifstream(fn)), local_is(true), 529 528 _filename(fn), _digraph(digraph), … … 561 560 private: 562 561 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); 570 569 571 570 DigraphReader(DigraphReader& other) … … 594 593 public: 595 594 596 /// \name Reading rules595 /// \name Reading Rules 597 596 /// @{ 598 597 … … 699 698 /// @} 700 699 701 /// \name Select section by name700 /// \name Select Section by Name 702 701 /// @{ 703 702 … … 728 727 /// @} 729 728 730 /// \name Using previously constructed node or arc set729 /// \name Using Previously Constructed Node or Arc Set 731 730 /// @{ 732 731 … … 848 847 readLine(); 849 848 } 850 line.putback(c); 849 if (readSuccess()) { 850 line.putback(c); 851 } 851 852 } 852 853 … … 1122 1123 public: 1123 1124 1124 /// \name Execution of the reader1125 /// \name Execution of the Reader 1125 1126 /// @{ 1126 1127 … … 1195 1196 }; 1196 1197 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 1197 1235 /// \brief Return a \ref DigraphReader class 1198 1236 /// 1199 1237 /// This function just returns a \ref DigraphReader class. 1200 1238 /// \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); 1204 1243 return tmp; 1205 1244 } … … 1209 1248 /// This function just returns a \ref DigraphReader class. 1210 1249 /// \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); 1215 1254 return tmp; 1216 1255 } 1217 1256 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> 1229 1258 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); 1238 1266 1239 1267 /// \ingroup lemon_io … … 1252 1280 /// arc map. Similarly, an attribute can be read into an arc, if 1253 1281 /// it's value is an edge label prefixed with \c '+' or \c '-'. 1254 template <typename _Graph>1282 template <typename GR> 1255 1283 class GraphReader { 1256 1284 public: 1257 1285 1258 typedef _Graph Graph; 1259 TEMPLATE_GRAPH_TYPEDEFS(Graph); 1286 typedef GR Graph; 1260 1287 1261 1288 private: 1289 1290 TEMPLATE_GRAPH_TYPEDEFS(GR); 1262 1291 1263 1292 std::istream* _is; … … 1265 1294 std::string _filename; 1266 1295 1267 G raph& _graph;1296 GR& _graph; 1268 1297 1269 1298 std::string _nodes_caption; … … 1303 1332 /// Construct an undirected graph reader, which reads from the given 1304 1333 /// input stream. 1305 GraphReader(G raph& graph, std::istream& is = std::cin)1334 GraphReader(GR& graph, std::istream& is = std::cin) 1306 1335 : _is(&is), local_is(false), _graph(graph), 1307 1336 _use_nodes(false), _use_edges(false), … … 1312 1341 /// Construct an undirected graph reader, which reads from the given 1313 1342 /// file. 1314 GraphReader(G raph& graph, const std::string& fn)1343 GraphReader(GR& graph, const std::string& fn) 1315 1344 : _is(new std::ifstream(fn.c_str())), local_is(true), 1316 1345 _filename(fn), _graph(graph), … … 1327 1356 /// Construct an undirected graph reader, which reads from the given 1328 1357 /// file. 1329 GraphReader(G raph& graph, const char* fn)1358 GraphReader(GR& graph, const char* fn) 1330 1359 : _is(new std::ifstream(fn)), local_is(true), 1331 1360 _filename(fn), _graph(graph), … … 1362 1391 1363 1392 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); 1370 1399 1371 1400 GraphReader(GraphReader& other) … … 1394 1423 public: 1395 1424 1396 /// \name Reading rules1425 /// \name Reading Rules 1397 1426 /// @{ 1398 1427 … … 1459 1488 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage)); 1460 1489 _reader_bits::MapStorageBase<Edge>* backward_storage = 1461 new _reader_bits::GraphArcMapStorage<G raph, false, Map>(_graph, map);1490 new _reader_bits::GraphArcMapStorage<GR, false, Map>(_graph, map); 1462 1491 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage)); 1463 1492 return *this; … … 1473 1502 checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>(); 1474 1503 _reader_bits::MapStorageBase<Edge>* forward_storage = 1475 new _reader_bits::GraphArcMapStorage<G raph, true, Map, Converter>1504 new _reader_bits::GraphArcMapStorage<GR, true, Map, Converter> 1476 1505 (_graph, map, converter); 1477 1506 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage)); 1478 1507 _reader_bits::MapStorageBase<Edge>* backward_storage = 1479 new _reader_bits::GraphArcMapStorage<G raph, false, Map, Converter>1508 new _reader_bits::GraphArcMapStorage<GR, false, Map, Converter> 1480 1509 (_graph, map, converter); 1481 1510 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage)); … … 1535 1564 /// Add an arc reading rule to reader. 1536 1565 GraphReader& arc(const std::string& caption, Arc& arc) { 1537 typedef _reader_bits::GraphArcLookUpConverter<G raph> Converter;1566 typedef _reader_bits::GraphArcLookUpConverter<GR> Converter; 1538 1567 Converter converter(_graph, _edge_index); 1539 1568 _reader_bits::ValueStorageBase* storage = … … 1545 1574 /// @} 1546 1575 1547 /// \name Select section by name1576 /// \name Select Section by Name 1548 1577 /// @{ 1549 1578 … … 1574 1603 /// @} 1575 1604 1576 /// \name Using previously constructed node or edge set1605 /// \name Using Previously Constructed Node or Edge Set 1577 1606 /// @{ 1578 1607 … … 1695 1724 readLine(); 1696 1725 } 1697 line.putback(c); 1726 if (readSuccess()) { 1727 line.putback(c); 1728 } 1698 1729 } 1699 1730 … … 1969 2000 public: 1970 2001 1971 /// \name Execution of the reader2002 /// \name Execution of the Reader 1972 2003 /// @{ 1973 2004 … … 2043 2074 }; 2044 2075 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 2045 2109 /// \brief Return a \ref GraphReader class 2046 2110 /// 2047 2111 /// This function just returns a \ref GraphReader class. 2048 2112 /// \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); 2052 2117 return tmp; 2053 2118 } … … 2057 2122 /// This function just returns a \ref GraphReader class. 2058 2123 /// \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); 2072 2128 return tmp; 2073 2129 } … … 2168 2224 public: 2169 2225 2170 /// \name Section readers2226 /// \name Section Readers 2171 2227 /// @{ 2172 2228 … … 2180 2236 /// whitespaces are trimmed from each processed string. 2181 2237 /// 2182 /// For example let's see a section, which contain several2238 /// For example, let's see a section, which contain several 2183 2239 /// integers, which should be inserted into a vector. 2184 2240 ///\code … … 2259 2315 readLine(); 2260 2316 } 2261 line.putback(c); 2317 if (readSuccess()) { 2318 line.putback(c); 2319 } 2262 2320 } 2263 2321 … … 2265 2323 2266 2324 2267 /// \name Execution of the reader2325 /// \name Execution of the Reader 2268 2326 /// @{ 2269 2327 … … 2324 2382 }; 2325 2383 2384 /// \ingroup lemon_io 2385 /// 2326 2386 /// \brief Return a \ref SectionReader class 2327 2387 /// 2328 2388 /// This function just returns a \ref SectionReader class. 2389 /// 2390 /// Please see SectionReader documentation about the custom section 2391 /// input. 2392 /// 2329 2393 /// \relates SectionReader 2394 /// \sa sectionReader(const std::string& fn) 2395 /// \sa sectionReader(const char *fn) 2330 2396 inline SectionReader sectionReader(std::istream& is) { 2331 2397 SectionReader tmp(is); … … 2337 2403 /// This function just returns a \ref SectionReader class. 2338 2404 /// \relates SectionReader 2405 /// \sa sectionReader(std::istream& is) 2339 2406 inline SectionReader sectionReader(const std::string& fn) { 2340 2407 SectionReader tmp(fn); … … 2346 2413 /// This function just returns a \ref SectionReader class. 2347 2414 /// \relates SectionReader 2415 /// \sa sectionReader(std::istream& is) 2348 2416 inline SectionReader sectionReader(const char* fn) { 2349 2417 SectionReader tmp(fn); … … 2447 2515 2448 2516 2449 /// \name Node sections2517 /// \name Node Sections 2450 2518 /// @{ 2451 2519 … … 2473 2541 /// @} 2474 2542 2475 /// \name Arc/Edge sections2543 /// \name Arc/Edge Sections 2476 2544 /// @{ 2477 2545 … … 2531 2599 /// @} 2532 2600 2533 /// \name Attribute sections2601 /// \name Attribute Sections 2534 2602 /// @{ 2535 2603 … … 2557 2625 /// @} 2558 2626 2559 /// \name Extra sections2627 /// \name Extra Sections 2560 2628 /// @{ 2561 2629 … … 2600 2668 readLine(); 2601 2669 } 2602 line.putback(c); 2670 if (readSuccess()) { 2671 line.putback(c); 2672 } 2603 2673 } 2604 2674 … … 2631 2701 public: 2632 2702 2633 /// \name Execution of the contents reader2703 /// \name Execution of the Contents Reader 2634 2704 /// @{ 2635 2705 -
test/CMakeLists.txt
r1065 r1070 34 34 heap_test 35 35 kruskal_test 36 lgf_test 36 37 maps_test 37 38 matching_test -
test/CMakeLists.txt
r1067 r1070 1 1 INCLUDE_DIRECTORIES( 2 ${ CMAKE_SOURCE_DIR}2 ${PROJECT_SOURCE_DIR} 3 3 ${PROJECT_BINARY_DIR} 4 4 ) 5 5 6 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon) 6 LINK_DIRECTORIES( 7 ${PROJECT_BINARY_DIR}/lemon 8 ) 9 10 SET(TEST_WITH_VALGRIND "NO" CACHE STRING 11 "Run the test with valgrind (YES/NO).") 12 SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.") 7 13 8 14 SET(TESTS 15 adaptors_test 16 bellman_ford_test 9 17 bfs_test 18 circulation_test 19 connectivity_test 10 20 counter_test 11 21 dfs_test … … 13 23 dijkstra_test 14 24 dim_test 25 edge_set_test 15 26 error_test 27 euler_test 28 fractional_matching_test 29 gomory_hu_test 16 30 graph_copy_test 17 31 graph_test 18 32 graph_utils_test 33 hao_orlin_test 19 34 heap_test 20 35 kruskal_test 21 36 lgf_test 22 37 maps_test 38 matching_test 39 min_cost_arborescence_test 40 min_cost_flow_test 41 min_mean_cycle_test 42 path_test 43 planarity_test 44 preflow_test 45 radix_sort_test 23 46 random_test 24 path_test47 suurballe_test 25 48 time_measure_test 26 unionfind_test) 49 unionfind_test 50 ) 51 52 IF(LEMON_HAVE_LP) 53 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") 54 ADD_EXECUTABLE(lp_test lp_test.cc) 55 ELSE() 56 ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc) 57 ENDIF() 58 59 SET(LP_TEST_LIBS lemon) 60 61 IF(LEMON_HAVE_GLPK) 62 SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES}) 63 ENDIF() 64 IF(LEMON_HAVE_CPLEX) 65 SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES}) 66 ENDIF() 67 IF(LEMON_HAVE_CLP) 68 SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES}) 69 ENDIF() 70 71 TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS}) 72 ADD_TEST(lp_test lp_test) 73 ADD_DEPENDENCIES(check lp_test) 74 75 IF(WIN32 AND LEMON_HAVE_GLPK) 76 GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) 77 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 78 ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD 79 COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} 80 COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} 81 COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} 82 ) 83 ENDIF() 84 85 IF(WIN32 AND LEMON_HAVE_CPLEX) 86 GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) 87 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 88 ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD 89 COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} 90 ) 91 ENDIF() 92 ENDIF() 93 94 IF(LEMON_HAVE_MIP) 95 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") 96 ADD_EXECUTABLE(mip_test mip_test.cc) 97 ELSE() 98 ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc) 99 ENDIF() 100 101 SET(MIP_TEST_LIBS lemon) 102 103 IF(LEMON_HAVE_GLPK) 104 SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES}) 105 ENDIF() 106 IF(LEMON_HAVE_CPLEX) 107 SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES}) 108 ENDIF() 109 IF(LEMON_HAVE_CBC) 110 SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES}) 111 ENDIF() 112 113 TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS}) 114 ADD_TEST(mip_test mip_test) 115 ADD_DEPENDENCIES(check mip_test) 116 117 IF(WIN32 AND LEMON_HAVE_GLPK) 118 GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) 119 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 120 ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD 121 COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} 122 COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} 123 COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} 124 ) 125 ENDIF() 126 127 IF(WIN32 AND LEMON_HAVE_CPLEX) 128 GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) 129 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 130 ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD 131 COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} 132 ) 133 ENDIF() 134 ENDIF() 27 135 28 136 FOREACH(TEST_NAME ${TESTS}) 29 ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc) 137 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") 138 ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc) 139 ELSE() 140 ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc) 141 ENDIF() 30 142 TARGET_LINK_LIBRARIES(${TEST_NAME} lemon) 31 ADD_TEST(${TEST_NAME} ${TEST_NAME}) 32 ENDFOREACH(TEST_NAME) 143 IF(TEST_WITH_VALGRIND) 144 ADD_TEST(${TEST_NAME} 145 valgrind --error-exitcode=1 ${VALGRIND_FLAGS} 146 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} ) 147 ELSE() 148 ADD_TEST(${TEST_NAME} ${TEST_NAME}) 149 ENDIF() 150 ADD_DEPENDENCIES(check ${TEST_NAME}) 151 ENDFOREACH() -
test/Makefile.am
r953 r1070 32 32 test/heap_test \ 33 33 test/kruskal_test \ 34 test/lgf_test \ 34 35 test/maps_test \ 35 36 test/matching_test \ … … 78 79 test_graph_test_SOURCES = test/graph_test.cc 79 80 test_graph_utils_test_SOURCES = test/graph_utils_test.cc 81 test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc 80 82 test_heap_test_SOURCES = test/heap_test.cc 81 83 test_kruskal_test_SOURCES = test/kruskal_test.cc 82 test_ hao_orlin_test_SOURCES = test/hao_orlin_test.cc84 test_lgf_test_SOURCES = test/lgf_test.cc 83 85 test_lp_test_SOURCES = test/lp_test.cc 84 86 test_maps_test_SOURCES = test/maps_test.cc -
test/Makefile.am
r1067 r1070 1 if USE_VALGRIND 2 TESTS_ENVIRONMENT=$(top_srcdir)/scripts/valgrind-wrapper.sh 3 endif 4 1 5 EXTRA_DIST += \ 2 6 test/CMakeLists.txt … … 4 8 noinst_HEADERS += \ 5 9 test/graph_test.h \ 6 10 test/test_tools.h 7 11 8 12 check_PROGRAMS += \ 13 test/adaptors_test \ 14 test/bellman_ford_test \ 9 15 test/bfs_test \ 10 test/counter_test \ 16 test/circulation_test \ 17 test/connectivity_test \ 18 test/counter_test \ 11 19 test/dfs_test \ 12 20 test/digraph_test \ 13 21 test/dijkstra_test \ 14 test/dim_test \ 22 test/dim_test \ 23 test/edge_set_test \ 15 24 test/error_test \ 25 test/euler_test \ 26 test/fractional_matching_test \ 27 test/gomory_hu_test \ 16 28 test/graph_copy_test \ 17 29 test/graph_test \ 18 30 test/graph_utils_test \ 31 test/hao_orlin_test \ 19 32 test/heap_test \ 20 33 test/kruskal_test \ 21 34 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/min_cost_arborescence_test \ 38 test/min_cost_flow_test \ 39 test/min_mean_cycle_test \ 40 test/path_test \ 41 test/planarity_test \ 42 test/preflow_test \ 43 test/radix_sort_test \ 44 test/random_test \ 45 test/suurballe_test \ 46 test/test_tools_fail \ 47 test/test_tools_pass \ 48 test/time_measure_test \ 28 49 test/unionfind_test 50 51 test_test_tools_pass_DEPENDENCIES = demo 52 53 if HAVE_LP 54 check_PROGRAMS += test/lp_test 55 endif HAVE_LP 56 if HAVE_MIP 57 check_PROGRAMS += test/mip_test 58 endif HAVE_MIP 29 59 30 60 TESTS += $(check_PROGRAMS) 31 61 XFAIL_TESTS += test/test_tools_fail$(EXEEXT) 32 62 63 test_adaptors_test_SOURCES = test/adaptors_test.cc 64 test_bellman_ford_test_SOURCES = test/bellman_ford_test.cc 33 65 test_bfs_test_SOURCES = test/bfs_test.cc 66 test_circulation_test_SOURCES = test/circulation_test.cc 34 67 test_counter_test_SOURCES = test/counter_test.cc 68 test_connectivity_test_SOURCES = test/connectivity_test.cc 35 69 test_dfs_test_SOURCES = test/dfs_test.cc 36 70 test_digraph_test_SOURCES = test/digraph_test.cc 37 71 test_dijkstra_test_SOURCES = test/dijkstra_test.cc 38 72 test_dim_test_SOURCES = test/dim_test.cc 73 test_edge_set_test_SOURCES = test/edge_set_test.cc 39 74 test_error_test_SOURCES = test/error_test.cc 75 test_euler_test_SOURCES = test/euler_test.cc 76 test_fractional_matching_test_SOURCES = test/fractional_matching_test.cc 77 test_gomory_hu_test_SOURCES = test/gomory_hu_test.cc 40 78 test_graph_copy_test_SOURCES = test/graph_copy_test.cc 41 79 test_graph_test_SOURCES = test/graph_test.cc 42 80 test_graph_utils_test_SOURCES = test/graph_utils_test.cc 81 test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc 43 82 test_heap_test_SOURCES = test/heap_test.cc 44 83 test_kruskal_test_SOURCES = test/kruskal_test.cc 45 84 test_lgf_test_SOURCES = test/lgf_test.cc 85 test_lp_test_SOURCES = test/lp_test.cc 46 86 test_maps_test_SOURCES = test/maps_test.cc 87 test_mip_test_SOURCES = test/mip_test.cc 88 test_matching_test_SOURCES = test/matching_test.cc 89 test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc 90 test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc 91 test_min_mean_cycle_test_SOURCES = test/min_mean_cycle_test.cc 47 92 test_path_test_SOURCES = test/path_test.cc 93 test_planarity_test_SOURCES = test/planarity_test.cc 94 test_preflow_test_SOURCES = test/preflow_test.cc 95 test_radix_sort_test_SOURCES = test/radix_sort_test.cc 96 test_suurballe_test_SOURCES = test/suurballe_test.cc 48 97 test_random_test_SOURCES = test/random_test.cc 49 98 test_test_tools_fail_SOURCES = test/test_tools_fail.cc
Note: See TracChangeset
for help on using the changeset viewer.