Skip to content

Commit ba4953d

Browse files
committed
#159 Refactor and update header comments
1 parent 418f22a commit ba4953d

File tree

1 file changed

+82
-87
lines changed

1 file changed

+82
-87
lines changed

src/global.h

+82-87
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @file global.h
3+
* @brief This file contains global definitions, constants, and utility classes for the SocNetV application.
4+
*/
5+
16
#ifndef GLOBAL_H
27
#define GLOBAL_H
38

@@ -15,14 +20,12 @@
1520
# define SOCNETV_USE_NAMESPACE
1621
#endif
1722

18-
1923
SOCNETV_BEGIN_NAMESPACE
2024

2125
#ifndef M_PI_3
2226
#define M_PI_3 (1.04719755119659774615)
2327
#endif
2428

25-
2629
#ifndef M_PI
2730
#define M_PI (3.14159265358979323846)
2831
#endif
@@ -33,6 +36,10 @@ SOCNETV_BEGIN_NAMESPACE
3336

3437
static const QString VERSION="3.2";
3538

39+
/**
40+
* @enum NodeShape
41+
* @brief Enumeration of possible shapes for nodes in the network.
42+
*/
3643
enum NodeShape{
3744
Box,
3845
Circle,
@@ -48,29 +55,38 @@ enum NodeShape{
4855
Custom
4956
};
5057

51-
58+
/**
59+
* @enum FileType
60+
* @brief Enumeration of possible file types for network data.
61+
*/
5262
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
63+
NOT_SAVED = 0, ///< New network not saved yet or modified network
64+
GRAPHML = 1, ///< .GRAPHML .XML
65+
PAJEK = 2, ///< .PAJ .NET
66+
ADJACENCY = 3, ///< .CSV .ADJ .SM
67+
GRAPHVIZ = 4, ///< .DOT
68+
UCINET = 5, ///< .DL .DAT
69+
GML = 6, ///< .GML
70+
EDGELIST_WEIGHTED = 7, ///< .CSV, .TXT, .LIST, LST, WLST
71+
EDGELIST_SIMPLE = 8, ///< .CSV, .TXT, .LIST, LST
72+
TWOMODE = 9, ///< .2SM .AFF
73+
UNRECOGNIZED =-1 ///< Unrecognized file format
6474
};
6575

66-
76+
/**
77+
* @enum EdgeType
78+
* @brief Enumeration of possible edge types in the network.
79+
*/
6780
enum EdgeType {
6881
Directed = 0,
6982
Reciprocated = 1,
7083
Undirected = 2
7184
};
7285

73-
86+
/**
87+
* @enum IndexType
88+
* @brief Enumeration of possible index types for network analysis.
89+
*/
7490
enum IndexType {
7591
DC = 1,
7692
CC = 2,
@@ -86,31 +102,34 @@ enum IndexType {
86102
PP = 12
87103
};
88104

89-
105+
/**
106+
* @enum ChartType
107+
* @brief Enumeration of possible chart types for visualizing network data.
108+
*/
90109
enum ChartType {
91110
None = -1,
92111
Spline = 0,
93112
Area = 1,
94113
Bars = 2
95114
};
96115

116+
/**
117+
* @enum NetworkRequestType
118+
* @brief Enumeration of possible network request types.
119+
*/
97120
enum NetworkRequestType {
98121
Generic = 0,
99122
Crawler = 1,
100123
CheckUpdate = 2
101-
102124
};
103125

104-
105-
106126
static const int USER_MSG_INFO=0;
107127
static const int USER_MSG_CRITICAL=1;
108128
static const int USER_MSG_CRITICAL_NO_NETWORK=2;
109129
static const int USER_MSG_CRITICAL_NO_EDGES=3;
110130
static const int USER_MSG_QUESTION=4;
111131
static const int USER_MSG_QUESTION_CUSTOM=5;
112132

113-
114133
static const int SUBGRAPH_CLIQUE = 1;
115134
static const int SUBGRAPH_STAR = 2;
116135
static const int SUBGRAPH_CYCLE = 3;
@@ -131,109 +150,85 @@ static const int MATRIX_DISTANCES_JACCARD= 14;
131150
static const int MATRIX_DISTANCES_HAMMING= 15;
132151
static const int MATRIX_DISTANCES_CHEBYSHEV= 16;
133152

134-
135-
136-
137-
138-
153+
/**
154+
* @struct ClickedEdge
155+
* @brief Structure to hold information about a clicked edge in the network.
156+
*/
139157
struct ClickedEdge {
140-
int v1;
141-
int v2;
142-
int type;
158+
int v1; ///< First vertex of the edge
159+
int v2; ///< Second vertex of the edge
160+
int type; ///< Type of the edge
143161
};
144162

145-
146-
147163
typedef QPair<int, int> SelectedEdge;
148164

149-
165+
/**
166+
* @class MyEdge
167+
* @brief Class representing an edge in the network.
168+
*/
150169
class MyEdge {
151170
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-
}
168-
~MyEdge(){}
171+
int source; ///< Source vertex of the edge
172+
int target; ///< Target vertex of the edge
173+
double weight; ///< Weight of the edge
174+
int type; ///< Type of the edge
175+
double rWeight; ///< Reserved weight of the edge
176+
177+
MyEdge(); ///< Default constructor
178+
MyEdge(const int &from, const int &to, const double &w =0, const int &type=0, const double &rw = 0); ///< Parameterized constructor
179+
MyEdge(const MyEdge &edge); ///< Copy constructor
180+
~MyEdge(); ///< Destructor
169181
};
170182

