vertex.h
Go to the documentation of this file.
1 /***************************************************************************
2  SocNetV: Social Network Visualizer
3  version: 2.2
4  Written in Qt
5 
6  vertex.h - description
7  -------------------
8  copyright : (C) 2005-2017 by Dimitris B. Kalamaras
9  project site : http://socnetv.org
10 
11  ***************************************************************************/
12 
13 /*******************************************************************************
14 * This program is free software: you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation, either version 3 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
26 ********************************************************************************/
27 
28 #ifndef VERTEX_H
29 #define VERTEX_H
30 
31 #include <QObject>
32 #include <QString>
33 #include <QStringList>
34 #include <QHash>
35 #include <QList>
36 #include <QPointF>
37 #include <map>
38 
39 using namespace std;
40 
41 class QPointF;
42 class Graph;
43 
44 
45 typedef QHash<int,QString> H_IntToStr;
46 typedef QList<int> L_int;
47 typedef QPair <float, bool> pair_f_b;
48 typedef QPair <int, pair_f_b > rel_w_bool;
49 typedef QHash < int, rel_w_bool > H_edges;
50 typedef QHash <QString, int> H_StrToInt;
51 
52 class Vertex : public QObject{
53  Q_OBJECT
54 
55 public:
56 
57  Vertex(Graph* parent,
58  const long int &name,
59  const int &val,
60  const int &relation,
61  const int &size,
62  const QString &color,
63  const QString &numColor,
64  const int &numSize,
65  const QString &label,
66  const QString &labelColor,
67  const int &labelSize,
68  const QPointF &p,
69  const QString &shape);
70 
71  Vertex(const long int &name);
72 
73  ~Vertex();
74 
75  long int name() const { return m_name; }
76 
77  void setName (const long int &name) { m_name=name; }
78 
79  void setEnabled (const bool &flag ) { m_enabled=flag; }
80  bool isEnabled () const { return m_enabled; }
81 
82  void relationSet(int) ;
83 
84  void edgeAddTo (const long int &v2, const float &weight);
85  void edgeAddFrom(const long int &v1, const float &weight);
86 
87  void changeOutEdgeWeight (long int target, float weight);
88 
89  void setOutEdgeEnabled (long int, bool);
90 
91  void edgeRemoveTo (long int target);
92  void edgeRemoveFrom(long int source);
93 
94  QHash<int,float>* outEdgesEnabledHash(const bool &allRelations=false);
95  QHash<int,float>* outEdgesAllRelationsUniqueHash();
96  QHash<int,float>* inEdgesEnabledHash();
97  QHash<int,float>* reciprocalEdgesHash();
98  QList<int> neighborhoodList();
99 
100  long int outEdges();
101  long int outEdgesConst() const ;
102 
103  long int inEdges();
104  long int inEdgesConst() const ;
105 
106  long int degreeOut();
107  long int outDegreeConst();
108  long int degreeIn();
109  long int inDegreeConst();
110  long int localDegree();
111 
112  /* sets eccentricity */
113  void setEccentricity (float c){ m_Eccentricity=c;}
114  float eccentricity() { return m_Eccentricity;}
115 
116  /* Returns true if there is an outLink from this vertex */
117  bool isOutLinked() { return (outEdges() > 0) ? true:false;}
118  float hasEdgeTo(const long int &v, const bool &allRelations=false);
119 
120  /* Returns true if there is an outLink from this vertex */
121  bool isInLinked() { return (inEdges() > 0) ? true:false;}
122  float hasEdgeFrom (const long int &v, const bool &allRelations=false);
123 
124  bool isIsolated() { return !(isOutLinked() | isInLinked()) ; }
125  void setIsolated(bool isolated) {m_isolated = isolated; }
126 
127  void edgeFilterByWeight(float m_threshold, bool overThreshold);
128  // void filterEdgesByColor(float m_threshold, bool overThreshold);
129  void edgeFilterByRelation(int relation, bool status);
130  void edgeFilterUnilateral(const bool &toggle=false);
131 
132  void setSize(const int &size ) { m_size=size; }
133  int size() const { return m_size; }
134 
135  void setShape(const QString &shape) { m_shape=shape; }
136  QString shape() const { return m_shape; }
137 
138  void setColor(const QString &color) { m_color=color; }
139  QString color() const { return m_color; }
140  QString colorToPajek();
141 
142  void setNumberColor (const QString &color) { m_numberColor = color; }
143  QString numberColor() const { return m_numberColor; }
144 
145  void setNumberSize (const int &size) { m_numberSize=size; }
146  int numberSize() const { return m_numberSize; }
147 
148  void setNumberDistance (const int &distance) { m_numberDistance=distance; }
149  int numberDistance() const { return m_numberDistance; }
150 
151  void setLabel (const QString &label) { m_label=label; }
152  QString label() const { return m_label; }
153 
154  void setLabelColor (const QString &labelColor) { m_labelColor=labelColor; }
155  QString labelColor() const { return m_labelColor; }
156 
157  void setLabelSize(const int &size) { m_labelSize=size; }
158  int labelSize() const { return m_labelSize; }
159 
160  void setLabelDistance (const int &distance) { m_labelDistance=distance; }
161  int labelDistance() const { return m_labelDistance; }
162 
163  void setX(const float &x) { m_x=x; }
164  float x() const { return m_x; }
165 
166  void setY(const float &y) { m_y=y; }
167  float y() const { return m_y; }
168 
169  QPointF pos () const { return QPointF ( x(), y() ); }
170  void setPos (QPointF &p) { m_x=p.x(); m_y=p.y(); }
171 
172  //returns displacement vector
173  QPointF & disp() { return m_disp; }
174 
175  void set_dispX (float x) { m_disp.rx() = x ; }
176  void set_dispY (float y) { m_disp.ry() = y ; }
177 
178 
179  void setOutLinkColor(const long int &v2,
180  const QString &color) { outLinkColors[v2]=color; }
181  QString outLinkColor(const long int &v2) {
182  return ( outLinkColors.contains(v2) ) ? outLinkColors.value(v2) : "black";
183  }
184 
185 
186  void setOutEdgeLabel(const long int &v2,
187  const QString &label) { m_outEdgeLabels[v2]=label; }
188  QString outEdgeLabel(const long int &v2) const {
189  return ( m_outEdgeLabels.contains(v2) ) ? m_outEdgeLabels.value(v2) : QString::null;
190  }
191 
192 
193  void setDelta (float c){ m_delta=c;} /* Sets vertex pair dependancy */
194  float delta() { return m_delta;} /* Returns vertex pair dependancy */
195 
196  void clearPs() ;
197 
198  void appendToPs(long int vertex ) ;
199  L_int Ps(void);
200 
201  void setDC (float c){ m_DC=c;} /* Sets vertex Degree Centrality*/
202  void setSDC (float c ) { m_SDC=c;} /* Sets standard vertex Degree Centrality*/
203  float DC() { return m_DC;} /* Returns vertex Degree Centrality*/
204  float SDC() { return m_SDC;} /* Returns standard vertex Degree Centrality*/
205 
206  void setCC (float c){ m_CC=c;} /* sets vertex Closeness Centrality*/
207  void setSCC (float c ) { m_SCC=c;} /* sets standard vertex Closeness Centrality*/
208  float CC() { return m_CC;} /* Returns vertex Closeness Centrality*/
209  float SCC() { return m_SCC; } /* Returns standard vertex Closeness Centrality*/
210 
211  void setIRCC (float c){ m_IRCC=c;} /* sets vertex IRCC */
212  void setSIRCC (float c ) { m_SIRCC=c;} /* sets standard vertex IRCC */
213  float IRCC() { return m_IRCC;} /* Returns vertex IRCC */
214  float SIRCC() { return m_SIRCC; } /* Returns standard vertex IRCC*/
215 
216  void setBC(float c){ m_BC=c;} /* sets s vertex Betweenness Centrality*/
217  void setSBC (float c ) { m_SBC=c;} /* sets standard vertex Betweenness Centrality*/
218  float BC() { return m_BC;} /* Returns vertex Betweenness Centrality*/
219  float SBC() { return m_SBC; } /* Returns standard vertex Betweenness Centrality*/
220 
221  void setSC (float c){ m_SC=c;} /* sets vertex Stress Centrality*/
222  void setSSC (float c ) { m_SSC=c;} /* sets standard vertex Stress Centrality*/
223  float SC() { return m_SC;} /* Returns vertex Stress Centrality*/
224  float SSC() { return m_SSC; } /* Returns standard vertex Stress Centrality*/
225 
226  void setEC(float dist) { m_EC=dist;} /* Sets max Geodesic Distance to all other vertices*/
227  void setSEC(float c) {m_SEC=c;}
228  float EC() { return m_EC;} /* Returns max Geodesic Distance to all other vertices*/
229  float SEC() { return m_SEC;}
230 
231  void setPC (float c){ m_PC=c;} /* sets vertex Power Centrality*/
232  void setSPC (float c ) { m_SPC=c;} /* sets standard vertex Power Centrality*/
233  float PC() { return m_PC;} /* Returns vertex Power Centrality*/
234  float SPC() { return m_SPC; } /* Returns standard vertex Power Centrality*/
235 
236  void setIC (float c){ m_IC=c;} /* sets vertex Information Centrality*/
237  void setSIC (float c ) { m_SIC=c;} /* sets standard vertex Information Centrality*/
238  float IC() { return m_IC;} /* Returns vertex Information Centrality*/
239  float SIC() { return m_SIC; } /* Returns standard vertex Information Centrality*/
240 
241  void setDP (float c){ m_DP=c;} /* Sets vertex Degree Prestige */
242  void setSDP (float c ) { m_SDP=c;} /* Sets standard vertex Degree Prestige */
243  float DP() { return m_DP;} /* Returns vertex Degree Prestige */
244  float SDP() { return m_SDP;} /* Returns standard vertex Degree Prestige */
245 
246  void setPRP (float c){ m_PRC=c;} /* sets vertex PageRank*/
247  void setSPRP (float c ) { m_SPRC=c;} /* sets standard vertex PageRank*/
248  float PRP() { return m_PRC;} /* Returns vertex PageRank */
249  float SPRP() { return m_SPRC; } /* Returns standard vertex PageRank*/
250 
251  void setPP (float c){ m_PP=c;} /* sets vertex Proximity Prestige */
252  void setSPP (float c ) { m_SPP=c;} /* sets standard vertex Proximity Prestige */
253  float PP() { return m_PP;} /* Returns vertex Proximity Prestige */
254  float SPP() { return m_SPP; } /* Returns standard vertex Proximity Prestige */
255 
256  float CLC() { return m_CLC; }
257  void setCLC(float clucof) { m_CLC=clucof; m_hasCLC=true; }
258  bool hasCLC() { return m_hasCLC; }
259 
260  void setEVC (float c){ m_EVC=c;} /* Sets vertex Degree Centrality*/
261  void setSEVC (float c ) { m_SEVC=c;} /* Sets standard vertex Degree Centrality*/
262  float EVC() { return m_EVC;} /* Returns vertex Degree Centrality*/
263  float SEVC() { return m_SEVC;} /* Returns standard vertex Degree Centrality*/
264 
265 
266  int cliques (const int &ofSize);
267 
268  void cliqueAdd (const QList<int> &clique);
269 
270  void clearCliques() { m_cliques.clear(); }
271 
272  //hold all outbound and inboud edges of this vertex.
273  H_edges m_outEdges, m_inEdges;
274 signals:
275  void setEdgeVisibility (int, int, int, bool);
276 
277 protected:
278 
279 private:
281  long int m_name, m_outEdgesCounter, m_inEdgesCounter, m_outDegree, m_inDegree, m_localDegree;
282  int m_value, m_size, m_labelSize, m_numberSize, m_numberDistance, m_labelDistance;
284  bool m_reciprocalLinked, m_enabled, m_hasCLC, m_isolated;
285  double m_x, m_y;
286  float m_Eccentricity, m_CLC;
287  float m_delta, m_EC, m_SEC;
288  float m_DC, m_SDC, m_DP, m_SDP, m_CC, m_SCC, m_BC, m_SBC, m_IRCC, m_SIRCC, m_SC, m_SSC;
289  float m_PC, m_SPC, m_SIC, m_IC, m_SPRC, m_PRC;
290  float m_PP, m_SPP, m_EVC, m_SEVC;
291 
292  QString m_color, m_numberColor, m_label, m_labelColor, m_shape;
293  QPointF m_disp;
294 
295  QHash<int,float>* m_reciprocalEdges;
298  H_IntToStr outLinkColors, m_outEdgeLabels;
299  QHash <int, L_int> m_cliques;
300  //FIXME vertex coords
301 
302 
303 
304 };
305 
306 #endif
void setNumberSize(const int &size)
Definition: vertex.h:145
void setSize(const int &size)
Definition: vertex.h:132
void setSC(float c)
Definition: vertex.h:221
float m_SPP
Definition: vertex.h:290
float DP()
Definition: vertex.h:243
QHash< int, rel_w_bool > H_edges
Definition: vertex.h:49
float m_SSC
Definition: vertex.h:288
int m_value
Definition: vertex.h:282
bool isInLinked()
Definition: vertex.h:121
float SBC()
Definition: vertex.h:219
float SEVC()
Definition: vertex.h:263
float SCC()
Definition: vertex.h:209
void setSBC(float c)
Definition: vertex.h:217
int size() const
Definition: vertex.h:133
bool isIsolated()
Definition: vertex.h:124
The Graph class This is the main class for a Graph, used in conjuction with Vertex, Parser and Matrix objects. Graph class methods are the interface to various analysis algorithms Vertex class holds each vertex data (colors, strings, statistics, etc) Matrix class holds the adjacency matrix of the network. Parser class loads files of networks.
Definition: graph.h:192
float m_SEC
Definition: vertex.h:287
bool isOutLinked()
Definition: vertex.h:117
void setDelta(float c)
Definition: vertex.h:193
void setOutEdgeLabel(const long int &v2, const QString &label)
Definition: vertex.h:186
QPointF pos() const
Definition: vertex.h:169
float SPC()
Definition: vertex.h:234
void setColor(const QString &color)
Definition: vertex.h:138
float CC()
Definition: vertex.h:208
void set_dispY(float y)
Definition: vertex.h:176
float SEC()
Definition: vertex.h:229
void setCC(float c)
Definition: vertex.h:206
float EVC()
Definition: vertex.h:262
void clearCliques()
Definition: vertex.h:270
void setLabelDistance(const int &distance)
Definition: vertex.h:160
void setPC(float c)
Definition: vertex.h:231
void setIsolated(bool isolated)
Definition: vertex.h:125
bool isEnabled() const
Definition: vertex.h:80
double m_y
Definition: vertex.h:285
bool hasCLC()
Definition: vertex.h:258
void setSPRP(float c)
Definition: vertex.h:247
void setPos(QPointF &p)
Definition: vertex.h:170
void setOutLinkColor(const long int &v2, const QString &color)
Definition: vertex.h:179
float SSC()
Definition: vertex.h:224
QString numberColor() const
Definition: vertex.h:143
void setSPC(float c)
Definition: vertex.h:232
float CLC()
Definition: vertex.h:256
float x() const
Definition: vertex.h:164
void setSDC(float c)
Definition: vertex.h:202
void setLabel(const QString &label)
Definition: vertex.h:151
void setSEC(float c)
Definition: vertex.h:227
float SIC()
Definition: vertex.h:239
float m_Eccentricity
Definition: vertex.h:286
float SIRCC()
Definition: vertex.h:214
void setEccentricity(float c)
Definition: vertex.h:113
float EC()
Definition: vertex.h:228
QHash< int, L_int > m_cliques
Definition: vertex.h:299
float DC()
Definition: vertex.h:203
void setSIRCC(float c)
Definition: vertex.h:212
int m_curRelation
Definition: vertex.h:283
void setPP(float c)
Definition: vertex.h:251
void setEnabled(const bool &flag)
Definition: vertex.h:79
QString color() const
Definition: vertex.h:139
void setIRCC(float c)
Definition: vertex.h:211
QString labelColor() const
Definition: vertex.h:155
int numberSize() const
Definition: vertex.h:146
void setDC(float c)
Definition: vertex.h:201
void setEC(float dist)
Definition: vertex.h:226
QPointF m_disp
Definition: vertex.h:293
void setEVC(float c)
Definition: vertex.h:260
QString label() const
Definition: vertex.h:152
int numberDistance() const
Definition: vertex.h:149
float SDP()
Definition: vertex.h:244
void setName(const long int &name)
Definition: vertex.h:77
QList< int > L_int
Definition: graph.h:111
void setY(const float &y)
Definition: vertex.h:166
void setNumberDistance(const int &distance)
Definition: vertex.h:148
void setSEVC(float c)
Definition: vertex.h:261
void setSCC(float c)
Definition: vertex.h:207
void setBC(float c)
Definition: vertex.h:216
void setSIC(float c)
Definition: vertex.h:237
float SC()
Definition: vertex.h:223
void setPRP(float c)
Definition: vertex.h:246
QHash< QString, int > H_StrToInt
Definition: vertex.h:50
L_int m_neighborhoodList
Definition: vertex.h:297
bool m_reciprocalLinked
Definition: vertex.h:284
float IC()
Definition: vertex.h:238
void setCLC(float clucof)
Definition: vertex.h:257
void setShape(const QString &shape)
Definition: vertex.h:135
H_edges m_outEdges
Definition: vertex.h:273
float m_SPRC
Definition: vertex.h:289
QPair< float, bool > pair_f_b
Definition: vertex.h:47
int labelDistance() const
Definition: vertex.h:161
void setSSC(float c)
Definition: vertex.h:222
void setSPP(float c)
Definition: vertex.h:252
void set_dispX(float x)
Definition: vertex.h:175
void setNumberColor(const QString &color)
Definition: vertex.h:142
QString m_shape
Definition: vertex.h:292
QHash< int, QString > H_IntToStr
Definition: vertex.h:42
float IRCC()
Definition: vertex.h:213
float PP()
Definition: vertex.h:253
Graph * parentGraph
Definition: vertex.h:280
float SPP()
Definition: vertex.h:254
float delta()
Definition: vertex.h:194
void setDP(float c)
Definition: vertex.h:241
float BC()
Definition: vertex.h:218
QPair< int, pair_f_b > rel_w_bool
Definition: vertex.h:48
QString shape() const
Definition: vertex.h:136
float PC()
Definition: vertex.h:233
int labelSize() const
Definition: vertex.h:158
long int name() const
Definition: vertex.h:75
QString outEdgeLabel(const long int &v2) const
Definition: vertex.h:188
QPointF & disp()
Definition: vertex.h:173
QHash< int, rel_w_bool > H_edges
Definition: graph.h:109
QString outLinkColor(const long int &v2)
Definition: vertex.h:181
float PRP()
Definition: vertex.h:248
float eccentricity()
Definition: vertex.h:114
float SPRP()
Definition: vertex.h:249
L_int myPs
Definition: vertex.h:296
void setLabelColor(const QString &labelColor)
Definition: vertex.h:154
QList< int > L_int
Definition: vertex.h:46
float SDC()
Definition: vertex.h:204
void setX(const float &x)
Definition: vertex.h:163
H_IntToStr outLinkColors
Definition: vertex.h:298
QHash< int, float > * m_reciprocalEdges
Definition: vertex.h:295
float y() const
Definition: vertex.h:167
Definition: vertex.h:52
void setIC(float c)
Definition: vertex.h:236
void setLabelSize(const int &size)
Definition: vertex.h:157
void setSDP(float c)
Definition: vertex.h:242
long int m_outEdgesCounter
Definition: vertex.h:281