global.h
Go to the documentation of this file.
1 #ifndef GLOBAL_H
2 #define GLOBAL_H
3 
4 #include <QMetaType>
5 
6 #define SOCNETV_NAMESPACE SocNetV
7 
8 #ifdef SOCNETV_NAMESPACE
9 # define SOCNETV_BEGIN_NAMESPACE namespace SOCNETV_NAMESPACE {
10 # define SOCNETV_END_NAMESPACE }
11 # define SOCNETV_USE_NAMESPACE using namespace SOCNETV_NAMESPACE;
12 #else
13 # define SOCNETV_BEGIN_NAMESPACE
14 # define SOCNETV_END_NAMESPACE
15 # define SOCNETV_USE_NAMESPACE
16 #endif
17 
18 
20 
21 #ifndef M_PI_3
22 #define M_PI_3 (1.04719755119659774615)
23 #endif
24 
25 
26 #ifndef M_PI
27 #define M_PI (3.14159265358979323846)
28 #endif
29 
30 #ifndef M_PI_X_2
31 #define M_PI_X_2 (6.28318530717958647692)
32 #endif
33 
34 
35 
36 enum NodeShape{
37  Box,
48  Custom
49 };
50 
51 
52 enum FileType {
53  NOT_SAVED = 0, // New network not saved yet or modified network
54  GRAPHML = 1, // .GRAPHML .XML
55  PAJEK = 2, // .PAJ .NET
56  ADJACENCY = 3, // .CSV .ADJ .SM
57  GRAPHVIZ = 4, // .DOT
58  UCINET = 5, // .DL .DAT
59  GML = 6, // .GML
60  EDGELIST_WEIGHTED = 7, // .CSV, .TXT, .LIST, LST, WLST
61  EDGELIST_SIMPLE = 8, // .CSV, .TXT, .LIST, LST
62  TWOMODE = 9, // .2SM .AFF
63  UNRECOGNIZED =-1 // UNRECOGNIZED FILE FORMAT
64 };
65 
66 
67 enum EdgeType {
68  Directed = 0,
70  Undirected = 2
71 };
72 
73 
74 enum IndexType {
75  DC = 1,
76  CC = 2,
77  IRCC = 3,
78  BC = 4,
79  SC = 5,
80  EC = 6,
81  PC = 7,
82  IC = 8,
83  EVC = 9,
84  DP = 10,
85  PRP = 11,
86  PP = 12
87 };
88 
89 
90 enum ChartType {
91  None = -1,
92  Spline = 0,
93  Area = 1,
94  Bars = 2
95 };
96 
98  Generic = 0,
99  Crawler = 1,
100  CheckUpdate = 2
101 
102 };
103 
104 static const QString VERSION="3.1";
105 
106 static const int USER_MSG_INFO=0;
107 static const int USER_MSG_CRITICAL=1;
108 static const int USER_MSG_CRITICAL_NO_NETWORK=2;
109 static const int USER_MSG_CRITICAL_NO_EDGES=3;
110 static const int USER_MSG_QUESTION=4;
111 static const int USER_MSG_QUESTION_CUSTOM=5;
112 
113 
114 static const int SUBGRAPH_CLIQUE = 1;
115 static const int SUBGRAPH_STAR = 2;
116 static const int SUBGRAPH_CYCLE = 3;
117 static const int SUBGRAPH_LINE = 4;
118 
119 static const int MATRIX_ADJACENCY = 1;
120 static const int MATRIX_DISTANCES = 2;
121 static const int MATRIX_DEGREE = 3;
122 static const int MATRIX_LAPLACIAN = 4;
123 static const int MATRIX_ADJACENCY_INVERSE = 5;
124 static const int MATRIX_GEODESICS = 6;
125 static const int MATRIX_REACHABILITY = 7;
126 static const int MATRIX_ADJACENCY_TRANSPOSE = 8;
127 static const int MATRIX_COCITATION = 9;
128 static const int MATRIX_DISTANCES_EUCLIDEAN = 12;
129 static const int MATRIX_DISTANCES_MANHATTAN= 13;
130 static const int MATRIX_DISTANCES_JACCARD= 14;
131 static const int MATRIX_DISTANCES_HAMMING= 15;
132 static const int MATRIX_DISTANCES_CHEBYSHEV= 16;
133 
134 
135 
136 
137 
138 
139 struct ClickedEdge {
140  int v1;
141  int v2;
142  int type;
143 };
144 
145 
146 
147 typedef QPair<int, int> SelectedEdge;
148 
149 
150 class MyEdge {
151 public:
152  int source;
153  int target;
154  double weight;
155  int type;
156  double rWeight;
157  MyEdge() { source=0; target=0;weight=0;type=0; rWeight=0; }
158  MyEdge (const int &from, const int &to, const double &w =0, const int &type=0, const double &rw = 0)
159  : source(from), target(to), weight(w), type(type), rWeight(rw) { }
160  // Copy constructor
161  MyEdge (const MyEdge &edge) {
162  source = edge.source;
163  target = edge.target;
164  weight = edge.weight;
165  rWeight = edge.rWeight ;
166  type = edge.type;
167  }
169 };
170 
171 
176 {
177 public:
178  int target;
179  int distance;
180 
181  GraphDistance(int t, int dist)
182  : target(t), distance(dist)
183  {
184 
185  }
186 };
187 
188 
189 
196 public:
198  {
199  if (t1.distance == t2.distance)
200  return t1.target > t2.target;
201  return t1.distance > t2.distance; //minimum priority
202  }
203 };
204 
205 
206 
207 
208 class PairVF
209 {
210 public:
211  qreal value;
212  qreal frequency;
213 
214  PairVF(qreal v, qreal f)
215  : value(v), frequency(f) { }
216 };
217 
218 
219 // implement a min-priority queue
221 public:
222  bool operator()(PairVF& v1, PairVF& v2)
223  {
224  return v1.value > v2.value; //minimum priority
225  // Returns true if t1 is closer than t2
226  // else
227  }
228 };
229 
230 
231 
233 
234 
235 Q_DECLARE_METATYPE(SOCNETV_NAMESPACE::MyEdge)
236 Q_DECLARE_METATYPE(SOCNETV_NAMESPACE::NetworkRequestType)
237 
238 
239 #endif // GLOBAL_H
Holds the distance to target. Used in Graph::dijkstra() priority_queue.
Definition: global.h:176
int distance
Definition: global.h:179
int target
Definition: global.h:178
GraphDistance(int t, int dist)
Definition: global.h:181
Metric to implement a min-priority queue. The operator returns true if if t1 is closer than t2 Used i...
Definition: global.h:195
bool operator()(GraphDistance &t1, GraphDistance &t2)
Definition: global.h:197
Definition: global.h:150
~MyEdge()
Definition: global.h:168
double weight
Definition: global.h:154
double rWeight
Definition: global.h:156
MyEdge(const MyEdge &edge)
Definition: global.h:161
int source
Definition: global.h:152
int target
Definition: global.h:153
MyEdge()
Definition: global.h:157
int type
Definition: global.h:155
MyEdge(const int &from, const int &to, const double &w=0, const int &type=0, const double &rw=0)
Definition: global.h:158
Definition: global.h:220
bool operator()(PairVF &v1, PairVF &v2)
Definition: global.h:222
Definition: global.h:209
qreal frequency
Definition: global.h:212
PairVF(qreal v, qreal f)
Definition: global.h:214
qreal value
Definition: global.h:211
static const int MATRIX_DISTANCES_JACCARD
Definition: global.h:130
static const QString VERSION
Definition: global.h:104
NetworkRequestType
Definition: global.h:97
@ Crawler
Definition: global.h:99
@ CheckUpdate
Definition: global.h:100
@ Generic
Definition: global.h:98
static const int SUBGRAPH_STAR
Definition: global.h:115
IndexType
Definition: global.h:74
@ BC
Definition: global.h:78
@ CC
Definition: global.h:76
@ IRCC
Definition: global.h:77
@ PP
Definition: global.h:86
@ IC
Definition: global.h:82
@ DC
Definition: global.h:75
@ SC
Definition: global.h:79
@ PC
Definition: global.h:81
@ EC
Definition: global.h:80
@ DP
Definition: global.h:84
@ PRP
Definition: global.h:85
@ EVC
Definition: global.h:83
FileType
Definition: global.h:52
@ GML
Definition: global.h:59
@ ADJACENCY
Definition: global.h:56
@ GRAPHML
Definition: global.h:54
@ EDGELIST_SIMPLE
Definition: global.h:61
@ PAJEK
Definition: global.h:55
@ NOT_SAVED
Definition: global.h:53
@ EDGELIST_WEIGHTED
Definition: global.h:60
@ UCINET
Definition: global.h:58
@ GRAPHVIZ
Definition: global.h:57
@ TWOMODE
Definition: global.h:62
@ UNRECOGNIZED
Definition: global.h:63
static const int SUBGRAPH_CLIQUE
Definition: global.h:114
NodeShape
Definition: global.h:36
@ Dice
Definition: global.h:47
@ Custom
Definition: global.h:48
@ Box
Definition: global.h:37
@ Bugs
Definition: global.h:45
@ Person
Definition: global.h:43
@ Diamond
Definition: global.h:39
@ PersonB
Definition: global.h:44
@ Triangle
Definition: global.h:41
@ Ellipse
Definition: global.h:40
@ Star
Definition: global.h:42
@ Circle
Definition: global.h:38
@ Heart
Definition: global.h:46
static const int USER_MSG_CRITICAL_NO_NETWORK
Definition: global.h:108
static const int MATRIX_ADJACENCY
Definition: global.h:119
EdgeType
Definition: global.h:67
@ Reciprocated
Definition: global.h:69
@ Undirected
Definition: global.h:70
@ Directed
Definition: global.h:68
static const int MATRIX_LAPLACIAN
Definition: global.h:122
static const int SUBGRAPH_LINE
Definition: global.h:117
static const int USER_MSG_QUESTION
Definition: global.h:110
ChartType
Definition: global.h:90
@ Area
Definition: global.h:93
@ Spline
Definition: global.h:92
@ Bars
Definition: global.h:94
@ None
Definition: global.h:91
static const int USER_MSG_INFO
Definition: global.h:106
static const int MATRIX_DEGREE
Definition: global.h:121
static const int MATRIX_GEODESICS
Definition: global.h:124
static const int MATRIX_DISTANCES_EUCLIDEAN
Definition: global.h:128
#define SOCNETV_END_NAMESPACE
Definition: global.h:10
static const int MATRIX_DISTANCES_CHEBYSHEV
Definition: global.h:132
static const int MATRIX_REACHABILITY
Definition: global.h:125
QPair< int, int > SelectedEdge
Definition: global.h:147
static const int MATRIX_DISTANCES_MANHATTAN
Definition: global.h:129
static const int USER_MSG_CRITICAL_NO_EDGES
Definition: global.h:109
static const int USER_MSG_QUESTION_CUSTOM
Definition: global.h:111
static const int MATRIX_DISTANCES
Definition: global.h:120
#define SOCNETV_BEGIN_NAMESPACE
Definition: global.h:9
static const int MATRIX_ADJACENCY_TRANSPOSE
Definition: global.h:126
static const int SUBGRAPH_CYCLE
Definition: global.h:116
static const int MATRIX_ADJACENCY_INVERSE
Definition: global.h:123
static const int USER_MSG_CRITICAL
Definition: global.h:107
static const int MATRIX_COCITATION
Definition: global.h:127
static const int MATRIX_DISTANCES_HAMMING
Definition: global.h:131
Definition: global.h:139
int v2
Definition: global.h:141
int v1
Definition: global.h:140
int type
Definition: global.h:142