171-
172183
/**
173-
* @brief Holds the distance to target. Used in Graph::dijkstra() priority_queue
184+
* @class GraphDistance
185+
* @brief Holds the distance to target. Used in Graph::dijkstra() priority_queue.
174186
*/
175187
class GraphDistance
176188
{
177189
public:
178-
int target;
179-
int distance;
180-
181-
GraphDistance(int t, int dist)
182-
: target(t), distance(dist)
183-
{
190+
int target; ///< Target vertex
191+
int distance; ///< Distance to the target vertex
184192

185-
}
193+
GraphDistance(int t, int dist); ///< Constructor
186194
};
187195

188-
189-
190196
/**
197+
* @class GraphDistancesCompare
191198
* @brief Metric to implement a min-priority queue.
192-
* The operator returns true if if t1 is closer than t2
193-
* Used in Graph::dijkstra() priority_queue
199+
* The operator returns true if t1 is closer than t2.
200+
* Used in Graph::dijkstra() priority_queue.
194201
*/
195202
class GraphDistancesCompare {
196203
public:
197-
bool operator()(GraphDistance& t1, GraphDistance& t2)
198-
{
199-
if (t1.distance == t2.distance)
200-
return t1.target > t2.target;
201-
return t1.distance > t2.distance; //minimum priority
202-
}
204+
bool operator()(GraphDistance& t1, GraphDistance& t2); ///< Comparison operator
203205
};
204206

205-
206-
207-
207+
/**
208+
* @class PairVF
209+
* @brief Class representing a pair of value and frequency.
210+
*/
208211
class PairVF
209212
{
210213
public:
211-
qreal value;
212-
qreal frequency;
214+
qreal value; ///< Value
215+
qreal frequency; ///< Frequency
213216

214-
PairVF(qreal v, qreal f)
215-
: value(v), frequency(f) { }
217+
PairVF(qreal v, qreal f); ///< Constructor
216218
};
217219

218-
219-
// implement a min-priority queue
220+
/**
221+
* @class PairVFCompare
222+
* @brief Implements a min-priority queue.
223+
*/
220224
class PairVFCompare {
221225
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-
}
226+
bool operator()(PairVF& v1, PairVF& v2); ///< Comparison operator
228227
};
229228

230-
231-
232229
SOCNETV_END_NAMESPACE
233230

234-
235231
Q_DECLARE_METATYPE(SOCNETV_NAMESPACE::MyEdge)
236232
Q_DECLARE_METATYPE(SOCNETV_NAMESPACE::NetworkRequestType)
237233

238-
239234
#endif // GLOBAL_H

0 commit comments

Comments
 (0)