COIN-OR::LEMON - Graph Library

Ticket #243: dimacs-impr-1b3cd69531df.patch

File dimacs-impr-1b3cd69531df.patch, 6.4 KB (added by Peter Kovacs, 16 years ago)
  • lemon/dimacs.h

    # 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  
    5555
    5656  ///Discover the type of a DIMACS file
    5757
    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
    5959  ///and size info. The found data is returned in a special struct
    6060  ///that can be evaluated and passed to the appropriate reader
    6161  ///function.
     
    105105  ///   p min
    106106  /// \endcode
    107107  /// 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.
    111112  ///
    112113  /// 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".
    118119  ///
    119120  /// If the file type was previously evaluated by dimacsType(), then
    120121  /// the descriptor struct should be given by the \c dest parameter.
     
    260261  ///   p max
    261262  /// \endcode
    262263  /// 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.
    265266  ///
    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".
    272273  ///
    273274  /// If the file type was previously evaluated by dimacsType(), then
    274275  /// the descriptor struct should be given by the \c dest parameter.
     
    294295  ///   p sp
    295296  /// \endcode
    296297  /// 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
    298299  /// source node.
    299300  ///
    300301  /// If the file type was previously evaluated by dimacsType(), then
     
    315316  /// DIMACS capacitated digraph reader function.
    316317  ///
    317318  /// This function reads an arc capacitated digraph instance from
    318   /// DIMACS 'mat' or 'sp' format.
     319  /// DIMACS 'max' or 'sp' format.
    319320  /// 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.
    321323  ///
    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".
    328330  ///
    329331  /// If the file type was previously evaluated by dimacsType(), then
    330332  /// the descriptor struct should be given by the \c dest parameter.
     
    393395        break;
    394396      case 'n': // node definition line
    395397        break;
    396       case 'a': // arc (arc) definition line
     398      case 'a': // arc definition line
    397399        is >> i >> j;
    398400        getline(is, str);
    399401        _addArcEdge(g,nodes[i], nodes[j]);
  • tools/dimacs-solver.cc

    diff --git a/tools/dimacs-solver.cc b/tools/dimacs-solver.cc
    a b  
    115115void solve(ArgParser &ap, std::istream &is, std::ostream &os,
    116116           DimacsDescriptor &desc)
    117117{
    118   std::stringstream iss(ap["infty"]);
     118  std::stringstream iss(ap["infcap"]);
    119119  Value infty;
    120120  iss >> infty;
    121   if(is.fail())
     121  if(iss.fail())
    122122    {
    123123      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;
    126126      exit(1);
    127127    }
    128128 
     
    170170    .boolOption("ldouble","Use 'long double' for capacities, costs etc.")
    171171    .optionGroup("datatype","ldouble")
    172172    .onlyOneGroup("datatype")
    173     .stringOption("infcap","Value of 'very high' capacities","0")
     173    .stringOption("infcap","Value used for 'very high' capacities","0")
    174174    .run();
    175175
    176176  std::ifstream input;