-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmarks.py
executable file
·2478 lines (2096 loc) · 123 KB
/
benchmarks.py
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
# -*- coding: utf-8 -*-
'''
Multiscale Entropic Network Generator (MUSKETEER)
Copyright (c) 2011-2014 by Alexander Gutfraind and Ilya Safro.
All rights reserved.
Use and redistribution of this file is governed by the license terms in
the LICENSE file found in the project's top-level directory.
Benchmarks of Quality and performance - internal
TODO:
1. alg-alg benchmarks:
compare two algorithms on a set of graphs.
a. attempt to show one is better on average using t-tests
b. identify areas where one algorithm is consistently better, using t-tests
2. target graph benchmarks:
report how well a particular set of graphs is replicated by a given algorithm
3. feature benchmark:
a. one-step benchmark
report how well a particular feature (e.g. clustering) is replicated by a given algorithm
b. two-step benchmark:
report how well a particular algorithm is able to retain the original features over 2 replications
c. T-step benchmark
report on the divergence from the original graph when replication is iterated
DONE d. bias benchmark
does the algorithm have a propensity to change a given feature in a particular direction? eg. increase density
4. benchmark suites
a set of tests the generates figures in the paper for PNAS
5. noise-spectrum benchmarks
show how changing the color of the noise changes the graph
6. ensemble_validation_benchmark
plot the properties of the replicas against properties of originals and against just randomly-noised graphs
7. speed benchamarks
running time
'''
import os, subprocess
import time
import numpy as np
import numpy.random as npr
import random, sys
import networkx as nx
import matplotlib
matplotlib.use('PS')
#matplotlib.use('PDF')
import matplotlib.pylab as pylab
#import pylab
import pdb, traceback
import pickle
import scipy.stats
#matplotlib.rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#matplotlib.rc('font',**{'family':'serif','serif':['Palatino']})
#rc('font',**{'family':'serif','serif':['Times New Roman']})
try:
os.system('latex -version > /dev/null')
matplotlib.rc('text', usetex=True)
except:
matplotlib.rc('text', usetex=False)
import algorithms
import alternatives
import community
import graphutils
import simpletesters, testers
np.seterr(all='raise')
timeNow = lambda : time.strftime('%Y_%m_%d__%H_%M_%S', time.localtime())
if not os.path.exists('output'):
os.makedir('output')
def alg_alg(alg1, alg2, params={}, graphs={}, alg_params={}, alg2_params={}):
'''
compare two algorithms
alg1 and alg2 should be methods that accept a graph and alg_params;
alg2_params are the same as alg_params by default
TODO: allow alg2 to be just random edge noise
graphs[graph_name] = {'G':G, 'options':Not_implemented}
'''
if graphs == {}:
graphs = next(default_graphs())
if alg_params == {}:
alg_params['verbose'] = False
alg_params['error_rate'] = [0.05/(1.+i) for i in range(100)]
if alg2_params == {}:
alg2_params = alg_params
errors_by_graph = []
errors_by_type = []
errors_by_metric= []
for graph_name in graphs:
G = graphs[graph_name]['G']
graph_type = graphs[graph_name]['graph_type']
replica1 = alg1(original=G, params=alg_params)
replica2 = alg2(original=G, params=alg2_params)
error_data1 = compare_nets(old_G=G, new_G=replica1, params={'verbose':False})[0]
error_data2 = compare_nets(old_G=G, new_G=replica2, params={'verbose':False})[0]
errors_by_graph.append((graph_name,
np.average([abs(err) for err in list(error_data1.values())]),
np.average([abs(err) for err in list(error_data2.values())])))
print('Mean errors by graph (absolute)')
print('Graph\t\t\t\tAlg1_Err Alg2_Err')
for graph_name, err1, err2 in errors_by_graph:
print('%s\t%.2f\t%.2f'%(graph_name.center(25),err1,err2))
print()
print('TODO: report mean errors by graph type')
print('GraphType\t\tAlg1_Error\t\tAlg2_Error')
print()
print('TODO: report errors by metric')
print('Metric\t\tAlg1_Error\t\tAlg2_Error')
print()
def alternatives_metric(G=None, replicas=None, metric=(community.louvain_modularity, 'modularity'), seed=None, figpath=None, title_infix=''):
vals_of_replicas = {}
num_of_algs = len(replicas)
alg_names = list(replicas.keys())
for alg_name in alg_names:
print(alg_name)
vals_of_replicas[alg_name] = []
for num_replica, replica in enumerate(replicas[alg_name]):
vals_of_replicas[alg_name].append(metric['function'](replica))
#if num_replica > 10:
# break
sys.stdout.write('.')
sys.stdout.flush()
sys.stdout.write('; ')
print()
val_of_graph = metric['function'](G)
print('Val of graph: ')
print(val_of_graph)
med_vals = [np.median(vals_of_replicas[alg_name]) for alg_name in alg_names]
print('Medians:')
print(med_vals)
normed_replica_vals = []
for alg_idx, alg_name in enumerate(alg_names):
noravg_vals = np.array(vals_of_replicas[alg_name])/((1E-20) + val_of_graph)
normed_replica_vals.append(noravg_vals)
fig = pylab.figure()
pylab.hold(True)
pylab.plot(num_of_algs*[1.], list(range(num_of_algs)), 'o', color='k', linewidth=2., label=G.name)
pylab.yticks(list(range(num_of_algs)), [alg_name.replace(' ', '\n') for alg_name in alg_names], rotation=0)
pylab.xlabel(metric['name'] + ' (normalized by empirical value)', rotation=0, fontsize='15')
#pylab.xlabel('Normalized value', rotation=0, fontsize='20')#, x=0.1)
pylab.boxplot(np.array(normed_replica_vals).transpose(), positions=list(range(num_of_algs)), vert=0, patch_artist=True)
max_axis = 2
pylab.xlim(-0.02,max_axis)
fig.subplots_adjust(left=0.17, right=0.95)
'''
pylab.text(x=1.75, y=num_of_algs-0.4, s='Median of\nreplicas')
for alg_idx, alg_name in enumerate(alg_names):
normed_val = med_vals[alg_idx]/((1E-20) + val_of_graph)
if abs(normed_val) < 100:
val_str=r'$%.2f$'%normed_val
elif normed_val < -1000:
val_str='un-\ndefined'
else:
val_str=r'$\gg0$'
pylab.text(x=max_axis+0.02, y=alg_idx, s=val_str)
'''
pylab.hold(False)
if figpath == None:
figpath = 'output/alternatives_metric_'+metric['name']+'_'+G.name+'__'+timeNow()
figpath = clean_path(figpath)
save_figure_helper(figpath)
def alternatives_outbreaks(G=None, seed=None, figpath=None, params=None, dynamics_params=None, alternative_algs=None, num_replicas = 150, outbreak_cutoff=50):
import epidemic_sim
if seed==None:
seed = npr.randint(1E6)
print('rand seed: %d'%seed)
npr.seed(seed)
random.seed(seed)
prob_outbreak = lambda outbreak_sizes: 1 - outbreak_sizes[:outbreak_cutoff-1].sum()
if params == None:
params = {'verbose':False, 'edge_edit_rate':[0.05, 0.04], 'dont_cutoff_leafs':True, 'node_edit_rate':[0.05, 0.04], 'node_growth_rate':[0., 0], 'locality_bias_correction':[0.], 'enforce_connected':True, 'accept_chance_edges':1.0}
params['preserve_degree'] = True
params['epsilon'] = sum(params['edge_edit_rate'])+sum(params['node_edit_rate'])
print('Params:')
print(params)
stepping = 2
max_time = 79
if dynamics_params == None:
#dynamics_params = {'minReplications':500, 'tie_stability':1.0, 'latent_interval':3, 'infectious_interval':300, 'max_time':250}
#flu (per day)
#dynamics_params = {'minReplications':1000, 'tie_stability':1.0, 'latent_interval':2, 'infectious_interval':9, 'max_time':max_time}
dynamics_params = {'minReplications':500, 'tie_stability':1.0, 'latent_interval':3, 'infectious_interval':2, 'max_time':max_time}
print('dynamics_params:')
print(dynamics_params)
if alternative_algs==None:
alternative_algs = []
alternative_algs += [('MUSKETEER', algorithms.generate_graph)]
alternative_algs += [('Edge swapping', alternatives.random_noise_replicate)]
alternative_algs += [('Expected degree model', alternatives.expected_degree_replicate)]
alternative_algs += [('Scale-free model', alternatives.scalefree_replicate)]
alternative_algs += [('Kronecker model', alternatives.kronecker_replicate)]
else:
alternative_algs = [('MUSKETEER', algorithms.generate_graph)] + alternative_algs
vals_of_graph = []
vals_of_replicas = {}
for alg_name,alg_func in alternative_algs:
vals_of_replicas[alg_name] = []
print()
print(G.name)
taus = np.arange(0,1.01, 0.05)
for tau in taus:
dynamics_params['tau'] = tau
dummy, outbreak_sizes = epidemic_sim.extentSIR_long(G=G, params=dynamics_params)
vals_of_graph.append(prob_outbreak(outbreak_sizes))
for alg_i, (alg_name, alt_alg) in enumerate(alternative_algs):
print()
print(alg_name)
for tau in taus:
sys.stdout.write('%.2f'%tau)
dynamics_params['tau'] = tau
probs = []
for replica_idx in range(num_replicas):
replica = alt_alg(G, params=params)
sys.stdout.write('.')
extent, outbreak_sizes = epidemic_sim.extentSIR_long(G=replica, params=dynamics_params)
probs.append(prob_outbreak(outbreak_sizes))
sys.stdout.write(' ')
sys.stdout.flush()
vals_of_replicas[alg_name].append(np.average(probs))
print()
pylab.figure()
pylab.hold(True)
pylab.plot(taus, vals_of_graph, '-^', color='b', linewidth=2., label='original network')
#curvetypes = ['r-', 'g-', 'b-', 'k-', 'c-.', 'y-', 'm-D', 'b-.', 'r-.', 'c-']
curvetypes = ['g-o', 'rd-', 'ks-', 'cp-', 'yH-', 'mD-', 'b3-', 'r4-', 'c1-']
for alg_i, (alg_name, alt_alg) in enumerate(alternative_algs):
print()
print(alg_name)
pylab.plot(taus, vals_of_replicas[alg_name], curvetypes[alg_i], linewidth=1., label=alg_name+'')
pylab.xlabel('Transmissibility (per contact-day)', fontsize='20')
pylab.ylabel('Probability of outbreak of size %d or more'%outbreak_cutoff, fontsize='20')#, x=0.1)
#pylab.title(G.name)
pylab.legend(loc='best')
pylab.xlim(-0.01,1.01)
pylab.ylim(ymin=-0.01)
if figpath == None:
figpath = 'output/alternatives_seir_outbreak_sizes_'+G.name+'_'+str(seed)+'__'+timeNow()
figpath = clean_path(figpath)
save_figure_helper(figpath)
pylab.hold(False)
data = {'vals_of_graph':vals_of_graph, 'vals_of_replicas':vals_of_replicas, 'params':params, 'dynamics_params':dynamics_params}
graphutils.safe_pickle(path=figpath+'.pkl', data=data)
def alternatives_SEIR(G=None, seed=None, figpath=None, params=None, dynamics_params=None, alternative_algs=None, num_replicas = 150):
import epidemic_sim
if seed==None:
seed = npr.randint(1E6)
print('rand seed: %d'%seed)
npr.seed(seed)
random.seed(seed)
if params == None:
params = {'verbose':False, 'edge_edit_rate':[0.05, 0.04], 'dont_cutoff_leafs':True, 'node_edit_rate':[0.05, 0.04], 'node_growth_rate':[0., 0], 'locality_bias_correction':[0.], 'enforce_connected':True, 'accept_chance_edges':1.0}
params['preserve_degree'] = True
params['epsilon'] = sum(params['edge_edit_rate'])+sum(params['node_edit_rate'])
print('Params:')
print(params)
if G.name == 'potterat':
params['matrix'] = '0.629063, 0.584033; 0.668222, 0.13873'
stepping = 2
max_time = 79
if dynamics_params == None:
#dynamics_params = {'minReplications':500, 'tau':0.1, 'tie_stability':1.0, 'latent_interval':3, 'infectious_interval':300, 'max_time':250}
#flu (per day)
dynamics_params = {'minReplications':1000, 'tau':0.5, 'tie_stability':1.0, 'latent_interval':2, 'infectious_interval':9, 'max_time':max_time}
#dynamics_params = {'minReplications':100, 'tau':0.4, 'tie_stability':1.0, 'latent_interval':3, 'infectious_interval':2, 'max_time':max_time}
print('dynamics_params:')
print(dynamics_params)
if alternative_algs==None:
alternative_algs = []
alternative_algs += [('MUSKETEER', algorithms.generate_graph)]
alternative_algs += [('Edge swapping', alternatives.random_noise_replicate)]
alternative_algs += [('Expected degree model', alternatives.expected_degree_replicate)]
alternative_algs += [('Scale-free model', alternatives.scalefree_replicate)]
alternative_algs += [('Kronecker model', alternatives.kronecker_replicate)]
else:
alternative_algs = [('MUSKETEER', algorithms.generate_graph)] + alternative_algs
replicas = {'MUSKETEER':[]}
vals_of_replicas = []
vals_of_replicas2 = {}
for alg_name,alg_func in alternative_algs:
replicas[alg_name] = []
vals_of_replicas2[alg_name] = []
mean_of_graph, outbreak_sizes = epidemic_sim.extentSIR_long(G=G, params=dynamics_params)
print()
print(G.name)
pylab.figure()
pylab.hold(True)
xvals = list(range(dynamics_params['max_time']))
pylab.plot(xvals[::2], mean_of_graph[::2], '-^', color='b', linewidth=2., label='original network')
#pylab.errorbar(xvals[::stepping], std_of_graph[::stepping], yerr=std_of_graph[::stepping], color='b', linestyle='', ecolor='b', capsize=4)[0]
#curvetypes = ['r-', 'g-', 'b-', 'k-', 'c-.', 'y-', 'm-D', 'b-.', 'r-.', 'c-']
curvetypes = ['g-o', 'rd-', 'ks-', 'cp-', 'yH-', 'mD-', 'b3-', 'r4-', 'c1-']
for alg_i, (alg_name, alt_alg) in enumerate(alternative_algs):
print()
print(alg_name)
for replica_idx in range(num_replicas):
replica = alt_alg(G, params=params)
replicas[alg_name].append(replica)
sys.stdout.write('.')
extent, outbreak_sizes = epidemic_sim.extentSIR_long(G=replica, params=dynamics_params)
sys.stdout.write(' ')
vals_of_replicas2[alg_name].append(extent)
vals_of_replicas2_ar = np.array(vals_of_replicas2[alg_name])
mean_of_replicas2_ar = vals_of_replicas2_ar.mean(axis=0)
std_of_replicas2 = vals_of_replicas2_ar.std(axis=0, ddof=1)
print()
pylab.plot(xvals[::2], mean_of_replicas2_ar[::2], curvetypes[alg_i], linewidth=1., label=alg_name+'')
pylab.errorbar(xvals[::stepping], mean_of_replicas2_ar[::stepping], yerr=std_of_replicas2[::stepping], color=curvetypes[alg_i][0], linestyle='', ecolor=curvetypes[alg_i][0], capsize=2)[0]
pylab.ylabel('New cases', fontsize='20')
pylab.xlabel('Time (days)', fontsize='20')#, x=0.1)
#pylab.ylabel('Normed by mean value', rotation=90, fontsize='20')
#pylab.title(G.name)
pylab.legend(loc='best')
pylab.xlim(-0.01,len(mean_of_graph)+0.1)
pylab.ylim(ymin=-0.01)
if figpath == None:
figpath = 'output/alternatives_seir_'+G.name+'_'+str(seed)+'__'+timeNow()
figpath = clean_path(figpath)
save_figure_helper(figpath)
pylab.hold(False)
data = {'replicas':replicas, 'vals_of_replicas':vals_of_replicas, 'vals_of_replicas2':vals_of_replicas2, 'params':params, 'dynamics_params':dynamics_params}
graphutils.safe_pickle(path=figpath+'.pkl', data=data)
return replicas
def bias_benchmark(G, alg, params={}, alg_params={}, seed=None):
'''
determine if alg has a systematic bias when running on graph G
'''
if seed==None:
seed = npr.randint(1E6)
print('rand seed: %d'%seed)
npr.seed(seed)
random.seed(seed)
if hasattr(G, 'name'):
print('Testing bias on: ' + str(G.name))
print(' note: error format: NEW_VALUE - OLD_VALUE')
if alg_params == {}:
alg_params['verbose'] = False
alg_params['node_edit_rate'] = [0.0]
alg_params['edge_edit_rate'] = [0.05]
alg_params['locality_bias_correction'] = [0.0]
#alg_params['deferential_detachment_factor'] = 1.0
#alg_params['edge_welfare_fraction'] = 1.0
#alg_params['enforce_connected'] = False
num_samples = params.get('num_samples', 50)
#target_metrics = params.get('target_metrics', ['num edges','clustering'])
target_metrics = params.get('target_metrics', [metric['name'] for metric in graphutils.default_metrics if metric['optional'] == 0])
errors_by_metric = {}
for met_name in target_metrics:
errors_by_metric[met_name] = []
for it in range(num_samples):
replica = alg(original=G, params=alg_params)
error_dat = graphutils.compare_nets(old_G=G, new_G=replica, params={'normalize':False, 'verbose':False})[0]
for met_name in target_metrics:
errors_by_metric[met_name] += [error_dat.get(met_name, 0.)]
print('Sample %d finished'%(it+1))
print()
print('Analysis results')
for met_name in errors_by_metric:
print(met_name)
samples = np.array(errors_by_metric[met_name])
expected_mean = 0.
sample_mean = np.average(samples)
if sum(np.abs(samples)) == 0.:
print('metric ok. no variation')
print()
continue
try:
t_val, p_val = scipy.stats.ttest_1samp(a=samples, popmean=expected_mean)
except:
print('Couldn\'t compute: '+met_name)
print()
continue
print(' Mean error: %.9f, Expected: %.9f'%(sample_mean,expected_mean))
print(' p_val: %.9f'%(p_val,))
print(' %s at 5%% level'%(p_val<0.05 and 'REJECTED' or 'apparently OK'))
print(samples)
print()
return errors_by_metric
def clean_path(fpath):
#make the path suitable for TeX
fpath = fpath.replace('.', 'd')
fpath = fpath.replace(',', 'c')
fpath = fpath.replace(' ', '_')
fpath = fpath.replace('*', '_')
fpath = fpath.replace('(', '_')
fpath = fpath.replace(')', '_')
return fpath
def compare_nets_betweenness(old_G, new_G, params=None):
'''
Report on the differences between two networks for their betweenness
'''
print('Node\tBC\tNewBC\tDIFF\%\tDC\tNewDC\tDIFF\%')
old_bet_cet = nx.betweenness_centrality(old_G)
new_bet_cet = nx.betweenness_centrality(new_G)
bet_errors = []
deg_errors = []
for node in old_G: #assumes same nodes
bet_old = old_bet_cet[node]
bet_new = new_bet_cet[node]
bet_error = (bet_new-bet_old)/max(bet_old,bet_new)
deg_old = old_G.degree(node)
deg_new = new_G.degree(node)
deg_error = (deg_new-deg_old)/max(deg_old,deg_new)
print('%s\t%.2f\t%.2f\t%.2f%%\t%.2f\t%.2f\t%.2f%%'%(str(node),bet_old,bet_new,100*bet_error,deg_old,deg_new,100*deg_error))
bet_errors.append(bet_error)
deg_errors.append(deg_error)
print('Mean betweenness difference: %.2f%%'%np.average(bet_errors))
print('Mean degree difference: %.2f%%'%np.average(deg_errors))
def degree_expect_diff(old_G, new_G):
#the expectation of d over degree histograph of old_G
# minus the expectation of d over degree histograph of new_G
#(normalized by the largest expectation)
h1 = nx.degree_histogram(old_G)
h2 = nx.degree_histogram(new_G)
if len(h1) < len(h2):
h1 += [0]*(len(h2)-len(h1))
else:
h2 += [0]*(len(h1)-len(h2))
ret = 0.
denom_1 = 0.
denom_2 = 0.
for i,val2 in enumerate(h2):
ret += i*(val2 - h1[i])
denom_1 += i*h1[i]
denom_2 += i*val2
return ret/max(denom_1,denom_2)
def default_graphs():
print('Loading default graphs:')
graphs = {}
names = [('../benchmark/net4-1.graph', 'adjlist', 'engineering',),
]
for graph_name, file_type, graph_type in names:
G = graphutils.load_graph(path=graph_name, params={'graph_type':file_type})
graphs[graph_name] = {'G':G, 'graph_type':graph_type}
print(graph_name)
graphs['southern women'] = {'G':nx.generators.davis_southern_women_graph(), 'graph_type':'social'}
print('.')
graphs['karate club'] = {'G':nx.generators.karate_club_graph(), 'graph_type':'social'}
print('.')
graphs['erdos-renyi200'] = {'G':nx.erdos_renyi_graph(n=200, p=0.02, seed=42), 'graph_type':'classic_model'}
print('.')
graphs['watts-strogatz200'] = {'G':nx.watts_strogatz_graph(n=200, k=3, p=0.05, seed=42),'graph_type':'classic_model'}
print('.')
graphs['barabasi-albert200'] = {'G':nx.barabasi_albert_graph(n=200, m=10, seed=42),'graph_type':'classic_model'}
print('.')
random.seed()
while True:
yield graphs
def dissimilarity_preservation_demo():
metrics = graphutils.default_metrics[:]
metrics = [met for met in metrics if met['name'] not in ['avg flow closeness', 'powerlaw exp', 'density', 'num comps', 'harmonic mean path', 'mean ecc', 'average degree']]
metrics = [met for met in metrics if met['name'] not in ['degree assortativity']] #varies too much
metrics = [met for met in metrics if met['optional'] == 0]
ER = nx.erdos_renyi_graph(n=100, p=0.08)
ER.name = 'ER'
scaling_data, norms = self_dissimilarity_analysis(G=ER, metrics=metrics, markersize=20)
params = {'verbose':False, 'edge_edit_rate':[0.03], 'node_edit_rate':[], 'node_growth_rate':[0],
'enforce_connected':True, 'accept_chance_edges':1.0, 'locality_bias_correction':[-0.65, 0, 0, 0, 0]}
for rep_num in range(10):
replica = algorithms.generate_graph(original=ER, params=params)
self_dissimilarity_analysis(G=replica, metrics=metrics, norms = norms, figure=1, markersize=1)
pylab.savefig('output/self_asymmetry_compare__'+timeNow()+'.eps')
def editing_demo(seed=15 ):
original = graphutils.load_graph('data-cyber-small/gr2.gml')
#maybe: convert_to_integers to simplify display?
base_params = {'edge_edit_rate':[], 'node_edit_rate':[], 'node_growth_rate':[]}
npr.seed(seed)
random.seed(seed)
pos = nx.spring_layout(original)
editing_demo_draw(G=original, new_G=original, pos=pos, seed=1)
npr.seed(15)
random.seed(15)
params_blue_edge = base_params.copy()
params_blue_edge['edge_edit_rate'] = [0.05]
blue_edge_replica = algorithms.generate_graph(original=original, params=params_blue_edge)
editing_demo_draw(G=original, new_G=blue_edge_replica, pos=pos, seed=10)
npr.seed(62)
random.seed(62)
params_red_edge = base_params.copy()
params_red_edge['edge_edit_rate'] = [0, 0.2]
red_edge_replica = algorithms.generate_graph(original=original, params=params_red_edge)
editing_demo_draw(G=original, new_G=red_edge_replica, pos=pos, seed=18 )
npr.seed( 2 )
random.seed( 2 )
params_blue_node = base_params.copy()
params_blue_node['node_edit_rate'] = [0.05]
blue_node_replica = algorithms.generate_graph(original=original, params=params_blue_node)
editing_demo_draw(G=original, new_G=blue_node_replica, pos=pos, seed=22)
npr.seed( 36 ) #7,18 ,24
random.seed( 36 )
params_red_node = base_params.copy()
params_red_node['node_edit_rate'] = [0, 0.2]
red_node_replica = algorithms.generate_graph(original=original, params=params_red_node)
editing_demo_draw(G=original, new_G=red_node_replica, pos=pos, seed=9)
def editing_demo_draw(G, new_G, seed=1, **kwargs):
#prepare a graph
npr.seed(seed)
random.seed(seed)
delta = graphutils.graph_graph_delta(G, new_G)
new_nodes = delta['new_nodes']
del_nodes = delta['del_nodes']
new_edges = delta['new_edges']
del_edges = delta['del_edges']
if 'pos' not in kwargs:
merged_pos = nx.spring_layout(G)
else:
merged_pos = kwargs['pos'].copy()
merged_G = G.copy()
tmp_pos = merged_pos.copy()
for node in new_nodes:
merged_G.add_node(node)
tmp_pos[node] = npr.rand(2)
for edge in new_edges:
merged_G.add_edge(*edge)
tmp_pos = nx.spring_layout(merged_G, pos=tmp_pos)
for node in new_nodes:
merged_pos[node]=tmp_pos[node]
regular_nodes = [node for node in merged_G if ((node not in new_nodes) and (node not in del_nodes))]
regular_edges = [edge for edge in merged_G.edges() if (G.has_edge(*edge) and new_G.has_edge(*edge))]
labels = {}
for node in merged_G:
labels[node] = ''
base_node_color = 'black'
new_node_color = 'brown'
del_node_color = 'yellow' #'blue'
base_edge_color = 'black'
new_edge_color = new_node_color
del_edge_color = 'black'
base_edge_style = 'solid'
new_edge_style = 'solid'
del_edge_style = 'dashed'
new_edge_width = 5
del_edge_width = 2
#pylab.close()
#pylab.figure(figsize=(2.1, 2))
pylab.figure()
pylab.hold(True)
#nx.draw(G)
#nx.draw(G, pos=pos, labels=labels, width=widths, style=styles)
nx.draw_networkx_nodes(merged_G, pos=merged_pos, nodelist=regular_nodes, node_color=base_node_color, node_size=500, alpha=1.0, with_labels=False, node_shape='s')
nx.draw_networkx_nodes(merged_G, pos=merged_pos, nodelist=new_nodes, node_color=new_node_color, node_size=500, alpha=1.0, with_labels=False, node_shape='s')
nx.draw_networkx_nodes(merged_G, pos=merged_pos, nodelist=del_nodes, node_color=del_node_color, node_size=100, alpha=1.0, with_labels=False, node_shape='s')
nx.draw_networkx_edges(merged_G, pos=merged_pos, edgelist=regular_edges, style=base_edge_style, edge_color=base_edge_color, alpha=1.0) #width=dict
nx.draw_networkx_edges(merged_G, pos=merged_pos, edgelist=new_edges, style=new_edge_style, edge_color=new_edge_color, alpha=1.0, width=new_edge_width)
nx.draw_networkx_edges(merged_G, pos=merged_pos, edgelist=del_edges, style=del_edge_style, edge_color=del_edge_color, alpha=1.0, width=del_edge_width)
nx.draw_networkx_labels(G, pos=merged_pos, labels=labels)
pylab.grid(b=False)
#pylab.axis('on')
pylab.axis('off')
#pylab.axes(frameon=False)
#pylab.savefig('output/graph_delta_'+timeNow() + '.pdf')
pylab.savefig('output/graph_delta_'+timeNow() + '.eps')
pylab.hold(False)
time.sleep(2)
#pylab.show()
npr.seed()
random.seed()
return delta
def ensemble_validation_benchmark(alg, params={}, graphs={}, alg_params={}):
'''
compare a population the replicas against a population of originals
'''
raise NotImplemented
if graphs == {}:
graphs = next(default_graphs())
if alg_params == {}:
alg_params['verbose'] = False
alg_params['error_rate'] = [0.05/(1.+i) for i in range(100)]
if params == {}:
params['num_replicas'] = 10
replica_ensembles = {}
for graph_name in graphs:
G = graphs[graph_name]['G']
graph_type = graphs[graph_name]['graph_type']
replica_ensembles[graph_name] = []
for r in range(params['num_replicas']):
replica = alg(original=G, params=alg_params)
replica_ensembles[graph_name].append(replica)
#TODO: plot the originals and their replicas over several metrics
def movie_of_replicas():
base_graph = graphutils.load_graph('data-social/911_unwted.gml')
base_graph.name = '911'
#base_graph = graphutils.load_graph(path='data-epi/potterat.gml')
#base_graph.name = 'potterat'
#assert base_graph.number_of_nodes() == 250
#assert base_graph.number_of_edges() == 266
num_replicas = 500
#base_graph = graphutils.load_graph(path='data-social/911_unwted.gml')
#base_graph.name = '911_krebs'
params_potterat = {'verbose':False, 'edge_edit_rate':[0.08, 0.07], 'node_edit_rate':[0.08, 0.07], 'node_growth_rate':[0], 'enforce_connected':True, 'accept_chance_edges':1.0, 'new_edge_horizon':20, 'num_deletion_trials':20, 'locality_bias_correction':[0, 0, 0, 0, 0]}
params_911 = {'edge_edit_rate':[0.08, 0.07], 'node_edit_rate':[0.08, 0.07], 'verbose':False, 'new_edge_horizon':20, 'num_insertion_trials':30, 'enforce_connected':True, 'locality_bias_correction':[1.0, 1.0, 0, 0, 0], 'edit_method':'alternating', 'deferential_detachment_factor':1., 'edge_welfare_fraction':1.0}
try:
os.mkdir('output/movie')
except:
pass
gpath = 'output/movie/'+base_graph.name+'_'+timeNow()+'.dot'
gpath_fig = gpath[:-3]+'png'
graphutils.write_graph(G=base_graph, path=gpath)
visualizer_cmdl = 'sfdp -Nlabel="" -Nfontsize=0 -Nwidth=0.03 -Nfixedsize=true -Nheight=0.03 -Nfillcolor=/ylgnbu9/9 \
-Nstyle=filled -Nperipheries=0 -Gratio=0.75 -Gdpi=300 -Tpng %s > %s &'%(gpath,gpath_fig)
#http://www.graphviz.org/doc/info/colors.html
print('Writing graph image: %s ..'%gpath_fig)
retCode = os.system(visualizer_cmdl)
for replica_num in range(num_replicas):
#gpath_rep = gpath[:-4]+'_replica%d'%(10000+replica_num)+'.dot'
gpath_rep = gpath[:-4]+'_replica%d'%(replica_num)+'.dot'
gpath_rep_fig = gpath_rep[:-4]+'.png'
replica = algorithms.generate_graph(original=base_graph, params=params_911)
graphutils.write_graph(G=replica, path=gpath_rep)
visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.03 -Nfixedsize=true -Nheight=0.03 -Nfillcolor=/ylgnbu9/9 \
-Nstyle=filled -Nperipheries=0 -Gratio=0.75 -Gdpi=300 -Tpng %s > %s &'%(gpath_rep,gpath_rep_fig)
#http://www.graphviz.org/doc/info/colors.html
print('Writing replica image: %s ..'%gpath_rep_fig)
retCode = os.system(visualizer_cmdl)
def paper_benchmarks_and_figures():
# execute all the benchmarks used in the paper
paper_findings_0()
paper_findings_1()
paper_findings_2()
paper_findings_emergent()
paper_findings_one_metric()
paper_findings_snapshots()
paper_alternatives_benchmarks()
paper_findings_memoriless()
paper_findings_epidemic()
paper_illustration_appendix()
def paper_alternatives_benchmarks():
base_graph = graphutils.load_graph(path='data-epi/potterat.gml')
base_graph.name = 'potterat'
num_replicas = 150
metrics = graphutils.default_metrics[:]
metrics = [met for met in metrics if met['name'] not in ['avg flow closeness', 'avg eigvec centrality', 'degree connectivity', 'degree assortativity', ]]
params_MUSKETEER = {'verbose':False, 'edge_edit_rate':[0, 0, 0, 0, 0, 0.08], 'node_edit_rate':[0, 0, 0, 0, 0, 0.08], 'node_growth_rate':[0., 0], 'enforce_connected':True, 'accept_chance_edges':1.0}
params_rand_noise = {'epsilon':sum(params_MUSKETEER['edge_edit_rate'])+sum(params_MUSKETEER['node_edit_rate']), 'preserve_degree':False}
params_edge_swap = params_rand_noise.copy()
params_edge_swap['preserve_degree'] = True
params_edge_swap['preserve_connected'] = True
#print 'Musketeer:'
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params=params_MUSKETEER)
#print
'''
print 'ER:'
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params={}, metrics=metrics,
generator_func=alternatives.er_replicate, title_infix='er')
print
print 'scalefree:'
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params={}, metrics=metrics,
generator_func=alternatives.scalefree_replicate, title_infix='scale_free')
print
print 'smallworld:'
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params={}, metrics=metrics,
generator_func=alternatives.watts_strogatz_replicate, title_infix='small_world')
print
print 'Expected degree:'
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params={}, metrics=metrics,
generator_func=alternatives.expected_degree_replicate, title_infix='expected_deg')
print
print 'random noising:'
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params=params_rand_noise, metrics=metrics,
generator_func=alternatives.random_noise_replicate, title_infix='rand_edit')
print
print 'edge swap:'
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params=params_edge_swap, metrics=metrics,
generator_func=alternatives.random_noise_replicate, title_infix='edge_swap')
'''
print()
print('kronecker:')
#FIXME kron_fitted_matrix = alternatives.kronecker_replicate(original=base_graph, params={'just_do_fitting':True})
print('Kronecker fitted matrix:')
#kron_fitted_matrix = '0.632785, 0.583371; 0.666826, 0.14198'
kron_fitted_matrix = '0.629063, 0.584033; 0.668222, 0.13873'
print(kron_fitted_matrix)
params_kronecker = {'matrix':kron_fitted_matrix}
testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=None, params=params_kronecker, metrics=metrics,
generator_func=alternatives.kronecker_replicate, title_infix='kronecker')
def paper_findings_0(seed=10):
if seed==None:
seed = npr.randint(1E6)
print('rand seed: %d'%seed)
npr.seed(seed)
random.seed(seed)
base_graph = graphutils.load_graph(path='data-samples/mesh33.edges')
print('Musketeer:')
params_MUSKETEER = {'edge_edit_rate':[0.01]}
######################
# 1st figure
######################
#http://www.graphviz.org/doc/info/colors.html
gpath = 'output/'+base_graph.name+'_'+timeNow()+'.dot'
gpath_fig = gpath[:-3]+'eps'
graphutils.write_graph(G=base_graph, path=gpath)
#visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.03 -Nfixedsize=true -Nheight=0.03 -Nfillcolor=/ylgnbu9/9 -Nstyle=filled -Nperipheries=0 -Teps %s > %s &'%(gpath,gpath_fig)
visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.06 -Nfixedsize=true -Nheight=0.06 -Teps %s > %s &'%(gpath,gpath_fig)
print('Writing graph image: %s ..'%gpath_fig)
retCode = os.system(visualizer_cmdl)
gpath_rep = gpath[:-4]+'_replica_shallow.dot'
gpath_rep_fig = gpath_rep[:-4]+'.eps'
params2 = params_MUSKETEER.copy()
params2['verbose']=True
replica = algorithms.generate_graph(original=base_graph, params=params2)
graphutils.write_graph(G=replica, path=gpath_rep)
visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.06 -Nfixedsize=true -Nheight=0.06 -Teps %s > %s &'%(gpath_rep,gpath_rep_fig)
print('Writing graph image: %s ..'%gpath_rep_fig)
retCode = os.system(visualizer_cmdl)
######################
# 2nd figure
######################
gpath_rep = gpath[:-4]+'_replica_deep.dot'
gpath_rep_fig = gpath_rep[:-4]+'.eps'
params3 = params_MUSKETEER.copy()
params3['edge_edit_rate'] = [0, 0, 0, 0, 0.01]
replica = algorithms.generate_graph(original=base_graph, params=params3)
graphutils.write_graph(G=replica, path=gpath_rep)
visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.06 -Nfixedsize=true -Nheight=0.06 -Teps %s > %s &'%(gpath_rep,gpath_rep_fig)
print('Writing graph image: %s ..'%gpath_rep_fig)
retCode = os.system(visualizer_cmdl)
def paper_findings_1(seed=8, intermediates=False, num_replicas=150):
#3 is good
if seed==None:
seed = npr.randint(1E6)
print('rand seed: %d'%seed)
npr.seed(seed)
random.seed(seed)
base_graph = graphutils.load_graph(path='data-epi/potterat.gml')
base_graph.name = 'potterat'
assert base_graph.number_of_nodes() == 250
assert base_graph.number_of_edges() == 266
#base_graph = graphutils.load_graph(path='data-social/911_unwted.gml')
#base_graph.name = '911_krebs'
print('Musketeer:')
params_MUSKETEER = {'verbose':False, 'edge_edit_rate':[0, 0, 0, 0, 0.08], 'node_edit_rate':[0, 0, 0, 0, 0.08], 'node_growth_rate':[0], 'dont_cutoff_leafs':True,
'enforce_connected':True, 'accept_chance_edges':0.8, 'new_edge_horizon':20, 'num_deletion_trials':20, 'locality_bias_correction':[0,0]}
metrics = graphutils.default_metrics[:]
metrics = [met for met in metrics if met['name'] not in ['avg flow closeness', 'avg eigvec centrality', 'degree connectivity', 'degree assortativity', ]]
#metrics = filter(lambda met: met['name'] not in ['avg harmonic shortest path'], metrics)
######################
# 1st figure
######################
#http://www.graphviz.org/doc/info/colors.html
gpath = 'output/'+base_graph.name+'_'+timeNow()+'.dot'
gpath_fig = gpath[:-3]+'eps'
graphutils.write_graph(G=base_graph, path=gpath)
#visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.03 -Nfixedsize=true -Nheight=0.03 -Nfillcolor=/ylgnbu9/9 -Nstyle=filled -Nperipheries=0 -Teps %s > %s &'%(gpath,gpath_fig)
visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.06 -Nfixedsize=true -Nheight=0.06 -Teps %s > %s &'%(gpath,gpath_fig)
print('Writing graph image: %s ..'%gpath_fig)
retCode = os.system(visualizer_cmdl)
gpath_rep = gpath[:-4]+'_replica.dot'
gpath_rep_fig = gpath_rep[:-4]+'.eps'
params2 = params_MUSKETEER.copy()
params2['verbose']=True
replica = algorithms.generate_graph(original=base_graph, params=params2)
graphutils.write_graph(G=replica, path=gpath_rep)
visualizer_cmdl = 'sfdp -Nlabel="" -Nwidth=0.06 -Nfixedsize=true -Nheight=0.06 -Teps %s > %s &'%(gpath_rep,gpath_rep_fig)
print('Writing graph image: %s ..'%gpath_rep_fig)
retCode = os.system(visualizer_cmdl)
######################
# 2nd figure
######################
#testers.replica_vs_original(G=base_graph, num_replicas=num_replicas, seed=1, params=params_MUSKETEER, metrics=metrics, title_infix='musketeer', intermediates=intermediates)
replica_vs_original_degree_distribution(G=base_graph, num_replicas=num_replicas, seed=1, params=params_MUSKETEER)
def paper_findings_2():
num_replicas = 150
params_MUSKETEER = {'verbose':False, 'edge_edit_rate':[0, 0, 0, 0.08], 'node_edit_rate':[0, 0, 0, 0.08], 'node_growth_rate':[0],
'enforce_connected':True, 'accept_chance_edges':1.0, 'num_pairs_to_sample':100, 'num_trial_particles':50, 'num_insertion_trials':50}
metrics = graphutils.default_metrics[:]
metrics = [met for met in metrics if met['name'] not in ['avg flow closeness', 'avg eigvec centrality', 'degree assortativity', 'degree connectivity', 'powerlaw exp']]
######################
# 3rd figure
######################
print('Barabasi-Albert')
params_BA = params_MUSKETEER.copy()
params_BA['locality_bias_correction'] = []
metrics += [met for met in graphutils.default_metrics if met['name'] == 'powerlaw exp']
metrics[-1]['optional']=0
BA_graph = nx.barabasi_albert_graph(n=300, m=10, seed=42)
testers.replica_vs_original(G=BA_graph, num_replicas=num_replicas, seed=1, params=params_BA, metrics=metrics)
print()
print('Erdos-Renyi')
params_ER = params_MUSKETEER.copy()
params_ER['locality_bias_correction'] = []
ER_graph = nx.erdos_renyi_graph(n=300, p=0.04, seed=42)
metrics_ER = [met for met in metrics if met['name'] not in ['powerlaw exp']]
testers.replica_vs_original(G=ER_graph, num_replicas=num_replicas, seed=1, params=params_ER, metrics=metrics_ER)
##WS_graph = nx.watts_strogatz_graph(n=300, k=4, p=0.001)
##metrics_WS = filter(lambda met: met['name'] not in ['powerlaw exp', 'degree assortativity'], metrics)
##testers.replica_vs_original(G=WS_graph, num_replicas=num_replicas, seed=1, params=params_MUSKETEER, metrics=metrics_WS)
def paper_findings_emergent():
base_graph = graphutils.load_graph(path='data-epi/potterat.gml')
base_graph.name = 'potterat'
assert base_graph.number_of_nodes() == 250
assert base_graph.number_of_edges() == 266
num_replicas = 150
#base_graph = graphutils.load_graph(path='data-social/911_unwted.gml')
#base_graph.name = '911_krebs'
print('Musketeer:')
params_MUSKETEER = {'verbose':False, 'edge_edit_rate':[0, 0, 0, 0, 0, 0.08], 'node_edit_rate':[0, 0, 0, 0, 0, 0.08], 'node_growth_rate':[0], 'dont_cutoff_leafs':True, 'enforce_connected':True, 'accept_chance_edges':0.8, 'new_edge_horizon':20, 'num_deletion_trials':20, 'locality_bias_correction':[0, 0, 0, 0, 0],
'skip_param_sanity_check':True}
######################
# 5a figure
######################
replicas = alternatives_SEIR(G=base_graph, num_replicas=num_replicas, seed=1, params=params_MUSKETEER)
######################
# 5b figure
######################
#alternatives_outbreaks(G=base_graph, num_replicas=num_replicas, seed=1, params=params_MUSKETEER)
def paper_findings_epidemic(seed=8):
#3 is good
if seed==None:
seed = npr.randint(1E6)
print('rand seed: %d'%seed)
npr.seed(seed)
random.seed(seed)
num_replicas = 20
#num_replicas = 150
params_default = {'verbose':False, 'edge_edit_rate':[0.08, 0.07], 'node_edit_rate':[0.08, 0.07], 'node_growth_rate':[0],
'dont_cutoff_leafs':False, #NOTE: this is important
'new_edge_horizon':10, 'num_deletion_trials':20, 'locality_bias_correction':[0,], 'edit_method':'sequential',
#'accept_chance_edges':1.0,
#'edit_method':'alternating',#NOTE: this is important
#'enforce_connected':True,
'enforce_connected':False,
#'component_is_edited': [True] + 1000*[False],
#'component_is_edited': [False, False, False, False, True] + 1000*[True],
#'deferential_detachment_factor':0.0, #1.0,
}
#params_default['algorithm'] = algorithms.musketeer_on_subgraphs
metrics_default = graphutils.default_metrics[:]
metrics_default = [met for met in metrics_default if met['name'] not in ['avg flow closeness', 'avg eigvec centrality', 'degree connectivity', 'degree assortativity', 'average shortest path', 'mean ecc', 'powerlaw exp', ]]
#metrics = filter(lambda met: met['name'] not in ['avg harmonic shortest path'], metrics)
problems = [('adol.edgelist',params_default,metrics_default),
#('salganik.edgelist',params_default,metrics_default),
#('clus.edgelist',params_default,metrics_default),