-
Notifications
You must be signed in to change notification settings - Fork 1
/
NetworkTopology.c
90 lines (74 loc) · 2.15 KB
/
NetworkTopology.c
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
#include "GeneralIncludes.h"
#include "NetworkTopology.h"
//#include "LIFNeuron.h"
#include "NumericalTools.h"
// topology 0 is a totally disconnected network (for simulator testing)
int topology0(signed int **adj, int no_neurons, long random_seed){
int i, j;
for (i = 0; i < no_neurons; i++){
for (j = 0; j < no_neurons; j++){
adj[i][j] = -1;
}
}
return 0;
}
// topology 1 is an all-to-all connected network, including self-connections
int topology1(signed int **adj, int no_neurons, long random_seed){
int i, j;
int index = 0;
for (i = 0; i < no_neurons; i++){
for (j = 0; j < no_neurons; j++){
//printf("%d ", adj[i][j]);
adj[i][j] = index;
index++;
}
//printf("\n");
}
return index;
}
// topology 2 is an all-to-all connected network, with no self-connections
int topology2(signed int **adj, int no_neurons, long random_seed){
int i, j;
int index = 0;
for (i = 0; i < no_neurons; i++){
for (j = 0; j < no_neurons; j++){
//printf("%d ", adj[i][j]);
if (i != j){
adj[i][j] = index;
index++;
}
else{
adj[i][j] = -1;
}
}
//printf("\n");
}
return index;
}
// topology 10 : the probability of a connection from a->b is 0.1, no self connections
int topology10(signed int **adj, int no_neurons, long random_seed){
int i, j;
int index = 0;
float ran;
for (i = 0; i < no_neurons; i++){
for (j = 0; j < no_neurons; j++){
if (i != j){
ran = ran2(&random_seed);
if ((ran) < 0.100000001){
//printf("DEBUG: ran (a) %f\n", ran);
adj[i][j] = index;
index++;
}
else{
//printf("DEBUG: ran (b) %f\n", ran);
adj[i][j] = -1;
}
}
else{
//printf("DEBUG: on diagonal, no self connections\n");
adj[i][j] = -1;
}
}
}
return index;
}