Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/graphAlgorithms/mcFlo/mcFlo.cpp
00001 // usage: mcFlo method
00002 //
00003 // mcFlo reads a Wflograph from stdin, computes a min cost maximum flow
00004 // using the method specified by the argument and then prints the
00005 // Wflograph with the computed flow.
00006 //
00007 
00008 #include "stdinc.h"
00009 #include "Wflograph.h"
00010 #include "cycRed.h"
00011 #include "lcap.h"
00012 
00013 using namespace grafalgo;
00014 
00015 int main(int argc, char *argv[]) {
00016         flow floVal; cost floCost;
00017         Wflograph wfg; cin >> wfg;
00018         
00019         if (argc != 2) Util::fatal("usage: mcFlo method");
00020 
00021         if (strcmp(argv[1],"cycRed") == 0)
00022                 cycRed(wfg,floVal,floCost);
00023         else if (strcmp(argv[1],"lcap") == 0)
00024                 lcap(wfg,floVal,floCost,false);
00025         else if (strcmp(argv[1],"mostNeg") == 0)
00026                 lcap(wfg,floVal,floCost,true);
00027         else
00028                 Util::fatal("mcFlo: undefined method");
00029 
00030         string s;
00031         cout << wfg.toString(s);
00032         cout << "flow value is " << floVal
00033              << " and flow cost is " << floCost << endl;
00034 }
 All Classes Files Functions Variables Typedefs Friends