-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.cpp
69 lines (58 loc) · 1.79 KB
/
main2.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
#include <iostream>
#include "database.h"
#include "random_walk_manager2.h"
using namespace std;
char* datafile;
int minsup;
int pat_count;
typedef ExPattern<int, int> PAT;
template<> vector<int> Database<PAT>::_no_data = Database<PAT>::set_static_data();
template<> PatternFactory<PAT>* PatternFactory<PAT>::_instance = PatternFactory<PAT>::set_static_data();
//template<> PatternFactory<PAT>::set_static_data();
void print_usage(char *prog) {
cerr<<"Usage: "<<prog<<" -d data-file -c count -s minsup"<<endl;
exit(0);
}
void parse_args(int argc, char* argv[]) {
if(argc<7) {
print_usage(argv[0]);
}
for (int i=1; i < argc; ++i){
if (strcmp(argv[i], "-d") == 0){
datafile=argv[++i];
}
else if (strcmp(argv[i], "-s") == 0){
minsup=atoi(argv[++i]);
cout << "Minimum Support:" << minsup << " " << endl;
}
else if(strcmp(argv[i],"-c") == 0){
pat_count=atoi(argv[++i]);
}
else{
print_usage(argv[0]);
}
}
}//end parse_args()
int main(int argc, char *argv[]) {
parse_args(argc, argv);
Database<PAT>* database;
/* creating database and loading data */
try {
database = new Database<PAT>(datafile);
database->set_minsup(minsup);
}
catch (exception& e) {
cout << e.what() << endl;
}
database->remove_infrequent_edges();
/* creating random_walk_manager and starting walk */
double C=50.0;
cout << "Start Sampling.......\n";
cout << "Line starting with M are maximal, and starting with F are frequent" << endl;
cout << "Number in the parenthesis are count, for M the count is unique, for F, they are not necessarily unique" << endl;;
RandomWalkManager2<PAT> rwm(C,pat_count,database);
lattice_node<PAT>* start = rwm.initialize();
rwm.walk(start);
cout << "\nWalk terminated:" << endl;
delete database;
}