-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraph_modular_betadist.m
57 lines (51 loc) · 1.48 KB
/
graph_modular_betadist.m
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
function adj = graph_modular_betadist(d, c, aa, bb)
% Generate random modular network introduced in
% Anand, D.V., Das, S., Dakurah, S., Chung, M.K. 2022
% Hodge-Decomposition of Brain Networks.
%
% INPUT
% d : number of nodes
% c : number of clusters/modules
% aa : alpha parameter for Beta distribution
% bb : beta parameter for Beta distribution
%
% OUTPUT
% adj : randomly weighted adjacency matrix using the Beta distribution
%
%
% %If you are using any part of the code, please reference the above paper.
%
% (C) 2022 Anand, D.V., Chung, M.K.
% University of Wisconsin-Madison
%
% Contact [email protected] for
% for support/permission with the codes
%
% Update history
% April, 2022 created - Vijay Anand D
% adjacency matrix
adj = zeros(d);
% nodes are evenly distributed among modules
modules = cell(c, 1);
for k = 1:c
modules{k} = round((k-1)*d/c+1):round(k*d/c);
end
for i = 1:d
for j = i + 1:d
module_i = ceil(c*i/d); % the module of node i
module_j = ceil(c*j/d); % the module of node j
% check if nodes i and j belongs to the same module
if module_i == module_j
% edge values for attachment within module
p = betarnd(aa, bb);
adj(i, j) = p;
adj(j, i) = p;
else
% edge values for attachment between modules
q = betarnd(bb, aa);
adj(i, j) = q;
adj(j, i) = q;
end
end
end
end