-
Notifications
You must be signed in to change notification settings - Fork 0
/
uniform_freq.cpp
72 lines (63 loc) · 1.86 KB
/
uniform_freq.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
//! \file uniform_freq.cpp - main() function
#include <iostream>
#include "database.h"
#include "uniform_freq_random_walk.h"
using namespace std;
char* datafile;
int minsup;
int uniq_pat_count;
int max_iter;
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);
}
/*! Parsing arguments */
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){
max_iter=atoi(argv[++i]);
}
else{
print_usage(argv[0]);
}
}
}//end parse_args()
/*! main function */
int main(int argc, char *argv[]) {
bool zero_neighbors;
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();
//database->print_database();
/* creating random_walk_manager and starting walk */
Uniform_Freq_Random_Walk<PAT> rwm(database, max_iter);
int cur_iter=0;
//will call initialize followed by walk again and again until it gets a single edge pattern with some neighbors.
do {
lattice_node<PAT>* start = rwm.initialize();
zero_neighbors = rwm.walk(start,cur_iter);
} while (zero_neighbors == 0);
delete database;
}