-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.cpp
More file actions
135 lines (108 loc) · 3.01 KB
/
main.cpp
File metadata and controls
135 lines (108 loc) · 3.01 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <cstdlib>
#include <sys/time.h>
#include "process_mem_usage.h"
#include "DenseGRAPH.cc"
#include "UndirDenseGRAPH.cc"
#include "UndirBitDenseGRAPH.cc"
#include "DenseMultiGRAPH.cc"
#include "SparseGRAPH.cc"
#include "EdgeOptimalSparseGRAPH.cc"
#include "SparseMultiGRAPH.cc"
#include "STLSparseMultiGRAPH.cc"
#include "StaticMultiGRAPH.cc"
#include "IO.cc"
#include "sPATH.cc"
#include "gPATH.cc"
#include "ePATH.cc"
#include "DFS.cc"
#include "InfoDFS.cc"
#include "CC.cc"
#include "EULER.cc"
#include "BI.cc"
#include "BFS.cc"
#include "PFS.cc"
#include "TC.cc"
#include "tc.cc"
#include "TCsc.cc"
#include "SCc.cc"
#include "SCt.cc"
#include "SCg.cc"
// typedef DenseGRAPH Graph;
// typedef UndirDenseGRAPH Graph;
// typedef UndirBitDenseGRAPH Graph;
// typedef DenseMultiGRAPH Graph;
// typedef SparseGRAPH Graph;
// typedef EdgeOptimalSparseGRAPH Graph;
typedef SparseMultiGRAPH Graph;
// typedef STLSparseMultiGRAPH Graph;
// typedef StaticMultiGRAPH Graph;
// typedef DFS<Graph> DFST;
typedef InfoDFS<Graph> DFST;
// typedef EULER<Graph> DFST;
// typedef BI<Graph> DFST;
typedef SCg<Graph> SC;
void graphInfo(const Graph &G) {
IO<Graph>::show(G);
IO<Graph>::showEdges(G);
IO<Graph>::showAdj(G);
}
void removeAllEdges(Graph &G) {
vector<Edge> vec = edges(G);
for (vector<Edge>::iterator p = vec.begin(); p != vec.end(); ++p) {
G.remove(*p);
}
}
// Упражнение 17.65, 17.66
void measure(char *argv[]) {
Graph G(atoi(argv[1]), true);
IO<Graph>::scanEZ(G);
timeval tBegin, tEnd;
gettimeofday(&tBegin, NULL);
// BODY -->
// IO<Graph>::randG(G, 2 * G.V());
DFST s(G);
// cout << "OK = " << s.bipartite() << endl;
// <-- BODY
gettimeofday(&tEnd, NULL);
double elapsedTime = (tEnd.tv_sec - tBegin.tv_sec) * 1000.0; // sec to ms
elapsedTime += (tEnd.tv_usec - tBegin.tv_usec) / 1000.0; // us to ms
cout << elapsedTime << " ms.\n";
double vm, rss;
process_mem_usage(vm, rss);
cout << "VM: " << vm << "; RSS: " << rss << endl;
}
void test(char *argv[]) {
Graph G(atoi(argv[1]), true);
IO<Graph>::scanEZ(G);
// IO<Graph>::scan(G);
// removeAllEdges(G);
graphInfo(G);
// // Graph O = G;
// Graph O = removeZerosLoopsParallels(G);
// graphInfo(O);
// G.insert();
// G.insert();
// graphInfo(G);
// // // cout << "zeros: " << G.zeros() << " | " << zeros(G) << endl;
// // // for (int v = 0; v < G.V(); ++v) {
// // // cout << v << ": " << G.degree(v) << endl;
// // // }
// G.remove(0);
// graphInfo(G);
// findMaxSeqClique(G);
// cout << "sPATH = " << sPATH<Graph>(G, 1, 2).exist() << endl;
// cout << "gPATH = " << gPATH<Graph>(G, 1, 2).exist() << endl;
// ePATH<Graph> ep(G, 1, 2);
// cout << "ePATH = " << ep.exist() << endl;
// ep.show();
// SC sc(G);
// for (int i = 0; i < G.V(); ++i) {
// cout << " " << sc.ID(i);
// }
// cout << endl;
}
int main(int argc, char *argv[]) {
// measure(argv);
test(argv);
return 0;
}