Changeset 1374:00769a5f0f5d in lemon
- Timestamp:
- 09/19/17 15:19:48 (7 years ago)
- Branch:
- 1.2
- Parents:
- 1365:1e87c18cf65e (diff), 1373:332627dd249e (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:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/dimacs.h
r956 r1374 26 26 #include <lemon/maps.h> 27 27 #include <lemon/error.h> 28 28 29 /// \ingroup dimacs_group 29 30 /// \file … … 123 124 /// 124 125 /// If the file type was previously evaluated by dimacsType(), then 125 /// the descriptor struct should be given by the \c des tparameter.126 /// the descriptor struct should be given by the \c desc parameter. 126 127 template <typename Digraph, typename LowerMap, 127 128 typename CapacityMap, typename CostMap, … … 277 278 /// 278 279 /// If the file type was previously evaluated by dimacsType(), then 279 /// the descriptor struct should be given by the \c des tparameter.280 /// the descriptor struct should be given by the \c desc parameter. 280 281 template<typename Digraph, typename CapacityMap> 281 282 void readDimacsMax(std::istream& is, … … 304 305 /// 305 306 /// If the file type was previously evaluated by dimacsType(), then 306 /// the descriptor struct should be given by the \c des tparameter.307 /// the descriptor struct should be given by the \c desc parameter. 307 308 template<typename Digraph, typename LengthMap> 308 309 void readDimacsSp(std::istream& is, … … 335 336 /// 336 337 /// If the file type was previously evaluated by dimacsType(), then 337 /// the descriptor struct should be given by the \c des tparameter.338 /// the descriptor struct should be given by the \c desc parameter. 338 339 template<typename Digraph, typename CapacityMap> 339 340 void readDimacsCap(std::istream& is, … … 344 345 typename Digraph::Node u,v; 345 346 if(desc.type==DimacsDescriptor::NONE) desc=dimacsType(is); 346 if(desc.type!=DimacsDescriptor::MAX ||desc.type!=DimacsDescriptor::SP)347 if(desc.type!=DimacsDescriptor::MAX && desc.type!=DimacsDescriptor::SP) 347 348 throw FormatError("Problem type mismatch"); 348 349 _readDimacs(is, g, capacity, u, v, infty, desc); … … 375 376 /// 376 377 /// If the file type was previously evaluated by dimacsType(), then 377 /// the descriptor struct should be given by the \c des tparameter.378 /// the descriptor struct should be given by the \c desc parameter. 378 379 template<typename Graph> 379 380 void readDimacsMat(std::istream& is, Graph &g, -
lemon/dimacs.h
r1373 r1374 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 39 39 struct DimacsDescriptor 40 40 { 41 ///File type enum 42 enum Type 43 { 44 NONE, MIN, MAX, SP, MAT 45 }; 41 ///\brief DIMACS file type enum 42 /// 43 ///DIMACS file type enum. 44 enum Type { 45 NONE, ///< Undefined type. 46 MIN, ///< DIMACS file type for minimum cost flow problems. 47 MAX, ///< DIMACS file type for maximum flow problems. 48 SP, ///< DIMACS file type for shostest path problems. 49 MAT ///< DIMACS file type for plain graphs and matching problems. 50 }; 46 51 ///The file type 47 52 Type type; … … 51 56 int edgeNum; 52 57 int lineShift; 53 /// Constructor. Sets the type toNONE.58 ///Constructor. It sets the type to \c NONE. 54 59 DimacsDescriptor() : type(NONE) {} 55 60 }; … … 57 62 ///Discover the type of a DIMACS file 58 63 59 /// It starts seeking the beginning of the file for the problem type60 /// and size info. The found data is returned in a special struct61 /// that can be evaluated and passed to the appropriate reader62 /// function.64 ///This function starts seeking the beginning of the given file for the 65 ///problem type and size info. 66 ///The found data is returned in a special struct that can be evaluated 67 ///and passed to the appropriate reader function. 63 68 DimacsDescriptor dimacsType(std::istream& is) 64 69 { … … 98 103 99 104 100 101 /// DIMACS minimum cost flow reader function. 105 /// \brief DIMACS minimum cost flow reader function. 102 106 /// 103 107 /// This function reads a minimum cost flow instance from DIMACS format, … … 210 214 std::numeric_limits<Capacity>::infinity() : 211 215 std::numeric_limits<Capacity>::max(); 212 216 213 217 while (is >> c) { 214 218 switch (c) { … … 235 239 e = g.addArc(nodes[i], nodes[j]); 236 240 capacity.set(e, _cap); 237 } 241 } 238 242 else if (desc.type==DimacsDescriptor::MAX) { 239 243 is >> i >> j >> _cap; … … 255 259 } 256 260 257 /// DIMACS maximum flow reader function.261 /// \brief DIMACS maximum flow reader function. 258 262 /// 259 263 /// This function reads a maximum flow instance from DIMACS format, … … 289 293 } 290 294 291 /// DIMACS shortest path reader function.295 /// \brief DIMACS shortest path reader function. 292 296 /// 293 297 /// This function reads a shortest path instance from DIMACS format, … … 315 319 } 316 320 317 /// DIMACS capacitated digraph reader function.321 /// \brief DIMACS capacitated digraph reader function. 318 322 /// 319 323 /// This function reads an arc capacitated digraph instance from … … 360 364 g.addArc(s,t); 361 365 } 362 363 /// DIMACS plain (di)graph reader function.364 /// 365 /// This function reads a (di)graph without any designated nodes and366 /// maps from DIMACS format, i.e. from DIMACS files having a line367 /// starting with366 367 /// \brief DIMACS plain (di)graph reader function. 368 /// 369 /// This function reads a plain (di)graph without any designated nodes 370 /// and maps (e.g. a matching instance) from DIMACS format, i.e. from 371 /// DIMACS files having a line starting with 368 372 /// \code 369 373 /// p mat … … 390 394 nodes[k] = g.addNode(); 391 395 } 392 396 393 397 while (is >> c) { 394 398 switch (c) {
Note: See TracChangeset
for help on using the changeset viewer.