-
Notifications
You must be signed in to change notification settings - Fork 3
/
Network.h
127 lines (100 loc) · 5.22 KB
/
Network.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
------------------------------------------------
Copyright (C) 2015-2016 by Jorge C. Valverde-Rebaza
Email: jvalverr@icmc.usp.br
This file is part of LPsource.
LPsource is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
LPsource is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should
have received a copy of the GNU General Public License along with LPsource. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------
*/
#ifndef NETWORK_H_INCLUDED
#define NETWORK_H_INCLUDED
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <math.h>
#include <time.h>
#include <cstdlib>
#include <stdio.h>
#include <limits>
#include "Structures.h"
using namespace std;
class Network {
private:
unsigned int numEdges;
unsigned int numNodes;
unsigned int maxPathLength;
long maxNumFriendsPerUser;
bool isWeighted;
vector<Node> Users; //list of all users
vector<Group> Groups; //list of user groups
vector<Link> TestLinks; //list of all test links
//methods
void sortNeighborsOfUsers();
void sortGroupsOfUsers();
public:
Network();
~Network();
Network& operator=( const Network& );
double getSampleCorrelationCoefficient(vector<vector<double> >&, vector<vector<double> >&) const;
double getSampleCorrelationCoefficient(vector<double>&, vector<double>&) const;
//reads
void readLinksFile ( const char* );
void readGroupsFile ( const char* );
void readLinkGroupsFile ( const char* );
void readWeightedLinksFile ( const char* );
//prints
void printLinksList ( ostream& );
void printLinksTest ( ostream& );
void printWeightedLinksTest ( ostream& );
void printGroups ( ostream& );
void printStatistics( ostream& );
//sample
void edgeRandomSubSampling( double );
void setTestLinksList(vector<Link>);
void sortLinkListTest();
//structural properties
bool hasEdge( index_v, index_v ) const;
bool isNetworkWeighted() const;
double getWeight( index_v, index_v) const;
double getStrengthOfNode( index_v ) const;
unsigned int getNumUsers() const;
unsigned int getDegree( index_v ) const;
unsigned int getDiameter();
unsigned long getNumEdgesFriendshipGraph();
long getMaxNumberFriendsPerUser();
double getAverageFriendsPerUser();
double getAverageDegree() const;
double getClusteringCoefficient( index_v ) const;
double getAverageClusteringCoefficient() const;
double getAverageAssortativityCoefficient() const;
double getHeterogeneity() const;
double getAveragePathLenght();
vector<index_v> getNeighbors( index_v ) const;
vector<index_v> getNeighbors( index_v, unsigned int ) const;
vector<index_v> getShortestPathLengths() const;
vector<index_v> getPathLengths( index_v ) const;
vector<index_v> intersect(vector<index_v>, vector<index_v>) const;
vector<long> intersect(vector<long>, vector<long>) const;
vector<index_v> junction (vector<index_v>, vector<index_v>) const;
vector<Link> getTrainLinks() const;
//group properties
unsigned int getNumberOfGroups() const;
unsigned int getOverlappingGroupsDegree(index_v) const;
long getIndexGroup( index_g );
double getAverageGroupMembershipPerUser() const;
double getAverageGroupSize() const;
double getAverageOverlappingGroupsDegree() const;
double getAverageGroupClusteringCoefficient() const;
double getGroupClusteringCoefficient(Group) const;
double getOverlappingGroupsClusteringCoefficient( index_v ) const;
double getAverageOverlappingGroupsClusteringCoefficient() const;
vector<index_v> getOverlappingGroupsNeighbors(index_v) const;
vector<index_g> getGroups( index_v ) const;
};
#endif // NETWORK_H_INCLUDED