-
Notifications
You must be signed in to change notification settings - Fork 1
/
SLPA.h
112 lines (87 loc) · 3.22 KB
/
SLPA.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
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
//============================================================================
// Name : SLPA.h
// Author : Jierui Xie ([email protected])
// Date : Oct. 2011
// Version :
// Copyright : All rights reserved.
// Description : SLPA algorithm for community detection.
// Web Site : https://sites.google.com/site/communitydetectionslpa/
// Publication:
// J. Xie, B. K. Szymanski and X. Liu, "SLPA: Uncovering Overlapping Communities in Social Networks via A Speaker-listener Interaction Dynamic Process", IEEE ICDM workshop on DMCCI 2011, Vancouver, CA.
//============================================================================
#ifndef SLPA_H_
#define SLPA_H_
#include "Net.h"
#include "NODE.h"
#include <map>
#include <vector>
#include <utility>
#include <tr1/unordered_map>
#include "MersenneTwister.h"
//---------------------------
// Multi-threading
//---------------------------
typedef std::tr1::unordered_map<int, int> UOrderedH_INT_INT;
struct thread_data{
int startind;
int endind;
int *pIndicator;
//expect to do sharro copy of the pointers
vector<vector<int>* > cpm;
vector<UOrderedH_INT_INT* > vectHTable;
};
class SLPA {
public:
//---------------------------
// network parameters
//---------------------------
Net* net;
string netName;
string fileName_net;
string networkPath;
bool isUseLargestComp; //***
//---------------------------
// SLPA parameters
//---------------------------
vector<double> THRS; //thr
vector<int> THRCS; //thr count
bool isSyn; //is synchronous version?
int maxT;
int maxRun;
//---------------------------
// more
//---------------------------
string outputDir;
MTRand mtrand1;
MTRand mtrand2;
SLPA(string, vector<double>,int ,int ,string ,bool,int );
virtual ~SLPA();
void start();
void pre_initial_THRCS();
void initWQueue_more();
//void GLPA_asyn();
void GLPA_asyn_pointer();
int ceateHistogram_selRandMax(const vector<int>& wordsList);
void post_createWQHistogram_MapEntryList();
void post_thresholding(vector<pair<int,int> >& pairList, int thrc, vector<int>& WS);
//need to change
//vector<vector<int> > post_sameLabelDisconnectedComponents(vector<vector<int> >& cpm);
//static void show_cpm(vector<vector<int> >& cpm);
static void sort_cpm(vector<vector<int> >& cpm);
//cpm pointer function
vector<vector<int>* > post_removeSubset_UorderedHashTable_cpmpointer(vector<vector<int>* >& cpm);
static void sort_cpm_pointer(vector<vector<int>* >& cpm);
void write2txt_CPM_pointer(string fileName,vector<vector<int>* >& cpm);
void post_threshold_createCPM_pointer(int thrc,string fileName);
void dothreshold_createCPM(int thrc,vector<vector<int> >& cpm);
void dothreshold_createCPM_pointer(int thrc,vector<vector<int>* >& cpm);
static bool isDEBUG;
//---------------------------
// Multi-threading
//---------------------------
int numThreads;
void decomposeTasks(int numTasks,int numThd,int stInds[],int enInds[]);
static void *removesubset_onethread(void *threadarg);
vector<vector<int>* > post_removeSubset_UorderedHashTable_cpmpointer_MultiThd(vector<vector<int>* >& cpm);
};
#endif /* SLPA_H_ */