tools/dimacs-solver.cc
changeset 596 ba659d676331
parent 573 28b154307c0d
child 608 6e0525ec5355
child 649 a79ef774fae1
equal deleted inserted replaced
0:77697ce85cca 1:2a25b5457ab5
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 ///\ingroup tools
    19 ///\ingroup tools
    20 ///\file
    20 ///\file
    21 ///\brief DIMACS to LGF converter.
    21 ///\brief DIMACS problem solver.
    22 ///
    22 ///
    23 /// This program converts various DIMACS formats to the LEMON Digraph Format
    23 /// This program solves various problems given in DIMACS format.
    24 /// (LGF).
       
    25 ///
    24 ///
    26 /// See
    25 /// See
    27 /// \verbatim
    26 /// \verbatim
    28 ///  dimacs-solver --help
    27 ///  dimacs-solver --help
    29 /// \endverbatim
    28 /// \endverbatim
   118 {
   117 {
   119   switch(desc.type)
   118   switch(desc.type)
   120     {
   119     {
   121     case DimacsDescriptor::MIN:
   120     case DimacsDescriptor::MIN:
   122       std::cerr <<
   121       std::cerr <<
   123         "\n\n Sorry, the min. cost flow solver is not yet available.\n"
   122         "\n\n Sorry, the min. cost flow solver is not yet available.\n";
   124                 << std::endl;
       
   125       break;
   123       break;
   126     case DimacsDescriptor::MAX:
   124     case DimacsDescriptor::MAX:
   127       solve_max<Value>(ap,is,os,desc);
   125       solve_max<Value>(ap,is,os,desc);
   128       break;
   126       break;
   129     case DimacsDescriptor::SP:
   127     case DimacsDescriptor::SP:
   139 
   137 
   140 int main(int argc, const char *argv[]) {
   138 int main(int argc, const char *argv[]) {
   141   typedef SmartDigraph Digraph;
   139   typedef SmartDigraph Digraph;
   142 
   140 
   143   typedef Digraph::Arc Arc;
   141   typedef Digraph::Arc Arc;
   144   typedef Digraph::Node Node;
       
   145   typedef Digraph::ArcIt ArcIt;
       
   146   typedef Digraph::NodeIt NodeIt;
       
   147   typedef Digraph::ArcMap<double> DoubleArcMap;
       
   148   typedef Digraph::NodeMap<double> DoubleNodeMap;
       
   149 
   142 
   150   std::string inputName;
   143   std::string inputName;
   151   std::string outputName;
   144   std::string outputName;
   152 
   145 
   153   ArgParser ap(argc, argv);
   146   ArgParser ap(argc, argv);
   186     case 0:
   179     case 0:
   187       break;
   180       break;
   188     default:
   181     default:
   189       std::cerr << ap.commandName() << ": too many arguments\n";
   182       std::cerr << ap.commandName() << ": too many arguments\n";
   190       return 1;
   183       return 1;
   191   }
   184     }
   192   std::istream& is = (ap.files().size()<1 ? std::cin : input);
   185   std::istream& is = (ap.files().size()<1 ? std::cin : input);
   193   std::ostream& os = (ap.files().size()<2 ? std::cout : output);
   186   std::ostream& os = (ap.files().size()<2 ? std::cout : output);
   194 
   187 
   195   DimacsDescriptor desc = dimacsType(is);
   188   DimacsDescriptor desc = dimacsType(is);
   196   
   189   
   214           exit(1);
   207           exit(1);
   215           break;
   208           break;
   216         }
   209         }
   217       std::cout << "\nNum of nodes: " << desc.nodeNum;
   210       std::cout << "\nNum of nodes: " << desc.nodeNum;
   218       std::cout << "\nNum of arcs:  " << desc.edgeNum;
   211       std::cout << "\nNum of arcs:  " << desc.edgeNum;
   219       std::cout << '\n' << std::endl;
   212       std::cout << "\n\n";
   220     }
   213     }
   221     
   214     
   222   if(ap.given("double"))
   215   if(ap.given("double"))
   223     solve<double>(ap,is,os,desc);
   216     solve<double>(ap,is,os,desc);
   224   else if(ap.given("ldouble"))
   217   else if(ap.given("ldouble"))