-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerateDsbm.m
28 lines (23 loc) · 946 Bytes
/
generateDsbm.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
function W = generateDsbm(C,P,directed)
%generateDsbm Generate realization of dynamic stochastic block model
% generateDsbm(C,P) generates a sequence of adjacency matrices
% where each adjacency matrix is a realization of a stochastic block
% model with class memberships given by a column of C and block
% probabilities given by a slice (third dimension) of P. Nodes that are
% not present at a particular time are denoted by zeros in the
% corresponding column of C.
%
% generateDsbm(C,P,directed) allows for creation of direted graphs
% by setting directed to true. By deafult, undirected graphs are created.
% Author: Kevin S. Xu
% Set as undirected graph by default
if nargin == 2
directed = false;
end
[n,tMax] = size(C);
W = zeros(n,n,tMax);
% Generate realization of stochastic block model at each time step
for t = 1:tMax
W(:,:,t) = generateSbm(C(:,t),P(:,:,t),directed);
end
end