forked from hartmutlentz/TemporalNetworkAccessibility
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnfold_Accessibility.py
34 lines (28 loc) · 1 KB
/
Unfold_Accessibility.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
#!/usr/bin/env python
#
#
import sys
import numpy as np
sys.path.append('./src')
from AdjacencyMatrixSequence import AdjMatrixSequence
from TemporalNetworkEdgeList import TemporalEdgeList
import Tools
import cPickle as pickle
# import an edgelist as sequence of adjacency matrices
the_file = 'edgelists/Test.dat'
At = AdjMatrixSequence(the_file, directed=True, write_label_file=False)
# compute accessibility
c = At.unfold_accessibility(return_accessibility_matrix=False)
# derivative of accessibility profile
h = np.gradient(c)
# write the results to files
Tools.dict2file(c, "shortest_path_durations_cumulative.txt")
Tools.dict2file(h, "shortest_path_durations_histogram.txt")
### ALTERNATIVELY: read a temporal edge list and randomize it
### Details about randomization techniques are in Supplementary Material of
### [1] Lentz et al, Phys. Rev. Lett. 110, 118701 (2013)
###
# import a temporal network edgelist for randomization
#E = TemporalEdgeList(the_file, directed=True)
#E.RE(5)
#E.write("Randomized_RE.txt")