-
Notifications
You must be signed in to change notification settings - Fork 1
/
examples.m
430 lines (361 loc) · 10.7 KB
/
examples.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
%% Examples accompying the simultaneous block diagonalization code sbd_fast.m
%% Including applications to synchronization patterns arising from symmetry clusters,
%% Laplacian clusters, input clusters, and chimera states in multilayer networks
clc;clear;
%%%%%%%%%%%%%%%%%%
% Network with 5 symmetry clusters (two intertwined) from
% L. M. Pecora, F. Sorrentino, A. M. Hagerstrom, T. E. Murphy, and R. Roy,
% Cluster synchronization and isolated desynchronization in complex networks with symmetries,
% Nat. Commun., 5 (2014), 4079.
%%%%%%%%%%%%%%%%%%
n = 11; %% size of the network
%% define adjacency matrix
adj = ones(n) - eye(n);
adj(1,5) = 0; adj(5,1) = 0;
adj(2,7) = 0; adj(7,2) = 0;
adj(3,9) = 0; adj(9,3) = 0;
adj(5,11) = 0; adj(11,5) = 0;
adj(8,10) = 0; adj(10,8) = 0;
adj(10,11) = 0; adj(11,10) = 0;
%% add noise/error to the matrix data
D{1} = adj + 1e-5*rand(n);
%% D{2} to D{6} are diagonal matrices that encode cluster info
%% e.g., node 1 and node 8 are in the same symmetry cluster
D{2} = zeros(n);
D{2}(1,1) = 1;
D{2}(8,8) = 1;
D{3} = zeros(n);
D{3}(4,4) = 1;
D{3}(6,6) = 1;
D{4} = zeros(n);
D{4}(2,2) = 1;
D{4}(3,3) = 1;
D{4}(7,7) = 1;
D{4}(9,9) = 1;
D{5} = zeros(n);
D{5}(5,5) = 1;
D{5}(10,10) = 1;
D{6} = zeros(n);
D{6}(11,11) = 1;
%% calculate orthogonal matrix for simultaneous block-diagonalization
P = sbd_fast(D,'real',1e-2);
for ii = 1:6
D{ii} = P' * D{ii} * P;
end
%% plot the matrices in common block-diagonal form
figure
colormap(flipud(colormap));
set(gcf, 'PaperPosition', [0 0 8 5]);
set(gcf, 'PaperSize', [8 5]);
for ii = 1:6
subplot(2,3,ii)
imagesc(D{ii});
caxis([-max(D{ii}(:)) max(D{ii}(:))])
colormap(lbmap(201,'RedWhiteBlue'))
set(gca,'XTick',[])
set(gca,'YTick',[])
end
%set(gca,'Visible','off');
saveas(gcf,'symmetry_cluster.pdf')
clc;clear;
%%%%%%%%%%%%%%%%%%
% Network with 2 Laplacian clusters from
% F. Sorrentino, L. M. Pecora, A. M. Hagerstrom, T. E. Murphy, and R. Roy,
% Complete characterization of the stability of cluster synchronization in complex dynamical networks,
% Sci. Adv., 2 (2016), e1501737
%%%%%%%%%%%%%%%%%%
n = 5; %% size of the network
%% define adjacency matrix
adj = ones(n) - eye(n);
adj(1,3) = 0; adj(3,1) = 0;
adj(2,4) = 0; adj(4,2) = 0;
%% define Laplacian matrix
rowsum = sum(adj,2);
laplacian = diag(rowsum) - adj;
%% add noise/error to the matrix data
D{1} = laplacian + 1e-5*rand(n);
%% D{2} and D{3} are diagonal matrices that encode cluster info
%% e.g., node 1, 3 and 5 are in the same Laplacian cluster
D{2} = zeros(n);
D{2}(1,1) = 1;
D{2}(3,3) = 1;
D{2}(5,5) = 1;
D{3} = zeros(n);
D{3}(2,2) = 1;
D{3}(4,4) = 1;
%% calculate orthogonal matrix for simultaneous block-diagonalization
P = sbd_fast(D,'real',1e-2);
for ii = 1:3
D{ii} = P' * D{ii} * P;
end
%% plot the matrices in common block-diagonal form
figure
colormap(flipud(colormap));
set(gcf, 'PaperPosition', [0 0 20 5]);
set(gcf, 'PaperSize', [20 5]);
for ii = 1:3
subplot(1,3,ii)
imagesc(D{ii});
caxis([-max(D{ii}(:)) max(D{ii}(:))])
colormap(lbmap(201,'RedWhiteBlue'))
set(gca,'XTick',[])
set(gca,'YTick',[])
end
%set(gca,'Visible','off');
saveas(gcf,'Laplacian_cluster.pdf')
clc;clear;
%%%%%%%%%%%%%%%%%%
% Network with 2 input clusters from
% M. T. Schaub, N. O’Clery, Y. N. Billeh, J.-C. Delvenne, R. Lambiotte, and M. Barahona,
% Graph partitions and cluster synchronization in networks of oscillators,
% Chaos, 26 (2016), 094821.
%%%%%%%%%%%%%%%%%%
n = 8; %% size of the matrices
%% define adjacency matrix
adj = [0,1,1,0,0,0,0,0;...
1,0,1,0,0,0,0,0;...
1,1,0,1,0,0,0,0;...
0,0,1,0,1,0,0,0;...
0,0,0,1,0,1,0,0;...
0,0,0,0,1,0,1,1;...
0,0,0,0,0,1,0,0;...
0,0,0,0,0,1,0,0];
%% define Laplacian matrix
rowsum = sum(adj,2);
laplacian = diag(rowsum) - adj;
%% add noise/error to the matrix data
D{1} = laplacian + 1e-5*rand(n);
%% D{2} and D{3} are diagonal matrices that encode cluster info
%% e.g., node 3 and node 6 are in the same equitable cluster
D{2} = zeros(n);
D{2}(3,3) = 1;
D{2}(6,6) = 1;
D{3} = eye(n) - D{2};
%% calculate orthogonal matrix for simultaneous block-diagonalization
P = sbd_fast(D,'real',1e-2);
for ii = 1:3
D{ii} = P' * D{ii} * P;
end
%% plot the matrices in common block-diagonal form
figure
colormap(flipud(colormap));
set(gcf, 'PaperPosition', [0 0 20 5]);
set(gcf, 'PaperSize', [20 5]);
for ii = 1:3
subplot(1,3,ii)
imagesc(D{ii});
caxis([-max(D{ii}(:)) max(D{ii}(:))])
colormap(lbmap(201,'RedWhiteBlue'))
set(gca,'XTick',[])
set(gca,'YTick',[])
end
%set(gca,'Visible','off');
saveas(gcf,'input_cluster.pdf')
clc;clear;
%%%%%%%%%%%%%%%%%%
% Network with 2 input clusters from Fig.1 of
% Y. Zhang and A. E. Motter,
% Symmetry-independent stability analysis of synchronization patterns,
% SIAM Rev. 62 817–836 (2020)
%%%%%%%%%%%%%%%%%%
n = 15; %% size of the matrices
%% define adjacency matrix
adj = [0,1,1,0,0,0,0,0,0,0,0,1,0,0,0;...
1,0,1,0,0,0,0,1,0,0,0,0,0,0,0;...
1,1,0,1,0,0,0,0,0,0,0,0,0,0,0;...
0,0,1,0,1,1,1,0,0,0,0,0,0,0,0;...
0,0,0,1,0,0,1,0,0,0,0,0,0,0,0;...
0,0,0,1,0,0,1,0,0,0,0,0,0,0,0;...
0,0,0,1,1,1,0,0,0,0,0,0,0,0,0;...
0,1,0,0,0,0,0,0,1,1,1,0,0,0,0;...
0,0,0,0,0,0,0,1,0,0,0,0,0,0,0;...
0,0,0,0,0,0,0,1,0,0,0,0,0,0,0;...
0,0,0,0,0,0,0,1,0,0,0,0,0,0,0;...
1,0,0,0,0,0,0,0,0,0,0,0,1,1,1;...
0,0,0,0,0,0,0,0,0,0,0,1,0,1,1;...
0,0,0,0,0,0,0,0,0,0,0,1,1,0,1;...
0,0,0,0,0,0,0,0,0,0,0,1,1,1,0];
%% define Laplacian matrix
rowsum = sum(adj,2);
laplacian = diag(rowsum) - adj;
%% add noise/error to the matrix data
D{1} = laplacian + 1e-5*rand(n);
%% D{2} and D{3} are diagonal matrices that encode cluster info
%% e.g., nodes 4, 8 and 12 are in the same equitable cluster
D{2} = zeros(n);
D{2}(4,4) = 1;
D{2}(8,8) = 1;
D{2}(12,12) = 1;
D{3} = eye(n) - D{2};
%% calculate orthogonal matrix for simultaneous block-diagonalization
P = sbd_fast(D,'real',1e-2);
for ii = 1:3
D{ii} = P' * D{ii} * P;
end
%% plot the matrices in common block-diagonal form
figure
colormap(flipud(colormap));
set(gcf, 'PaperPosition', [0 0 20 5]);
set(gcf, 'PaperSize', [20 5]);
for ii = 1:3
subplot(1,3,ii)
imagesc(D{ii});
caxis([-max(D{ii}(:)) max(D{ii}(:))])
colormap(lbmap(201,'RedWhiteBlue'))
set(gca,'XTick',[])
set(gca,'YTick',[])
end
%set(gca,'Visible','off');
saveas(gcf,'Sirev_fig1.pdf')
clc;clear;
%%%%%%%%%%%%%%%%%%
% Random network with 4 symmetry clusters from Fig.3 of
% Y. Zhang and A. E. Motter,
% Symmetry-independent stability analysis of synchronization patterns,
% SIAM Rev. 62 817–836 (2020)
%%%%%%%%%%%%%%%%%%
n = 30; %% size of the matrices
%% define adjacency matrix
adj = dlmread('random_net.txt');
%% add noise/error to the matrix data
D{1} = adj + 1e-5*rand(n);
%% D{2} to D{5} are diagonal matrices that encode cluster info
%% e.g., node 20 and node 24 are in the same symmetry cluster
D{2} = zeros(n);
D{2}(20,20) = 1;
D{2}(24,24) = 1;
D{3} = zeros(n);
D{3}(2,2) = 1;
D{3}(10,10) = 1;
D{3}(16,16) = 1;
D{3}(30,30) = 1;
D{4} = zeros(n);
D{4}(3,3) = 1;
D{4}(6,6) = 1;
D{4}(7,7) = 1;
D{4}(11,11) = 1;
D{5} = eye(n) - D{2} - D{3} - D{4};
%% calculate orthogonal matrix for simultaneous block-diagonalization
P = sbd_fast(D,'real',1e-2);
for ii = 1:5
D{ii} = P' * D{ii} * P;
end
%% plot the matrices in common block-diagonal form
figure
colormap(flipud(colormap));
set(gcf, 'PaperPosition', [0 0 8 5]);
set(gcf, 'PaperSize', [8 5]);
for ii = 1:5
subplot(2,3,ii)
imagesc(D{ii});
caxis([-max(D{ii}(:)) max(D{ii}(:))])
colormap(lbmap(201,'RedWhiteBlue'))
set(gca,'XTick',[])
set(gca,'YTick',[])
end
%set(gca,'Visible','off');
saveas(gcf,'Sirev_fig3.pdf')
clc;clear;
%%%%%%%%%%%%%%%%%%
% Chimera states in a multilayer network from Fig.4 of
% Y. Zhang and A. E. Motter,
% Symmetry-independent stability analysis of synchronization patterns,
% SIAM Rev. 62 817–836 (2020)
%%%%%%%%%%%%%%%%%%
n = 6; %% size of the matrices representing each layer
%% first-layer subnetwork
adj1 = [0,1,0,0,1,1;...
1,0,0,0,1,0;...
0,0,0,1,1,0;...
0,0,1,0,1,1;...
1,1,1,1,0,0;...
1,0,0,1,0,0];
%% second-layer subnetwork
adj2 = [0,1,0,1,0,0;...
1,0,1,0,1,0;...
0,1,0,1,1,0;...
1,0,1,0,1,0;...
0,1,1,1,0,1;...
0,0,0,0,1,0];
%% adjacency matrices representing the interlayer and intralayer connections
aij1 = [adj1,zeros(n); zeros(n),adj2];
aij2 = [zeros(n),ones(n); ones(n),zeros(n)];
%% laplacian matrices representing the interlayer and intralayer connections
rowsum = sum(aij1,2);
laplacian1 = diag(rowsum) - aij1;
rowsum = sum(aij2,2);
laplacian2 = diag(rowsum) - aij2;
%% add noise/error to the matrix data
D{1} = laplacian1 + 1e-5*rand(2*n);
D{2} = laplacian2 + 1e-5*rand(2*n);
%% D{3} and D{4} are diagonal matrices that encode cluster info
%% e.g., nodes 1 to n are in the same cluster
D{3} = zeros(2*n);
for i = 1:n
D{3}(i,i) = 1;
end
D{4} = zeros(2*n);
for i = 1:n
D{4}(n+i,n+i) = 1;
end
%% calculate orthogonal matrix for simultaneous block-diagonalization
P = sbd_fast(D,'real',1e-2);
for ii = 1:4
D{ii} = P' * D{ii} * P;
end
%% plot the matrices in common block-diagonal form
figure
colormap(flipud(colormap));
set(gcf, 'PaperPosition', [0 0 12 12]);
set(gcf, 'PaperSize', [12 12]);
for ii = 1:4
subplot(2,2,ii)
imagesc(D{ii});
caxis([-max(D{ii}(:)) max(D{ii}(:))])
colormap(lbmap(201,'RedWhiteBlue'))
set(gca,'XTick',[])
set(gca,'YTick',[])
end
%set(gca,'Visible','off');
saveas(gcf,'Sirev_fig4b.pdf')
%% We now study the 7-cluster pattern in the same multilayer network
D{1} = laplacian1 + 1e-5*rand(2*n);
D{2} = laplacian2 + 1e-5*rand(2*n);
%% D{3} to D{9} are diagonal matrices that encode cluster info
%% e.g., nodes 1 to n are in the same cluster
D{3} = zeros(2*n);
for i = 1:n
D{3}(i,i) = 1;
end
D{4} = zeros(2*n);
D{4}(n+1,n+1) = 1;
D{5} = zeros(2*n);
D{5}(n+2,n+2) = 1;
D{6} = zeros(2*n);
D{6}(n+3,n+3) = 1;
D{7} = zeros(2*n);
D{7}(n+4,n+4) = 1;
D{8} = zeros(2*n);
D{8}(n+5,n+5) = 1;
D{9} = zeros(2*n);
D{9}(n+6,n+6) = 1;
%% calculate orthogonal matrix for simultaneous block-diagonalization
P = sbd_fast(D,'real',1e-2);
for ii = 1:9
D{ii} = P' * D{ii} * P;
end
%% plot the matrices in common block-diagonal form
figure
colormap(flipud(colormap));
set(gcf, 'PaperPosition', [0 0 12 12]);
set(gcf, 'PaperSize', [12 12]);
for ii = 1:9
subplot(3,3,ii)
imagesc(D{ii});
caxis([-max(D{ii}(:)) max(D{ii}(:))])
colormap(lbmap(201,'RedWhiteBlue'))
set(gca,'XTick',[])
set(gca,'YTick',[])
end
%set(gca,'Visible','off');
saveas(gcf,'Sirev_fig4c.pdf')