-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnfold_Accessibility.py
More file actions
57 lines (44 loc) · 1.82 KB
/
Copy pathUnfold_Accessibility.py
File metadata and controls
57 lines (44 loc) · 1.82 KB
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
#!/usr/bin/env python
#
#
import sys,platform
# Adjust these lines to match the locations of your repositories
if platform.system()=='Darwin': # Mac
sys.path.append('/Users/lentz/Documents/GitHub_locals/my_py') # optional tools
sys.path.append('/Users/lentz/Documents/GitHub_locals/lonetop/src/correlations')
sys.path.append('/Users/lentz/Documents/GitHub_locals/lonetop/src/tools')
elif platform.system()=='Linux': # Linux
sys.path.append('/users/tsd/lentz/Documents/GitHub_locals/my_py') #optional tools
sys.path.append('/users/tsd/lentz/Documents/GitHub_locals/lonetop/src/correlations')
sys.path.append('/users/tsd/lentz/Documents/GitHub_locals/lonetop/src/tools')
else:
raise NameError, 'unknown operating system.'
import numpy as np, scipy as sc
import Gewindehammer as gwh # optional: for dict2file, cdf2histogram, etc.
from MatrixList import AdjMatrixSequence
from TemporalEdgeList import TemporalEdgeList
#
# ----------------- ----------------- ----------------- -----------------
#
if __name__=="__main__":
the_file='data/T_edgelist.txt'
At=AdjMatrixSequence(the_file,directed=True,write_label_file=False)
P,c=At.unfold_accessibility(return_accessibility_matrix=True)
#h=gwh.cdf2histogram(c)
#gwh.dict2file(c,"cumu.txt")
#gwh.dict2file(h,"histo.txt")
vir=P.sum(axis=1)
vul=P.sum(axis=0)
vir_a=np.squeeze(np.asarray(vir))
vul_a=np.squeeze(np.asarray(vul))
h_vir=np.bincount(vir_a)
h_vul=np.bincount(vul_a)
gwh.dict2file(h_vir,"virulence_histo.txt")
gwh.dict2file(h_vul,"vulnerability_histo.txt")
# Randomized versions of the temporal network
"""E=TemporalEdgeList(the_file,directed=True)
print '-> read file: done'
E.RE()
print '-> shuffling done. Writing...'
E.write("Test_RE.txt")
print '-> file written.' """