-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTalk-of-the-network.cpp
86 lines (59 loc) · 1.6 KB
/
Talk-of-the-network.cpp
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
#include <Rcpp.h>
using Rcpp::List;
using Rcpp::LogicalVector;
using Rcpp::IntegerVector;
using std::vector;
// [[Rcpp::plugins("cpp11")]]
//[[Rcpp::export]]
vector<List> initialize(const List& g, const int& n_subgraphs) {
vector<List> G;
for (int i = 0; i < n_subgraphs; ++i) {
G.push_back(g);
}
return G;
}
//[[Rcpp::export]]
vector<LogicalVector> reset(const vector<List>& G) {
vector<LogicalVector> node_status;
for (auto& g : G) {
LogicalVector ns;
for (int i = 0; i < g.length(); ++i) {
ns.push_back(false);
}
node_status.push_back(ns);
}
return node_status;
}
//[[Rcpp::export]]
int count_active_str_ties(const vector<List>& G,
const int& node_network_id,
const int& node,
const vector<LogicalVector>& node_status) {
int n_active_str_ties = 0;
IntegerVector nbrs = G[node_network_id][node];
for (auto& nbr : nbrs) {
if (node_status[node_network_id][nbr] == true)
n_active_str_ties++;
}
return n_active_str_ties;
}
int random_meetings(const vector<List>& G,
const int& node_network_id,
const int& node,
const vector<LogicalVector>& node_status,
const int& n_weak_ties) {
int n_active_wk_ties;
IntegerVector all_network_ids;
auto it = G.begin();
while (it != G.end()) {
++it;
}
return n_active_wk_ties;
}
/*** R
library(igraph)
g <- make_full_graph(5, loops = FALSE)
G <- initialize(neighborhood(g), 2)
ns <- reset(G)
ns
*/