forked from datourat/Gorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
76 lines (65 loc) · 1.4 KB
/
main.cpp
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
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <functional>
#include <climits>
#include <ctime>
#include <stdlib.h>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <chrono>
#include "Graph.h"
#include "Util.h"
using namespace std;
using namespace Gorder;
const int INPUTNUM=1;
int main(int argc, char* argv[]){
ios::sync_with_stdio(false);
int i;
int W=5;
clock_t start, end;
string filename;
if(argc==1){
cout << "please provide parameter" << endl;
quit();
}
i=1;
while(i<argc){
if(strcmp("-w", argv[i])==0){
i++;
W=atoi(argv[i]);
if(W<=0){
cout << "w should be larger than 0" << endl;
quit();
}
i++;
}
else{
filename=argv[i++];
}
}
srand(time(0));
Graph g;
string name;
name=extractFilename(filename.c_str());
g.setFilename(name);
start=clock();
g.readGraph(filename);
g.Transform();
cout << name << " readGraph is complete." << endl;
end=clock();
cout << "Time Cost: " << (double)(end-start)/CLOCKS_PER_SEC << endl;
start=clock();
vector<int> order;
g.GorderGreedy(order, W);
end=clock();
cout << "ReOrdered Time Cost: " << (double)(end-start)/CLOCKS_PER_SEC << endl;
cout << "Begin Output the Reordered Graph" << endl;
g.PrintReOrderedGraph(order);
cout << endl;
}