-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
100 lines (92 loc) · 2.05 KB
/
Main.cpp
File metadata and controls
100 lines (92 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "Graph.h"
#include "PushRelabel.h"
int main(int argc, char **argv)
{
int max;
string file;
ifstream graphFile;
bool hlQueue = false;
bool doInc = false;
int incVal = 0;
string incFile;
bool printStats = false;
bool doOutFile;
string resFile;
if ((argc > 10) || (argc < 2))
{
cout << "Wrong number of arguments" << endl;
cout << "Usage: pushrelabel FILE [-c INC NEW-OUT] [-s] [-o OUT] [-m HL/FIFO]" << endl;
exit(1);
}
else
{
file = argv[1];
int i = 2;
while (i < argc)
{
if (strncmp(argv[i], "-c", 3) == 0)
{
if (i+2 > argc)
{
cout << "Wrong number of arguments" << endl;
cout << "Usage: pushrelabel FILE [-c INC NEW-OUT] [-s] [-o OUT] [-m HL/FIFO]" << endl;
exit(1);
}
doInc = true;
i++;
incVal = atoi(argv[i]);
i++;
incFile = argv[i];
}
else if (strncmp(argv[i], "-s", 3) == 0)
{
printStats = true;
}
else if (strncmp(argv[i], "-o", 3) == 0)
{
if (i+1 > argc)
{
cout << "Wrong number of arguments" << endl;
cout << "Usage: pushrelabel FILE [-c INC NEW-OUT] [-s] [-o OUT] [-m HL/FIFO]" << endl;
exit(1);
}
doOutFile = true;
i++;
resFile = argv[i];
}
else if (strncmp(argv[i], "-m", 3) == 0)
{
if (i+1 > argc)
{
cout << "Wrong number of arguments" << endl;
cout << "Usage: pushrelabel FILE [-c INC NEW-OUT] [-s] [-o OUT] [-m HL/FIFO]" << endl;
exit(1);
}
i++;
if (strncmp(argv[i], "HL", 3) == 0)
hlQueue = true;
else
hlQueue = false;
}
else
{
cout << "Bad argument - " << argv[i] << endl;
cout << "Usage: pushrelabel FILE [-c INC NEW-OUT] [-s] [-o OUT] [-m HL/FIFO]" << endl;
exit(1);
}
i++;
}
}
Graph *g = new Graph(file, hlQueue);
max = PushRelabel::calc(g, printStats);
if (doOutFile)
g->printGraph(resFile);
if (doInc)
{
g->incPrevPathCap(incVal);
PushRelabel::dijkstraPath();
g->printGraph(incFile);
}
printf("Done\n");
return(0);
}