-
Notifications
You must be signed in to change notification settings - Fork 1
/
pruning.h
84 lines (74 loc) · 3.23 KB
/
pruning.h
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
#ifndef PRUNING_H
#define PRUNING_H
#include "buildGraph.h"
#include "topicDiscover.h"
#include "queue.h"
#include "math.h"
#include "global.h"
#include "assessUtil.h"
#include "dbUtil.h"
#include "timeUtil.h"
using namespace std;
class Pruning{
private:
static Pruning *_pInstance;
map<int,float> keyWordMap;
map<int,float> hotWordMap;
vector<int> keyWordList;
vector<int> hotWordList;
float f1;
int C;
int C1;
float mu;
int tao;
float xipuxiluo;
int PruningCount;
map<long int,UserLink> *userGraphMap;
map<long,WordTfIdfLink> *sidWTIMap;
map<int,StatusTagLink> *widSTMap;
public:
static Pruning *GetInstance();
Pruning();
bool Init(); //传播过程初始化
bool TopicDiffuse(); //话题传播
bool BuildQueue(Queue<long> &lqueue,map<long,UserStatus> &userSMap,StatusTagLink p,const int &wid);//建立传播列表队列
bool ModelSpread(Queue<long> &lqueue,map<long,UserStatus> &userSMap); //模拟传播过程
float DiffuseRate(const int &srcWeight,const int &dstWeight,const int &conntect);//传播概率
bool DynamicSpread(const string &startTime,const string &midTime,const string &endTime); //某一段时间的,话题动态传播
bool GetKeyWordMap(const string &startTime,const string &endTime);
bool GetHotWordMap(const string &startTime,const string &endTime);
bool BuildKeyHotWordMap(const string &startTime,const string &endTime);
bool CalculateF1();
bool StatisticUserInfo(map<long int,UserLink> *userGraphMap);//统计用户数量,话题数量,平均度数
bool ShowUserSMap(map<long,UserStatus> &userSMap);
bool PruningUserGraph(map<long int,UserLink> *userGraphMap,UserLLink userhead);
//Method4 根据权值来进行剪枝计算
bool PruningMethod4();
bool SortUser(map<int,UserTopicValueLink> &widUserTopicMap,map<long int,UserLink> *userGraphMap,UserLLink userhead);
//Method5 根据用户兴趣的相似性来对用户进行排序
bool PruningMethod5();
bool InitWordTopicValueMap(map<long,WordTfIdfLink> &uidWordTopicMap);
bool SortUserByInterest(map<long,WordTfIdfLink> &uidWordTopicMap,UserLLink userhead);
float CalcuateInterest(WordTfIdfLink head1,WordTfIdfLink head2);
bool SortUserLink(map<long,UserLLink> &userInterestMap);
bool SortUserII(map<long,UserLLink> &userInterestMap,UserLLink userhead);
bool InsertUserHead(UserLLink userhead);
bool QueryUserHead(UserLLink userhead);
bool FreeWordTopicValueMap(map<long,WordTfIdfLink> &uidWordTopicMap);
bool FreeUserInterestMap(map<long,UserLLink> &userInterestMap);
bool InitUserTopicValueMap(map<int,UserTopicValueLink> &widUserTopicMap);
bool SortUserTopicValueMap(map<int,UserTopicValueLink> &widUserTopicMap);
bool FreeUserTopicValueMap(map<int,UserTopicValueLink> &widUserTopicMap);
//Method1 随机进行剪枝
bool PruningMethod1();
bool RandomSortUser(UserLLink userhead);
//Method2 选择度大的进行剪枝
bool PruningMethod2();
//Method3 选择度小的进行剪枝
bool PruningMethod3();
bool SortUserByDgree(UserLLink userhead,bool BigSign);
void Show(); //展示结果内容
void Test(map<int,UserTopicValueLink> &widUserTopicMap);
~Pruning();
};
#endif // PRUNING_H