Grafalgo
Library of useful data structures and algorithms
|
00001 // usage: 00002 // mcFloRep method reps n m mss ec1 ec2 lo hi 00003 // 00004 // mcFloRep repeated generates a random graph and computes 00005 // a min cost max flow using the specified method. 00006 // Reps is the number of repetitions. 00007 // n is the number of vertices, m is the total number of edges, 00008 // mss is the number of edges from the source and the number 00009 // to the sink, ec1 is the average capacity for the src/sink 00010 // edges, ec2 is the average capacity for the other edges, 00011 // lo and hi define the range for the edge costs 00012 // 00013 00014 #include "stdinc.h" 00015 #include "Wflograph.h" 00016 #include "cycRed.h" 00017 #include "lcap.h" 00018 00019 using namespace grafalgo; 00020 00021 int main(int argc, char* argv[]) { 00022 int i, reps, n, m, mss, ec1, ec2, lo, hi; 00023 if (argc != 10 || 00024 sscanf(argv[2],"%d",&reps) != 1 || 00025 sscanf(argv[3],"%d",&n) != 1 || 00026 sscanf(argv[4],"%d",&m) != 1 || 00027 sscanf(argv[5],"%d",&mss) != 1 || 00028 sscanf(argv[6],"%d",&ec1) != 1 || 00029 sscanf(argv[7],"%d",&ec2) != 1 || 00030 sscanf(argv[8],"%d",&lo) != 1 || 00031 sscanf(argv[9],"%d",&hi) != 1) 00032 Util::fatal("usage: mcFloRep method reps n m mss ec1 ec2 lo hi"); 00033 00034 Wflograph wfg; flow floVal; cost floCost; 00035 for (i = 1; i <= reps; i++) { 00036 wfg.rgraph(n,m-2*mss,mss); 00037 wfg.randCapacity(ec1,ec2); 00038 wfg.randCost(lo,hi); 00039 00040 if (strcmp(argv[1],"cycRed") == 0) 00041 cycRed(wfg,floVal,floCost); 00042 else if (strcmp(argv[1],"lcap") == 0) 00043 lcap(wfg,floVal,floCost,false); 00044 else if (strcmp(argv[1],"mostNeg") == 0) 00045 lcap(wfg,floVal,floCost,true); 00046 else 00047 Util::fatal("mcFloRep: undefined method"); 00048 } 00049 }