-
Notifications
You must be signed in to change notification settings - Fork 8
/
SBEGUI.m
executable file
·3790 lines (3260 loc) · 137 KB
/
SBEGUI.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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = SBEGUI(varargin)
% SBEGUI M-network for SBEGUI.fig
% SBEGUI, by itself, creates a new SBEGUI or raises the existing
% singleton*.
%
% H = SBEGUI returns the handle to a new SBEGUI or the handle to
% the existing singleton*.
%
% SBEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SBEGUI.M with the given input arguments.
%
% SBEGUI('Property','Value',...) creates a new SBEGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before SBEGUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to SBEGUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Statistics menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
%
% Edit the above text to modify the response to help SBEGUI
%
% Systems Biology and Evolution Toolbox (SBEToolbox).
% Authors: Kranti Konganti, James Cai.
% (C) Texas A&M University.
%
% $LastChangedDate: 2013-06-26 10:09:36 -0500 (Wed, 26 Jun 2013) $
% $LastChangedRevision: 742 $
% $LastChangedBy: konganti $
%
% Last Modified by GUIDE v2.5 27-Nov-2013 08:44:06
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SBEGUI_OpeningFcn, ...
'gui_OutputFcn', @SBEGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before SBEGUI is made visible.
function SBEGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to SBEGUI (see VARARGIN)
% Choose default command line output for SBEGUI
handles.output = hObject;
global deduced_net;
%scrsz=get(0,'ScreenSize');
%pos_act=get(gcf,'Position');
%xr=scrsz(3)-pos_act(3);
%xp=round(xr/2);
%yr=scrsz(4)-pos_act(4);
%yp=round(yr/2);
%set(gcf,'position',[xp yp pos_act(3) pos_act(4)]);
%waitH = askScreenPreference;
%if ~strcmp(waitH, 'noWait'), waitfor(waitH); end
%disp(getpref('SBEToolbox', 'useMonitor'));
%set(0, 'DefaultFigurePosition', getpref('SBEToolbox', 'useMonitor'));
%set(gcf, 'units', 'pixels', ...
% 'Position', getpref('SBEToolbox', 'useMonitor'));
movegui(gcf, 'center');
if ~isempty(deduced_net)
clear global deduced_net;
end
% --------------------------------------------------------------------
% User preferences
% --------------------------------------------------------------------
if ispref('SBEToolbox', 'installPath')
cd(getpref('SBEToolbox', 'installPath'))
else
addpref('SBEToolbox', 'installPath', fileparts(which(mfilename)));
end
if ~ispref('SBEToolbox', 'LoadDeducedNetworkUserPref')
addpref('SBEToolbox', 'LoadDeducedNetworkUserPref', 0);
end
if getpref('SBEToolbox', 'LoadDeducedNetworkUserPref') == 1
set(handles.LoadDeducedNetwork, 'enable', 'off');
set(handles.LoadDeducedNetwork, 'checked', 'on');
end
if ~ispref('SBEToolbox', 'SaveWindowOutput2File')
addpref('SBEToolbox', 'SaveWindowOutput2File', 0);
end
if getpref('SBEToolbox', 'SaveWindowOutput2File') == 1
set(handles.WantToExportResultFile, 'checked', 'on');
end
if ~ispref('SBEToolbox', 'CopyWindowOutput2Clipboard')
addpref('SBEToolbox', 'CopyWindowOutput2Clipboard', 0);
end
if getpref('SBEToolbox', 'CopyWindowOutput2Clipboard') == 1
set(handles.WantToExportResultToClipboard, 'checked', 'on');
end
if ~ispref('SBEToolbox', 'ExportWindowOutput2Workspace')
addpref('SBEToolbox', 'ExportWindowOutput2Workspace', 0);
end
if getpref('SBEToolbox', 'ExportWindowOutput2Workspace') == 1
set(handles.WantToExportResultToClipboard, 'checked', 'on');
end
if ~ispref('SBEToolbox', 'ShowGraphInset')
addpref('SBEToolbox', 'ShowGraphInset', 0);
end
if getpref('SBEToolbox', 'ShowGraphInset') == 1
set(handles.alwaysViewGraphInset, 'checked', 'on');
end
if ~ispref('SBEToolbox', 'isRestore')
addpref('SBEToolbox', 'isRestore', 0);
end
if ~ispref('SBEToolbox', 'largestconnnetCalled')
addpref('SBEToolbox', 'largestconnnetCalled', 0);
end
if ~ispref('SBEToolbox', 'ShowGraphInset')
addpref('SBEToolbox', 'ShowGraphInset', 0);
end
if ~ispref('SBEToolbox', 'pluginexe')
addpref('SBEToolbox', 'pluginexe', '');
end
if ~ispref('SBEToolbox', 'filedir')
addpref('SBEToolbox', 'filedir', '');
end
if ~ispref('SBEToolbox', 'filename')
addpref('SBEToolbox', 'filename', '');
end
if ~ispref('SBEToolbox', 'graph_gui')
addpref('SBEToolbox', 'graph_gui', '');
end
if ~ispref('SBEToolbox', 'graph_gui_drawn')
addpref('SBEToolbox', 'graph_gui_drawn', '');
end
if ~ispref('SBEToolbox', 'annotation_db')
addpref('SBEToolbox', 'annotation_db', '');
end
if ~ispref('SBEToolbox', 'InitMatlabMemUsedMB')
addpref('SBEToolbox', 'InitMatlabMemUsedMB', 0);
end
if ~ispref('SBEToolbox', 'RandomEvolutionUserPref')
addpref('SBEToolbox', 'RandomEvolutionUserPref', 0);
end
if ~ispref('SBEToolbox', 'isPluginNetworkReload')
addpref('SBEToolbox', 'isPluginNetworkReload', 0);
end
if ~ispref('SBEToolbox', 'NetEvolMsg')
addpref('SBEToolbox', 'NetEvolMsg', 'Network Evolved (?)');
else
setpref('SBEToolbox', 'NetEvolMsg', 1);
end
if isempty(getpref('SBEToolbox', 'annotation_db'))
annotate_nodes;
end
% Users don't need gory details about update process
%hideSBEToolboxUpdate
% Timer function for memory monitoring
if ~isempty(timerfindall('Name', 'SBEGUI_CurrentMemUsage'))
delete(timerfindall('Name', 'SBEGUI_CurrentMemUsage'));
end
memT = timer('Name', 'SBEGUI_CurrentMemUsage', 'ExecutionMode', ...
'fixedRate', 'Period', 1, 'BusyMode', 'queue', ...
'ObjectVisibility', 'off', 'TimerFcn', ...
{@updateMemoryUsage, handles});
start(memT);
% --------------------------------------------------------------------
% Update handles structure
% --------------------------------------------------------------------
guidata(hObject, handles);
checkisRandomEvolution(handles);
SetMenuStatus(handles);
% UIWAIT makes SBEGUI wait for user response (see UIRESUME)
% uiwait(handles.SBEToolboxGUI);
% --------------------------------------------------------------------
function WorkspaceOutput_Callback(hObject, eventdata, handles)
% hObject handle to WorkspaceOutput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of WorkspaceOutput as text
% str2double(get(hObject,'String')) returns contents of WorkspaceOutput as a double
% --- Executes during object creation, after setting all properties.
function WorkspaceOutput_CreateFcn(hObject, eventdata, handles)
% hObject handle to WorkspaceOutput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Outputs from this function are returned to the command line.
function varargout = SBEGUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function Network_Callback(hObject, eventdata, handles)
% hObject handle to Network (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SetMenuStatus(handles);
% --------------------------------------------------------------------
function Statistics_Callback(hObject, eventdata, handles)
% hObject handle to Statistics (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SetMenuStatus(handles);
% --------------------------------------------------------------------
function Help_Callback(hObject, eventdata, handles)
% hObject handle to Help (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SetMenuStatus(handles);
% --------------------------------------------------------------------
function NetworkOpenMATFile_Callback(hObject, eventdata, handles)
% hObject handle to NetworkOpenMATFile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode retFname
set(handles.StatusBar, 'String', 'Busy');
retFname_old = retFname;
[sbeG,sbeNode,retFname]=opensbematfile;
sbeG = sparse(sbeG);
if ~isempty(sbeG)
guiOutput = i_dispheader_gui('Network loaded from MAT file!',...
2);
guiOutput = viewnetinfo_gui(sbeG, guiOutput);
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
writenetsession(sbeG, sbeNode, 'sbeVars');
setpref('SBEToolbox', 'largestconnnetCalled', 0);
setpref('SBEToolbox', 'isRestore', 0);
else
[sbeG, sbeNode] = getcurrentnetsession;
retFname = retFname_old;
end
SetMenuStatus(handles);
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function NetworkExit_Callback(hObject, eventdata, handles)
% hObject handle to NetworkExit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear global sbeG sbeNode deduced_net retFname sbeG_ori sbeNode_ori;
clear functions;
writenetsession([], [], 'sbeVars');
writenetsession([], [], 'sbeLargeConnNet');
writenetsession([], [], 'sbeEdit');
close;
% --------------------------------------------------------------------
function HelpHelpContents_Callback(hObject, eventdata, handles)
% hObject handle to HelpHelpContents (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%helpwin sbetoolbox;
%if ispc
% help_dir = '.\\help\\';
% if ((exist('.\\help', 'dir')) ~= 7)
% help_dir = '..\\help\\';
% end
%else
% help_dir = './help/';
% if ((exist('./help', 'dir')) ~= 7)
% help_dir = '../help/';
% end
%end
web('Contents.html', '-browser');
%web('http://sbetoolbox.sourceforge.net/Contents.html', '-browser');
% --------------------------------------------------------------------
function StatCentralityBetweenness_Callback(hObject, eventdata, handles)
% hObject handle to StatCentralityBetweenness (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode
set(handles.StatusBar, 'String', 'Busy');
if isbig(sbeG), h=waitbar(0.5, 'Please wait...'); end
%if isbig(sbeG), h=waitbar2a(0.5,'Please wait...', 'BarColor', 'g'); end
try
data=betweenness_centrality(double(sparse(sbeG)));
guiOutput = i_dispheader_gui('Betweenness Centrality', size(sbeG, 1));
for k=1:size(sbeG,1)
guiHeaderOffset = k + 1;
guiOutput{guiHeaderOffset} = sprintf('Node%04d\t%s\t%g',...
k,sbeNode{k}, data(k));
end
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
i_conditionalexportresult(handles,data,sbeNode);
%plot_histcurve(data, 1, 'Betweenness Centrality Distribution', ...
% 'log_1_0(betweenness centrality)', 'nodes');
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
%{
function StatCentralityCurrentInformationFlow_Callback(hObject, eventdata, handles)
% hObject handle to StatCentralityCurrentInformationFlow (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode
set(handles.StatusBar, 'String', 'Busy');
try
warning off;
[~,data]=current_info_flow(sbeG,1,true);
guiOutput = i_dispheader_gui('Current Information Flow (Missiuro et al 2009)', ...
size(sbeG, 1));
for k=1:size(sbeG,1)
guiHeaderOffset = k + 1;
guiOutput{guiHeaderOffset} = sprintf('Node%04d\t%s\t%g',k,sbeNode{k},data(k));
end
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
i_conditionalexportresult(handles,data,sbeNode);
warning on;
catch exception
errordlg(exception.message);
set(handles.StatusBar, 'String', 'Ready');
warning on;
return;
end
set(handles.StatusBar, 'String', 'Ready');
%}
% --------------------------------------------------------------------
function StatClusteringCoefficient_Callback(hObject, eventdata, handles)
% hObject handle to StatClusteringCoefficient (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode
set(handles.StatusBar, 'String', 'Busy');
if isbig(sbeG), h=waitbar(0.5, 'Please wait...'); end
% h = waitbar(0,'1','Name','Computing Clustering Coefficient...',...
% 'CreateCancelBtn',...
% 'setappdata(gcbf,''canceling'',1)');
% setappdata(h,'canceling',0)
try
data=clustering_coefficients(double(sparse(sbeG)));
guiOutput = i_dispheader_gui('Clustering Coefficient [CLUSTERING_COEFFICIENTS.m]', ...
size(sbeG, 1));
for k=1:size(sbeG,1)
guiHeaderOffset = k + 1;
guiOutput{guiHeaderOffset} = sprintf('Node%04d\t%s\t%g',k,sbeNode{k},data(k));
end
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
i_conditionalexportresult(handles,data,sbeNode);
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
function i_conditionalexportresult(handles,data,nodename)
set(handles.StatusBar, 'String', 'Busy');
if (i_WantToExport(handles)),
%filename=tempname;
writeattribute2tab(data,nodename);
%edit(filename);
end
if (i_WantToCopy(handles)),
if iscell(data)
warndlg(['Seems like the output is stored as Cell Array.',...
' Try to Save results or Export as a variable to Matlab workspace.'],...
'Warning!');
return;
end
selection = questdlg('Do you want to copy result into clipboard?',...
'Pressing Yes will clear memory',...
'Yes','No','No');
switch selection,
case 'Yes',
num2clip(data);
otherwise
% do nothing
end
end
if (i_WantToAssign(handles))
export2wsdlg({'Assign node list to variable named:',...
'Assign result to variable named:'},...
{'sbeNode','sbeOut'},{nodename,data},...
'Save to Workspace');
end
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function Edit_Callback(hObject, eventdata, handles)
% hObject handle to Edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SetMenuStatus(handles);
% --------------------------------------------------------------------
function Layout_Callback(hObject, eventdata, handles)
% hObject handle to Layout (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SetMenuStatus(handles);
% --------------------------------------------------------------------
function HelpDemo_Callback(hObject, eventdata, handles)
% hObject handle to HelpDemo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SetMenuStatus(handles);
% --------------------------------------------------------------------
function StatNetworkSummary_Callback(hObject, eventdata, handles)
% hObject handle to StatNetworkSummary (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG;
guiOutput = i_dispheader_gui('Network Summary',2);
guiOutput = viewnetinfo_gui(sbeG, guiOutput);
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
set(handles.StatusBar, 'String', 'Ready');
%{
set(handles.StatusBar, 'String', 'Busy');
%[y]=isgsymmetric(sbeG);
%fprintf('Is symmetric: %d\n',y);
h=waitbar(0, 'Please wait...');
%try
guiOutput = i_dispheader_gui('Network Summary', 7);
waitbar(0.2, h);
guiOutput = viewnetinfo_gui(sbeG, guiOutput);
waitbar(0.4, h);
guiOutput{4} = sprintf('Average Distance: %.3f',graph_meandist(sbeG));
waitbar(0.6, h);
[Diam,Rad]=graph_diameter(sbeG);
waitbar(0.8, h);
guiOutput{5} = sprintf('Diameter: %d',Diam);
guiOutput{6} = sprintf('Radius: %d',Rad);
guiOutput{7} = sprintf('Efficiency: %.3f',graph_efficiency(sbeG));
waitbar(0.9, h);
%catch exception
% errordlg(exception.message);
%if exist('h','var'), close(h); end
%set(handles.StatusBar, 'String', 'Ready');
%return;
%end
if isbig(sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
set(handles.WorkspaceOutput, 'String', guiOutput);
set(handles.StatusBar, 'String', 'Ready');
%}
% --------------------------------------------------------------------
function StatDistanceBtw2Nodes_Callback(hObject, eventdata, handles)
% hObject handle to StatDistanceBtw2Nodes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode
set(handles.StatusBar, 'String', 'Busy');
%prompt={'Node 1:','Node 2:'};
%def={'1','2'};
%dlgTitle='Distance (Shortest Path) Between Nodes';
%lineNo=1;
%options.Resize='on';
%options.WindowStyle='normal';
%answer=inputdlg(prompt,dlgTitle,lineNo,def,options);
n1 = Search(sbeNode, 'Select node 1: ');
if ~n1, set(handles.StatusBar, 'String', 'Ready'); return; end
n2 = Search(sbeNode, 'Select node 2: ');
%[n1,selected] = listdlg('Name','Nodes in network',...
% 'PromptString','Select node 1:',...
% 'SelectionMode','single',...
% 'ListString',sbeNode);
%if ~selected, return; end
%[n2,selected] = listdlg('Name','Nodes in network',...
% 'PromptString','Select node 2:',...
% 'SelectionMode','single',...
% 'ListString',sbeNode);
% if ~selected, return; end
if n1>0 && n2>0
%D=shortest_paths(double(sparse(sbeG)),n1);
if isbig(sbeG), h=waitbar(0.5, 'Please wait...'); end
try
D=shortest_paths(double(sparse(sbeG)),n1,struct('target',n2));
guiOutput = i_dispheader_gui(sprintf('Distance (Shortest Path)\nbetween %s and %s',...
sbeNode{n1},sbeNode{n2}),1);
guiOutput{2} = sprintf('%d',D(n2));
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
else
set(handles.StatusBar, 'String', 'Ready');
return;
end
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function StatGraphAverageDistance_Callback(hObject, eventdata, handles)
% hObject handle to StatGraphAverageDistance (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG
set(handles.StatusBar, 'String', 'Busy');
if isbig(sbeG), h=waitbar(0.5, 'Please wait...'); end
try
[out]=graph_meandist(sbeG);
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(sbeG), waitbar(1, h); close(h); end
guiOutput = i_dispheader_gui(...
'Average Graph Distance [GRAPH_MEANDIST.m]',0);
guiOutput{2} = sprintf('%g', out);
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function StatGraphDiameter_Callback(hObject, eventdata, handles)
% hObject handle to StatGraphDiameter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG
set(handles.StatusBar, 'String', 'Busy');
if isbig(sbeG), h=waitbar(0.5, 'Please wait...'); end
try
if issparse(sbeG) && islogical(sbeG), sbeG=double(sbeG); end
[out]=graph_diameter(sbeG);
if issparse(sbeG) && ~islogical(sbeG), sbeG=logical(sbeG); end
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
guiOutput=i_dispheader_gui('Graph Diameter [GRAPH_DIAMETER.m]',0);
guiOutput{2} = sprintf('%g', out);
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function ViewDistanceMatrix_Callback(hObject, eventdata, handles)
% hObject handle to ViewDistanceMatrix (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG deduced_net
set(handles.StatusBar, 'String', 'Busy');
userWantsToLoadDeducedNetwork = loadDeducedClustersForPlotting(handles);
if (userWantsToLoadDeducedNetwork && ~isempty(deduced_net))
plot_sbeG = deduced_net;
else
plot_sbeG = sbeG;
end
if isbig(plot_sbeG), h=waitbar(0.5, 'Please wait...'); end
try
[D]=all_shortest_paths(double(sparse(plot_sbeG)));
figure;
imagesc(D);
axis square;
x=gray; x=x(end:-1:1,:);
colormap(x);
colorbar;
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(plot_sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function NetworkNew_Callback(hObject, eventdata, handles)
% hObject handle to NetworkNew (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode retFname
set(handles.StatusBar, 'String', 'Busy');
retFname_old = retFname;
sbeG_ori_bNew = sbeG;
sbeNode_ori_bNew = sbeNode;
sbeNode = [];
g=graph_gui;
waitfor(g);
if getpref('SBEToolbox', 'graph_gui') == 1
if ~isempty(sbeG)
retFname = 'New network created !';
guiOutput = i_dispheader_gui(retFname, 2);
guiOutput = viewnetinfo_gui(sbeG, guiOutput);
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
writenetsession(sbeG, sbeNode, 'sbeVars');
setpref('SBEToolbox', 'filename', 'Drawn New Network');
else
[sbeG, sbeNode] = getcurrentnetsession;
end
else
retFname = retFname_old;
sbeG = sbeG_ori_bNew;
sbeNode = sbeNode_ori_bNew;
end
clear sbeG_ori_bNew sbeNode_ori_bNew;
SetMenuStatus(handles);
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function ViewAdjacencyMatrix_Callback(hObject, eventdata, handles)
% hObject handle to ViewAdjacencyMatrix (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG deduced_net
set(handles.StatusBar, 'String', 'Busy');
userWantsToLoadDeducedNetwork = loadDeducedClustersForPlotting(handles);
if (userWantsToLoadDeducedNetwork && ~isempty(deduced_net))
plot_sbeG = deduced_net;
else
plot_sbeG = sbeG;
end
if (size(plot_sbeG, 1) > 4000)
h=waitbar(0, 'Please wait...');
end
try
%guiOutput = i_dispheader_gui('Showing Adjacency Matrix ... ', ...
% size(sbeG, 1));
%guiOutput = viewnetinfo_gui(sbeG, guiOutput);
%for k = 1:size(sbeG, 1)
% guiHeaderOffset = k + 3;
% if issparse(sbeG(k,:))
% kr = full(sbeG(k,:));
% end
% guiOutput{guiHeaderOffset} = sprintf('%d',kr);
%if (size(sbeG, 1) > 4000)
% waitbar(k/size(sbeG, 1), h);
%end
%end
figure;
dispadjmat(plot_sbeG);
%spy(sbeG)
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if (size(plot_sbeG, 1) > 4000)
if exist('h','var'), close(h); end
end
%guiOutput=i_dispfooter_gui(guiOutput);
%set(handles.WorkspaceOutput, 'String', guiOutput);
%
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function NetworkClose_Callback(hObject, eventdata, handles)
% hObject handle to NetworkClose (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode
sbeG=[]; sbeNode=[];
clear global sbeG sbeNode deduced_net
clear functions
%clearString = sprintf('\n%s\n%s\n', ...
% 'Function Output:',...
% '=========================================');
set(handles.WorkspaceOutput, 'String', '');
SetMenuStatus(handles);
netCleared = sprintf('\n%s', 'Network cleared !');
set(handles.NetworkInformation, 'ForegroundColor', 'green');
%set(handles.NetworkInformation, 'ForegroundColor', [0, .6, 0]);
set(handles.NetworkInformation, 'String', netCleared);
setpref('SBEToolbox', 'largestconnnetCalled', 0);
setpref('SBEToolbox', 'isRestore', 0);
setpref('SBEToolbox', 'graph_gui', 0);
writenetsession([], [], 'sbeVars');
writenetsession([], [], 'sbeLargeConnNet');
writenetsession([], [], 'sbeEdit');
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function StatCentralityInDegree_Callback(hObject, eventdata, handles)
% hObject handle to StatCentralityInDegree (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode
set(handles.StatusBar, 'String', 'Busy');
if isbig(sbeG), h=waitbar(0.5, 'Please wait...'); end
try
data=sum(sbeG,2);
guiOutput = i_dispheader_gui('Degree Centrality', size(sbeG, 1));
for k=1:size(sbeG,1)
guiHeaderOffset = k + 1;
guiOutput{guiHeaderOffset} = sprintf('Node%04d\t%s\t%d',k, ...
sbeNode{k}, full(data(k)));
end
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
i_conditionalexportresult(handles,data,sbeNode);
%plot_histcurve(data, 1, 'Degree Centrality Distribution', ...
% 'log_1_0(degree)', 'nodes');
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function StatCentralityCloseness_Callback(hObject, eventdata, handles)
% hObject handle to StatCentralityCloseness (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode
set(handles.StatusBar, 'String', 'Busy');
if isbig(sbeG), h=waitbar(0.5, 'Please wait...'); end
try
data=closeness_centrality(sbeG);
guiOutput = i_dispheader_gui('Closeness Centrality', size(sbeG, 1));
if exist('h', 'var'), waitbar(0.582, h); end;
for k=1:size(sbeG,1)
guiHeaderOffset = k + 1;
guiOutput{guiHeaderOffset} = sprintf('Node%04d\t%s\t%g',k,...
sbeNode{k}, full(data(k)));
end
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
i_conditionalexportresult(handles,data,sbeNode);
%plot_histcurve(data, 1, 'Closeness Centrality Distribution', ...
% 'log_1_0(closeness)', 'nodes');
catch exception
errordlg(exception.message);
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
return;
end
if isbig(sbeG), waitbar(1, h); end
if exist('h','var'), close(h); end
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function NetworkCreate_Callback(hObject, eventdata, handles)
% hObject handle to NetworkCreate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function NetworkCreateSmallWorld_Callback(hObject, eventdata, handles)
% hObject handle to NetworkCreateSmallWorld (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode deduced_net retFname
set(handles.StatusBar, 'String', 'Busy');
prompt={'Number of nodes:','Number of links a new node can make:'};
def={'300','1'};
dlgTitle='Generate Small-World Network';
lineNo=1;
answer=inputdlg(prompt, dlgTitle,...
[lineNo, 60; lineNo, 60], def);
if ~(isempty(answer)),
n=str2double(answer{1});
p=str2double(answer{2});
[sbeG,sbeNode]=randnet_sw(n,p);
writenetsession(sbeG, sbeNode, 'sbeVars');
setpref('SBEToolbox', 'isRestore', 0);
setpref('SBEToolbox', 'largestconnnetCalled', 0);
setpref('SBEToolbox', 'filename', 'RandNet - Small World');
else
set(handles.StatusBar, 'String', 'Ready');
return;
end
guiOutput = i_dispheader_gui('Random network ( Small World ) created!',...
2);
guiOutput = viewnetinfo_gui(sbeG, guiOutput);
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
if ~isempty(deduced_net)
clear global deduced_net;
end
retFname = 'RandNet - Small World';
SetMenuStatus(handles)
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function NetworkCreateErdosRenyi_Callback(hObject, eventdata, handles)
% hObject handle to NetworkCreateErdosRenyi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode deduced_net retFname
set(handles.StatusBar, 'String', 'Busy');
prompt={'Number of vertices:','Probability of each edge:'};
def={'100','0.05'};
dlgTitle='Generate Erdös-Réyni Network';
lineNo=1;
answer=inputdlg(prompt, dlgTitle, ...
[lineNo, 60; lineNo, 60], def);
if ~(isempty(answer)),
n=str2double(answer{1});
p=str2double(answer{2});
[sbeG,sbeNode]=randnet_er(n,p);
writenetsession(sbeG, sbeNode, 'sbeVars');
setpref('SBEToolbox', 'isRestore', 0);
setpref('SBEToolbox', 'largestconnnetCalled', 0);
setpref('SBEToolbox', 'filename', 'RandNet - Erdös-Réyni');
else
set(handles.StatusBar, 'String', 'Ready');
return;
end
guiOutput = i_dispheader_gui('Random network ( Erdös-Réyni ) created!',...
2);
guiOutput = viewnetinfo_gui(sbeG, guiOutput);
guiOutput=i_dispfooter_gui(guiOutput);
set(handles.WorkspaceOutput, 'String', guiOutput);
if ~isempty(deduced_net)
clear global deduced_net;
end
retFname = 'RandNet - Erdös-Réyni';
SetMenuStatus(handles)
set(handles.StatusBar, 'String', 'Ready');
% --------------------------------------------------------------------
function NetworkCreateRingLattice_Callback(hObject, eventdata, handles)
% hObject handle to NetworkCreateRingLattice (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sbeG sbeNode deduced_net retFname
set(handles.StatusBar, 'String', 'Busy');
prompt = {'Number of Nodes:',...
'Number of connections each Node can make:',...
'Watts and Strogatz Probability (ß):'};
def={'20', '4', '0'};
dlgTitle = 'Generate Ring Lattice Network';
num_lines = 1;
answer = inputdlg(prompt, dlgTitle, ...
[num_lines, 70; num_lines, 70; num_lines, 70], def);
if ~(isempty(answer))
nodes = str2double(answer{1});
degree = str2double(answer{2});
prob = str2double(answer{3});