-
Notifications
You must be signed in to change notification settings - Fork 0
/
projection.h
87 lines (73 loc) · 1.66 KB
/
projection.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
#ifndef PROJ_H
#define PROJ_H
#include "libs.h"
#include "graph.h"
class Projection
{
private:
unsigned int nb_threads;
public:
Graph* in_graph;
vector<Node*> get_neighbors(unsigned int&, unsigned int&) const;
set<Node*> get_intersection(Node*&, Node*&) const;
virtual float similarity_projection(Node*&, Node*&)=0;
Graph* graph_projection;
Projection(Graph*&);
~Projection();
void project(unsigned int);
};
static pthread_mutex_t projection_main_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t compute_projection_mutex = PTHREAD_MUTEX_INITIALIZER;
void* projection_main_thread(void*);
void* compute_projection_thread(void*);
typedef struct
{
Projection* p;
unsigned int index;
unsigned int distance;
unordered_map<unsigned int, Node*>* map_node;
unordered_map<unsigned int, set<pair<unsigned int, float>, comp_pair>>* map_neighbor;
} projection_thread_args;
class CommonNeighbors : public Projection
{
protected:
float similarity_projection(Node*&, Node*&);
public:
CommonNeighbors(Graph*&);
};
class JaccardIndex : public Projection
{
protected:
float similarity_projection(Node*&, Node*&);
public:
JaccardIndex(Graph*&);
};
class AdamicAdar : public Projection
{
protected:
float similarity_projection(Node*&, Node*&);
public:
AdamicAdar(Graph*&);
};
class ResourceAllocator : public Projection
{
protected:
float similarity_projection(Node*&, Node*&);
public:
ResourceAllocator(Graph*&);
};
class LHN1 : public Projection
{
protected:
float similarity_projection(Node*&, Node*&);
public:
LHN1(Graph*&);
};
class PA_Neighbor : public Projection
{
protected:
float similarity_projection(Node*&, Node*&);
public:
PA_Neighbor(Graph*&);
};
#endif