# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1238438952 -7200
# Node ID 1b3cd69531df1b05daaeb1ee1bb9af0afc77f623
# Parent 5d1dc5085b442dcf54533aca3a689fc7abc49efc
Fixes and doc improvements for DIMACS tools (#243)
diff --git a/lemon/dimacs.h b/lemon/dimacs.h
|
a
|
b
|
|
| 55 | 55 | |
| 56 | 56 | ///Discover the type of a DIMACS file |
| 57 | 57 | |
| 58 | | ///It starts seeking the begining of the file for the problem type |
| | 58 | ///It starts seeking the beginning of the file for the problem type |
| 59 | 59 | ///and size info. The found data is returned in a special struct |
| 60 | 60 | ///that can be evaluated and passed to the appropriate reader |
| 61 | 61 | ///function. |
| … |
… |
|
| 105 | 105 | /// p min |
| 106 | 106 | /// \endcode |
| 107 | 107 | /// At the beginning, \c g is cleared by \c g.clear(). The supply |
| 108 | | /// amount of the nodes are written to \c supply (signed). The |
| 109 | | /// lower bounds, capacities and costs of the arcs are written to |
| 110 | | /// \c lower, \c capacity and \c cost. |
| | 108 | /// amount of the nodes are written to the \c supply node map |
| | 109 | /// (they are signed values). The lower bounds, capacities and costs |
| | 110 | /// of the arcs are written to the \c lower, \c capacity and \c cost |
| | 111 | /// arc maps. |
| 111 | 112 | /// |
| 112 | 113 | /// If the capacity of an arc is less than the lower bound, it will |
| 113 | | /// be set to "infinite" instead. The value if "infinite" is contolled |
| 114 | | /// by the \c infty parameter. If it is 0 (the default value), |
| 115 | | /// std::numeric_limits<Capacity>::infinity() will be used if available, |
| 116 | | /// std::numeric_limits<Capacity>::max() otherwise. If \c infty is set to |
| 117 | | /// a nonzero value, that value will be used as "infinite". |
| | 114 | /// be set to "infinite" instead. The actual value of "infinite" is |
| | 115 | /// contolled by the \c infty parameter. If it is 0 (the default value), |
| | 116 | /// \c std::numeric_limits<Capacity>::infinity() will be used if available, |
| | 117 | /// \c std::numeric_limits<Capacity>::max() otherwise. If \c infty is set to |
| | 118 | /// a non-zero value, that value will be used as "infinite". |
| 118 | 119 | /// |
| 119 | 120 | /// If the file type was previously evaluated by dimacsType(), then |
| 120 | 121 | /// the descriptor struct should be given by the \c dest parameter. |
| … |
… |
|
| 260 | 261 | /// p max |
| 261 | 262 | /// \endcode |
| 262 | 263 | /// At the beginning, \c g is cleared by \c g.clear(). The arc |
| 263 | | /// capacities are written to \c capacity and \c s and \c t are |
| 264 | | /// set to the source and the target nodes. |
| | 264 | /// capacities are written to the \c capacity arc map and \c s and |
| | 265 | /// \c t are set to the source and the target nodes. |
| 265 | 266 | /// |
| 266 | | /// If the capacity of an arc is less than 0, it will |
| 267 | | /// be set to "infinite" instead. The value if "infinite" is contolled |
| 268 | | /// by the \c infty parameter. If it is 0 (the default value), |
| 269 | | /// std::numeric_limits<Capacity>::infinity() will be used if available, |
| 270 | | /// std::numeric_limits<Capacity>::max() otherwise. If \c infty is set to |
| 271 | | /// a nonzero value, that value will be used as "infinite". |
| | 267 | /// If the capacity of an arc is negative, it will |
| | 268 | /// be set to "infinite" instead. The actual value of "infinite" is |
| | 269 | /// contolled by the \c infty parameter. If it is 0 (the default value), |
| | 270 | /// \c std::numeric_limits<Capacity>::infinity() will be used if available, |
| | 271 | /// \c std::numeric_limits<Capacity>::max() otherwise. If \c infty is set to |
| | 272 | /// a non-zero value, that value will be used as "infinite". |
| 272 | 273 | /// |
| 273 | 274 | /// If the file type was previously evaluated by dimacsType(), then |
| 274 | 275 | /// the descriptor struct should be given by the \c dest parameter. |
| … |
… |
|
| 294 | 295 | /// p sp |
| 295 | 296 | /// \endcode |
| 296 | 297 | /// At the beginning, \c g is cleared by \c g.clear(). The arc |
| 297 | | /// lengths are written to \c length and \c s is set to the |
| | 298 | /// lengths are written to the \c length arc map and \c s is set to the |
| 298 | 299 | /// source node. |
| 299 | 300 | /// |
| 300 | 301 | /// If the file type was previously evaluated by dimacsType(), then |
| … |
… |
|
| 315 | 316 | /// DIMACS capacitated digraph reader function. |
| 316 | 317 | /// |
| 317 | 318 | /// This function reads an arc capacitated digraph instance from |
| 318 | | /// DIMACS 'mat' or 'sp' format. |
| | 319 | /// DIMACS 'max' or 'sp' format. |
| 319 | 320 | /// At the beginning, \c g is cleared by \c g.clear() |
| 320 | | /// and the arc capacities/lengths are written to \c capacity. |
| | 321 | /// and the arc capacities/lengths are written to the \c capacity |
| | 322 | /// arc map. |
| 321 | 323 | /// |
| 322 | | /// If the capacity of an arc is less than 0, it will |
| 323 | | /// be set to "infinite" instead. The value if "infinite" is contolled |
| 324 | | /// by the \c infty parameter. If it is 0 (the default value), |
| 325 | | /// std::numeric_limits<Capacity>::infinity() will be used if available, |
| 326 | | /// std::numeric_limits<Capacity>::max() otherwise. If \c infty is set to |
| 327 | | /// a nonzero value, that value will be used as "infinite". |
| | 324 | /// If the capacity of an arc is negative, it will |
| | 325 | /// be set to "infinite" instead. The actual value of "infinite" is |
| | 326 | /// contolled by the \c infty parameter. If it is 0 (the default value), |
| | 327 | /// \c std::numeric_limits<Capacity>::infinity() will be used if available, |
| | 328 | /// \c std::numeric_limits<Capacity>::max() otherwise. If \c infty is set to |
| | 329 | /// a non-zero value, that value will be used as "infinite". |
| 328 | 330 | /// |
| 329 | 331 | /// If the file type was previously evaluated by dimacsType(), then |
| 330 | 332 | /// the descriptor struct should be given by the \c dest parameter. |
| … |
… |
|
| 393 | 395 | break; |
| 394 | 396 | case 'n': // node definition line |
| 395 | 397 | break; |
| 396 | | case 'a': // arc (arc) definition line |
| | 398 | case 'a': // arc definition line |
| 397 | 399 | is >> i >> j; |
| 398 | 400 | getline(is, str); |
| 399 | 401 | _addArcEdge(g,nodes[i], nodes[j]); |
diff --git a/tools/dimacs-solver.cc b/tools/dimacs-solver.cc
|
a
|
b
|
|
| 115 | 115 | void solve(ArgParser &ap, std::istream &is, std::ostream &os, |
| 116 | 116 | DimacsDescriptor &desc) |
| 117 | 117 | { |
| 118 | | std::stringstream iss(ap["infty"]); |
| | 118 | std::stringstream iss(ap["infcap"]); |
| 119 | 119 | Value infty; |
| 120 | 120 | iss >> infty; |
| 121 | | if(is.fail()) |
| | 121 | if(iss.fail()) |
| 122 | 122 | { |
| 123 | 123 | std::cerr << "Cannot interpret '" |
| 124 | | << static_cast<std::string>(ap["infty"]) << "' as infinite" |
| 125 | | << std::endl; |
| | 124 | << static_cast<std::string>(ap["infcap"]) << "' as infinite" |
| | 125 | << std::endl; |
| 126 | 126 | exit(1); |
| 127 | 127 | } |
| 128 | 128 | |
| … |
… |
|
| 170 | 170 | .boolOption("ldouble","Use 'long double' for capacities, costs etc.") |
| 171 | 171 | .optionGroup("datatype","ldouble") |
| 172 | 172 | .onlyOneGroup("datatype") |
| 173 | | .stringOption("infcap","Value of 'very high' capacities","0") |
| | 173 | .stringOption("infcap","Value used for 'very high' capacities","0") |
| 174 | 174 | .run(); |
| 175 | 175 | |
| 176 | 176 | std::ifstream input; |