Revision 9f4f3f35

View differences:

documents/SoA/SoAmobiCen.md
1
# SoA Mobility & Centrality
2

  
3
Base del ragionamento: La centralità cambia nel tempo se cambia il grafo
4

  
5
Problem Statement 1: Come aggiornare velocemente la centralità?
6

  
7
Kourtellis, Nicolas, Gianmarco De Francisci Morales, and Francesco Bonchi. "Scalable online betweenness centrality in evolving graphs." IEEE Transactions on Knowledge and Data Engineering 27.9 (2015): 2494-2506.
8

  
9
Lee, Min-Joong, Sunghee Choi, and Chin-Wan Chung. "Efficient algorithms for updating betweenness centrality in fully dynamic graphs." Information Sciences 326 (2016): 278-296.
10

  
11
Bergamini, Elisabetta, and Henning Meyerhenke. "Approximating betweenness centrality in fully dynamic networks." Internet Mathematics 12.5 (2016): 281-314.
12

  
13
Bergamini, Elisabetta, et al. "Faster betweenness centrality updates in evolving networks." arXiv preprint arXiv:1704.08592 (2017).
14

  
15
Bergamini, Elisabetta, and Henning Meyerhenke. "Fully-dynamic approximation of betweenness centrality." Algorithms-ESA 2015. Springer, Berlin, Heidelberg, 2015. 155-166.
16

  
17
Riondato, Matteo, and Eli Upfal. "ABRA: Approximating betweenness centrality in static and dynamic graphs with rademacher averages." ACM Transactions on Knowledge Discovery from Data (TKDD) 12.5 (2018): 61.
18

  
19
Riondato, Matteo, and Evgenios M. Kornaropoulos. "Fast approximation of betweenness centrality through sampling." Data Mining and Knowledge Discovery 30.2 (2016): 438-475.
20

  
21
Step ragionamento: va bene, ma adesso ho solo risolto il problema basilare del computo della centralità. Se volessi studiare i trend della centralità nel tempo? Beh ho bisogno di un modello di grafo dinamico/evolvente/temporale...
22

  
23
Problem Statement 2: Come si studia un grafo temporale? Come lo modello?
24

  
25
Holme, Petter, and Jari Saramäki. "Temporal networks." Physics reports 519.3 (2012): 97-125.
26

  
27
Holme, Petter. "Modern temporal network theory: a colloquium." The European Physical Journal B 88.9 (2015): 234.
28

  
29
Wehmuth, Klaus, Artur Ziviani, and Eric Fleury. "A unifying model for representing time-varying graphs." 2015 IEEE International Conference on Data Science and Advanced Analytics (DSAA). IEEE, 2015.
30

  
31
Benissimo, ce n'è quanti ne vuoi di modelli e ragionamenti da fare, vediamo di tornare allo studio di centralità o altre metriche interessanti
32
in grafi temporali. C'è quache studio di autocorrelazione di questo tipo?
33

  
34
Roberts, Steven A., G. Brent Hall, and Paul H. Calamai. "Analysing forest fragmentation using spatial autocorrelation, graphs and GIS." International Journal of Geographical Information Science 14.2 (2000): 185-204.
35

  
36
Hovestadt, Thomas, Stefan Messner, and Joachim Poethke Hans. "Evolution of reduced dispersal mortality and ‘fat-tailed’dispersal kernels in autocorrelated landscapes." Proceedings of the Royal Society of London. Series B: Biological Sciences 268.1465 (2001): 385-391.
37

  
38
Ok non male, sono studi un po' fuori dal settore Computer Networking ma almeno abbiamo delle applicazioni interessanti di quello che potrebbe essere il nostro output finale. Facciamo che "ci provo io" ad impostare uno studio di autocorrelazione della centralità. Parto dall'ipotesi di avere
39
un generatore di mobility pattern che mi fornisce uno stream temporale di coordinate x,y dei miei nodi...come faccio a crearci un grafo sopra
40
per poi calcolare le metriche?
41

  
42
da Fonseca, Guilherme Dias, et al. "On the recognition of unit disk graphs and the Distance Geometry Problem with Ranges." Discrete Applied Mathematics 197 (2015): 3-19.
43

  
44
H. Breu, D. G. Kirkpatrick, Unit disk graphs recognition is NP-hard,
45
Comp. Geom. 9(1–2) (1998) 2–24.
46

  
47
C. McDiarmid, T. Müller, Integer realizations of disk and segment
48
graphs, J. Comb. Theory, Series B 103(1) (2013) 114–143.
49

  
50
Bentley, Jon L., Donald F. Stanat, and E. Hollins Williams Jr. "The complexity of finding fixed-radius near neighbors." Information processing letters 6.6 (1977): 209-212.
51

  
52
Alla fine ce la si fa ben a generare velocemente dei grafi a partire da set di coordinate:
53
- https://www.cse.wustl.edu/~pless/546/lectures/Lecture2.pdf
54
- https://stackoverflow.com/questions/32424604/find-all-nearest-neighbors-within-a-specific-distance
55

  
56
Ma è mai possibile che sia davvero io il primo ad impostare questo tipo di analisi/problema? Magari trovo qualche modulo python già fatto
57
se cerco meglio... OMG: a cercare bene davvero ci sono proprio gli studi belli e pronti!
58

  
59
Kim, Hyoungshick, and Ross Anderson. "Temporal node centrality in complex networks." Physical Review E 85.2 (2012): 026107.
60

  
61
Kim, Hyoungshick, et al. "Centrality prediction in dynamic human contact networks." Computer Networks 56.3 (2012): 983-996.
62

  
63
Braha, Dan, and Yaneer Bar-Yam. "Time-dependent complex networks: Dynamic centrality, dynamic motifs, and cycles of social interactions." Adaptive Networks. Springer, Berlin, Heidelberg, 2009. 39-50.
64

  
65
Liao, Hao, et al. "Ranking in evolving complex networks." Physics Reports 689 (2017): 1-54.
66

  
67
Ma in particolare si distinguono due bomber nel panorama della time-analysis di centralità nel tempo: André Panisson e Ingo Scholtes, che mi offrono
68
pure dei modulini Python per impostare il mio lavoro come il loro. Partiamo da Panisson
69

  
70
Panisson modella i temporal graph come tensori, e da abile manipolazione dei tensori tira fuori un sacco di cose interessanti.
71

  
72
https://github.com/panisson/ntf-school
73

  
74
L. Gauvin, A. Panisson, C. Cattuto. Detecting the Community Structure and Activity Patterns of Temporal Networks: A Non-Negative Tensor Factorization Approach PLOS ONE 9.1 (2014): e86028.
75

  
76
https://www.youtube.com/watch?v=ehlFqkyre3k
77

  
78
https://www.slideshare.net/panisson/exploring-temporal-graph-data-with-python-a-study-on-tensor-decomposition-of-wearable-sensor-data
79

  
80
Scholtes invece prova un approccio di tipo "multi-layer graphs", sembra molto figo. Lo spiegano bene e lo supportano bene con tool molto ben sviluupati
81

  
82
https://github.com/IngoScholtes/pathpy
83
https://www.youtube.com/watch?v=CxJkVrD2ZlM
84

  
85
I Scholtes: When is a network a network? Multi-Order Graphical Model Selection in Pathways and Temporal Networks, to appear in KDD'17, arXiv:1702.05499
86
I Scholtes, N Wider, A Garas: Higher-Order Aggregate Networks in the Analysis of Temporal Networks: Path structures and centralities, The European Physical Journal B, 89:61, March 2016
87
I Scholtes, N Wider, R Pfitzner, A Garas, CJ Tessone, F Schweitzer: Causality-driven slow-down and speed-up of diffusion in non-Markovian temporal networks, Nature Communications, 5, September 2014
88
R Pfitzner, I Scholtes, A Garas, CJ Tessone, F Schweitzer: Betweenness preference: Quantifying correlations in the topological dynamics of temporal networks, Phys Rev Lett, 110(19), 198701, May 2013
documents/SoA/try.tex
1
\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
2
\PassOptionsToPackage{hyphens}{url}
3
%
4
\documentclass[]{article}
5
\usepackage{lmodern}
6
\usepackage{amssymb,amsmath}
7
\usepackage{ifxetex,ifluatex}
8
\usepackage{fixltx2e} % provides \textsubscript
9
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
10
  \usepackage[T1]{fontenc}
11
  \usepackage[utf8]{inputenc}
12
  \usepackage{textcomp} % provides euro and other symbols
13
\else % if luatex or xelatex
14
  \usepackage{unicode-math}
15
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
16
\fi
17
% use upquote if available, for straight quotes in verbatim environments
18
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
19
% use microtype if available
20
\IfFileExists{microtype.sty}{%
21
\usepackage[]{microtype}
22
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
23
}{}
24
\IfFileExists{parskip.sty}{%
25
\usepackage{parskip}
26
}{% else
27
\setlength{\parindent}{0pt}
28
\setlength{\parskip}{6pt plus 2pt minus 1pt}
29
}
30
\usepackage{hyperref}
31
\hypersetup{
32
            pdfborder={0 0 0},
33
            breaklinks=true}
34
\urlstyle{same}  % don't use monospace font for urls
35
\setlength{\emergencystretch}{3em}  % prevent overfull lines
36
\providecommand{\tightlist}{%
37
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
38
\setcounter{secnumdepth}{0}
39
% Redefines (sub)paragraphs to behave more like sections
40
\ifx\paragraph\undefined\else
41
\let\oldparagraph\paragraph
42
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
43
\fi
44
\ifx\subparagraph\undefined\else
45
\let\oldsubparagraph\subparagraph
46
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
47
\fi
48

  
49
% set default figure placement to htbp
50
\makeatletter
51
\def\fps@figure{htbp}
52
\makeatother
53

  
54

  
55
\date{}
56

  
57
\begin{document}
58

  
59
\hypertarget{soa-mobility-centrality}{%
60
\section{SoA Mobility \& Centrality}\label{soa-mobility-centrality}}
61

  
62
Base del ragionamento: La centralità cambia nel tempo se cambia il grafo
63

  
64
Problem Statement 1: Come aggiornare velocemente la centralità?
65

  
66
Kourtellis, Nicolas, Gianmarco De Francisci Morales, and Francesco
67
Bonchi. ``Scalable online betweenness centrality in evolving graphs.''
68
IEEE Transactions on Knowledge and Data Engineering 27.9 (2015):
69
2494-2506.
70

  
71
Lee, Min-Joong, Sunghee Choi, and Chin-Wan Chung. ``Efficient algorithms
72
for updating betweenness centrality in fully dynamic graphs.''
73
Information Sciences 326 (2016): 278-296.
74

  
75
Bergamini, Elisabetta, and Henning Meyerhenke. ``Approximating
76
betweenness centrality in fully dynamic networks.'' Internet Mathematics
77
12.5 (2016): 281-314.
78

  
79
Bergamini, Elisabetta, et al. ``Faster betweenness centrality updates in
80
evolving networks.'' arXiv preprint arXiv:1704.08592 (2017).
81

  
82
Bergamini, Elisabetta, and Henning Meyerhenke. ``Fully-dynamic
83
approximation of betweenness centrality.'' Algorithms-ESA 2015.
84
Springer, Berlin, Heidelberg, 2015. 155-166.
85

  
86
Riondato, Matteo, and Eli Upfal. ``ABRA: Approximating betweenness
87
centrality in static and dynamic graphs with rademacher averages.'' ACM
88
Transactions on Knowledge Discovery from Data (TKDD) 12.5 (2018): 61.
89

  
90
Riondato, Matteo, and Evgenios M. Kornaropoulos. ``Fast approximation of
91
betweenness centrality through sampling.'' Data Mining and Knowledge
92
Discovery 30.2 (2016): 438-475.
93

  
94
Step ragionamento: va bene, ma adesso ho solo risolto il problema
95
basilare del computo della centralità. Se volessi studiare i trend della
96
centralità nel tempo? Beh ho bisogno di un modello di grafo
97
dinamico/evolvente/temporale\ldots{}
98

  
99
Problem Statement 2: Come si studia un grafo temporale? Come lo modello?
100

  
101
Holme, Petter, and Jari Saramäki. ``Temporal networks.'' Physics reports
102
519.3 (2012): 97-125.
103

  
104
Holme, Petter. ``Modern temporal network theory: a colloquium.'' The
105
European Physical Journal B 88.9 (2015): 234.
106

  
107
Wehmuth, Klaus, Artur Ziviani, and Eric Fleury. ``A unifying model for
108
representing time-varying graphs.'' 2015 IEEE International Conference
109
on Data Science and Advanced Analytics (DSAA). IEEE, 2015.
110

  
111
Benissimo, ce n'è quanti ne vuoi di modelli e ragionamenti da fare,
112
vediamo di tornare allo studio di centralità o altre metriche
113
interessanti in grafi temporali. C'è quache studio di autocorrelazione
114
di questo tipo?
115

  
116
Roberts, Steven A., G. Brent Hall, and Paul H. Calamai. ``Analysing
117
forest fragmentation using spatial autocorrelation, graphs and GIS.''
118
International Journal of Geographical Information Science 14.2 (2000):
119
185-204.
120

  
121
Hovestadt, Thomas, Stefan Messner, and Joachim Poethke Hans. ``Evolution
122
of reduced dispersal mortality and `fat-tailed'dispersal kernels in
123
autocorrelated landscapes.'' Proceedings of the Royal Society of London.
124
Series B: Biological Sciences 268.1465 (2001): 385-391.
125

  
126
Ok non male, sono studi un po' fuori dal settore Computer Networking ma
127
almeno abbiamo delle applicazioni interessanti di quello che potrebbe
128
essere il nostro output finale. Facciamo che ``ci provo io'' ad
129
impostare uno studio di autocorrelazione della centralità. Parto
130
dall'ipotesi di avere un generatore di mobility pattern che mi fornisce
131
uno stream temporale di coordinate x,y dei miei nodi\ldots{}come faccio
132
a crearci un grafo sopra per poi calcolare le metriche?
133

  
134
da Fonseca, Guilherme Dias, et al. ``On the recognition of unit disk
135
graphs and the Distance Geometry Problem with Ranges.'' Discrete Applied
136
Mathematics 197 (2015): 3-19.
137

  
138
H. Breu, D. G. Kirkpatrick, Unit disk graphs recognition is NP-hard,
139
Comp. Geom. 9(1--2) (1998) 2--24.
140

  
141
C. McDiarmid, T. Müller, Integer realizations of disk and segment
142
graphs, J. Comb. Theory, Series B 103(1) (2013) 114--143.
143

  
144
Bentley, Jon L., Donald F. Stanat, and E. Hollins Williams Jr. ``The
145
complexity of finding fixed-radius near neighbors.'' Information
146
processing letters 6.6 (1977): 209-212.
147

  
148
Alla fine ce la si fa ben a generare velocemente dei grafi a partire da
149
set di coordinate: -
150
https://www.cse.wustl.edu/\textasciitilde{}pless/546/lectures/Lecture2.pdf
151
-
152
https://stackoverflow.com/questions/32424604/find-all-nearest-neighbors-within-a-specific-distance
153

  
154
Ma è mai possibile che sia davvero io il primo ad impostare questo tipo
155
di analisi/problema? Magari trovo qualche modulo python già fatto se
156
cerco meglio\ldots{} OMG: a cercare bene davvero ci sono proprio gli
157
studi belli e pronti!
158

  
159
Kim, Hyoungshick, and Ross Anderson. ``Temporal node centrality in
160
complex networks.'' Physical Review E 85.2 (2012): 026107.
161

  
162
Kim, Hyoungshick, et al. ``Centrality prediction in dynamic human
163
contact networks.'' Computer Networks 56.3 (2012): 983-996.
164

  
165
Braha, Dan, and Yaneer Bar-Yam. ``Time-dependent complex networks:
166
Dynamic centrality, dynamic motifs, and cycles of social interactions.''
167
Adaptive Networks. Springer, Berlin, Heidelberg, 2009. 39-50.
168

  
169
Liao, Hao, et al. ``Ranking in evolving complex networks.'' Physics
170
Reports 689 (2017): 1-54.
171

  
172
Ma in particolare si distinguono due bomber nel panorama della
173
time-analysis di centralità nel tempo: André Panisson e Ingo Scholtes,
174
che mi offrono pure dei modulini Python per impostare il mio lavoro come
175
il loro. Partiamo da Panisson
176

  
177
Panisson modella i temporal graph come tensori, e da abile manipolazione
178
dei tensori tira fuori un sacco di cose interessanti.
179

  
180
https://github.com/panisson/ntf-school
181

  
182
L. Gauvin, A. Panisson, C. Cattuto. Detecting the Community Structure
183
and Activity Patterns of Temporal Networks: A Non-Negative Tensor
184
Factorization Approach PLOS ONE 9.1 (2014): e86028.
185

  
186
https://www.youtube.com/watch?v=ehlFqkyre3k
187

  
188
https://www.slideshare.net/panisson/exploring-temporal-graph-data-with-python-a-study-on-tensor-decomposition-of-wearable-sensor-data
189

  
190
Scholtes invece prova un approccio di tipo ``multi-layer graphs'',
191
sembra molto figo. Lo spiegano bene e lo supportano bene con tool molto
192
ben sviluupati
193

  
194
https://github.com/IngoScholtes/pathpy
195
https://www.youtube.com/watch?v=CxJkVrD2ZlM
196

  
197
I Scholtes: When is a network a network? Multi-Order Graphical Model
198
Selection in Pathways and Temporal Networks, to appear in KDD'17,
199
arXiv:1702.05499 I Scholtes, N Wider, A Garas: Higher-Order Aggregate
200
Networks in the Analysis of Temporal Networks: Path structures and
201
centralities, The European Physical Journal B, 89:61, March 2016 I
202
Scholtes, N Wider, R Pfitzner, A Garas, CJ Tessone, F Schweitzer:
203
Causality-driven slow-down and speed-up of diffusion in non-Markovian
204
temporal networks, Nature Communications, 5, September 2014 R Pfitzner,
205
I Scholtes, A Garas, CJ Tessone, F Schweitzer: Betweenness preference:
206
Quantifying correlations in the topological dynamics of temporal
207
networks, Phys Rev Lett, 110(19), 198701, May 2013
208

  
209
\end{document}
documents/soaEXT.md
1
SVILUPPI POSSIBILI:
2
- EFFETTI DELLA CORRELAZIONE, vedere come cambia una performance metric di uno streaming/diffusion-process in base a qualche parametro di mobilità
3
- vedere se possiamo sfruttare la correlazione con past-centrality per predirre la next-centr
4
- misurare la k-coreness
5

  
6
Cosa posso plottare?
7

  
8
0) Autocorrelazione delle 3 metriche (al variare di ray OR speed OR density OR mob-model)
9

  
10
1) Correlazione fra le 3 metriche: 
11

  
12
    BC      DEG     KCORE
13
BC
14

  
15
DEG
16

  
17
KCORE
18

  
19
In diversi scenari: (dense vs sparse), (slow vs fast), (short-range vs long-range)  (mobility models)
20

  
21
2) Rank Correlation...
22

  
23
# How Correlated Are Network Centrality Measures?
24
Thomas W. Valente, PhD,
25
University of Southern California, Department of Prevention Research, Los Angeles
26
Kathryn Coronges, MPH,
27
University of Southern California, Department of Prevention Research, Los Angeles
28
Cynthia Lakon, PhD, and
29
University of Southern California, Department of Prevention Research, Los Angeles
30
Elizabeth Costenbader, PhD
31
Research Triangle Institute, Raleigh North Carolina
32

  
33
We correlated the 9 measures for each network and then calculated the average correlation,
34
standard deviation, and range across centrality measures. We also calculated the overall
35
correlation and compared it by study to assess the degree of variation in average correlation
36
between studies. Lastly, we explore the associations between four different sociometric
37
network properties (i.e., density, reciprocity, centralization and number of components) and
38
the centrality correlations. This last analysis seeks to determine whether centrality measures
39
are more highly correlated in *dense or sparse networks*, in reciprocal or non-reciprocal
40
networks, in *centralized or decentralized* networks, and in networks with *few or many
41
components*. Density is the number of ties in the network divided by the total possible number
42
of ties (Nx(N−1)). Reciprocity was measured as the percent of possible ties that are symmetric.
43
Degree centralization was measured using Freeman’s (1979) formula. The number of
44
components in the network was determined by symmetrizing the network and calculating
45
components.
46

  
47

  
48
# Betweenness centrality correlation in social networks
49
K.-I. Goh, E. Oh, B. Kahng, and D. Kim
50
PHYSICAL REVIEW E 67, 017101 2003
51

  
52
PHYSICAL REVIEW E 85, 026107 (2012)
53
# Temporal node centrality in complex networks
54
Hyoungshick Kim and Ross Anderson
55
Computer Laboratory, University of Cambridge, 15 J. J. Thomson Avenue, Cambridge CB3 0FD, United Kingdom
56
(Received 1 November 2011; published 13 February 2012)
57

  
58
--> Buona definizione di Temporal Betweenness, qualche studio di correlazione (ma non si capisce tanto)
59

  
60

  
61
# Centrality prediction in dynamic human contact networks
62
Hyoungshick Kim ⇑ , John Tang, Ross Anderson, Cecilia Mascolo
63
Computer Laboratory, University of Cambridge, United Kingdom
64

  
65
--> un sacco di plot simili ai miei per grafi dinamici molto regolari (contact networks), "gente a conferenze" e "gente in giro per scuola". Fanno i surface-plot che facciamo noi e considerazioni simili sulla correlazioni della BC a vari lag-width.
66
Lo fanno per poi definire dei "predictor" di centralità
67

  
68

  
69
PHYSICAL REVIEW E 84, 016105 (2011)
70
# Path lengths, correlations, and centrality in temporal networks
71
Raj Kumar Pan and Jari Saramäki
72

  
73
--> Abbastanza inutile... la correlazione che studiano è tra "temporal distance" e "static graph distance". Le due metriche dipendono dal tipo di grafo utilizzato per rappresentare i loro dataset (telefonate, voli-aerei). Non studiano tanto la centralità nel tempo. Dicono solo che, rispetto al degree o all'indice k-shell/k-core, la Closeness Centrality è più fortemente correlata rispetto alla temporal closeness centrality. 
74

  
75

  
76
# Time-Dependent Complex Networks: Dynamic Centrality, Dynamic Motifs, and Cycles of Social Interactions
77
Dan Braha and Yaneer Bar-Yam
78

  
79
--> Brutto paper, ma fanno tante misure, inclusa correlazione tra esistenza di archi a diversi istanti di tempo
80

  
81

  
82
# Betweenness Preference: Quantifying Correlations in the Topological Dynamics of Temporal Networks
83
René Pfitzner,* Ingo Scholtes, † Antonios Garas, ‡ Claudio J. Tessone, § and Frank Schweitzer k
84
ETH Zurich, Chair of Systems Design, Weinbergstrasse 56/58, 8092 Zurich, Switzerland
85
(Received 8 August 2012; revised manuscript received 19 March 2013; published 10 May 2013)
86

  
87
--> betweenness preference, i.e., the
88
tendency of nodes to preferentially connect—in a temporal
89
sense—particular pairs of neighbors, (i) is not captured in
90
the time-aggregated network, (ii) is present in empirical
91
temporal network data, (iii) changes the topology of time-
92
respecting paths, and (iv) critically influences dynamical
93
processes evolving on temporal networks.
94

  
95
Studiano la probabilità che un nodo v sia collegato a s al tempo t, e a d al tempo t+1.
96
Così definiscono la BC^v_{s,d} = 1 se c'è un arco s-v al tempo t un arco v-d al tempo t+1, 0 altrimenti.
97
Poi pigliano dati reali di contatti fra gente e dimostrano c'è "betwenness preference" in grafi reali
98
e non ce n'è in grafi temporali generati a caso. Pertanto dicono che questa proprietà di "btw preference"
99
non va mai scordata anzi, ci danno nu generatore per generare grafi che possiedono una buona distribuzione
100
di btw preference.
nkStudy.py
1
import code  # code.interact(local=dict(globals(), **locals()))
2
from collections import deque
3
from scipy import stats
4
import matplotlib.pyplot as plt
5
from collections import defaultdict
6
import os
7
import sys
8
from statsmodels.graphics.tsaplots import plot_acf, acf
9
import operator
10
from mpl_toolkits import mplot3d
11
import pandas as pd
12
from pprint import pprint
13
import numpy as np
14
import glob
15

  
16

  
17

  
18
folder = sys.argv[1]
19
lags = 100
20
if len(sys.argv) > 2:
21
    lags = int(sys.argv[2])
22
nick = folder.split('/')[-2].split('_')[0]
23
os.chdir(folder)
24

  
25
bcdf = pd.DataFrame()  # rows=nodes columns=BC at column-index time-instant
26
degdf = pd.DataFrame()  # rows=nodes columns=DEG at column-index time-instant
27
kcoredf = pd.DataFrame()  # rows=nodes columns=KCORE at column-index time-instant
28
allnkd=pd.DataFrame()
29
print "Loading data from", folder, "..."
30
for snap in sorted(glob.glob('./stats*')):
31
    # print "",snap
32
    node_id = int(snap.strip('.csv').strip('./stats'))
33
    df = pd.read_csv(snap, names=['time', 'bc', 'deg', 'kcore'], skiprows=1)
34
    d={(node_id, t): (df.iloc[t]['bc'], df.iloc[t]['deg'], df.iloc[t]['kcore']) for t in df.index}
35
    nkd=pd.DataFrame.from_dict(d, orient='index', columns=['bc', 'deg', 'kcore'])
36
    allnkd=allnkd.append(nkd)
37

  
38
srtNK=allnkd.sort_values(by=['bc'], ascending=False)
39

  
40
#code.interact(local=dict(globals(), **locals()))
41

  
42
#min-max Normalize columns
43
for c in srtNK.columns:
44
    srtNK[c] = (srtNK[c] - srtNK[c].min()) / (srtNK[c].max() - srtNK[c].min())
45

  
46
bc, deg, kcore = srtNK['bc'], srtNK['deg'], srtNK['kcore']
47

  
48
bcc = bc - bc.mean()
49
degc = deg - deg.mean()
50
kcorec = kcore - kcore.mean()
51

  
52
y=srtNK['bc']
53
bcdeg = bcc * degc
54
degkcore = degc * kcorec
55
bckcore = bcc * kcorec
56

  
57
if not os.path.exists("plots"+nick):
58
    os.makedirs("plots"+nick)
59

  
60
os.chdir("plots"+nick)
61

  
62
'''import math
63
ymin=math.floor(min(map(min, [bcdeg, degkcore, bckcore, y])))
64
ymax=math.ceil(max(map(max, [bcdeg, degkcore, bckcore, y])))'''
65

  
66

  
67
bcdeg.plot(label='bc-deg', style='b--')
68
y.plot(label='BC', kind='line', style='k-')
69
plt.xticks([], [])
70
plt.legend()
71
plt.axhline(y=0.1, color='r', linestyle='--', lw=1.2)
72
plt.axhline(y=0.0, color='r', linestyle='--', lw=2)
73
plt.axhline(y=-0.1, color='r', linestyle='--', lw=1.2)
74
plt.ylim(-0.2, 1.0)
75
plt.yticks(np.arange(-0.2, 1.0, step=0.1))
76
plt.xlabel("(nodeID, time) couples, sorted by BC")
77
plt.ylabel("Product of First Central Moments")
78
plt.savefig(nick+"bc-degEvo.pdf", format='pdf')
79
plt.clf()
80

  
81
degkcore.plot(label='deg-kcore', style='r-')
82
y.plot(label='BC', kind='line', style='k-')
83
plt.xticks([], [])
84
plt.legend()
85
plt.axhline(y=0.1, color='r', linestyle='--', lw=1.2)
86
plt.axhline(y=0.0, color='r', linestyle='--', lw=2)
87
plt.axhline(y=-0.1, color='r', linestyle='--', lw=1.2)
88
plt.ylim(-0.2, 1.0)
89
plt.xlabel("(nodeID, time) couples, sorted by BC")
90
plt.ylabel("Product of First Central Moments")
91
plt.yticks(np.arange(-0.2, 1.0, step=0.1))
92
plt.savefig(nick+"deg-kcoreEvo.pdf", format='pdf')
93
plt.clf()
94

  
95
bckcore.plot(label='bc-kcore', style='g-')
96
y.plot(label='BC', kind='line', style='k-')
97
plt.legend()
98
plt.axhline(y=0.1, color='r', linestyle='--', lw=1.2)
99
plt.axhline(y=0.0, color='r', linestyle='--', lw=2)
100
plt.axhline(y=-0.1, color='r', linestyle='--', lw=1.2)
101
plt.ylim(-0.2, 1.0)
102
plt.yticks(np.arange(-0.2, 1.0, step=0.1))
103
plt.xticks([], [])
104
plt.xlabel("(nodeID, time) couples, sorted by BC")
105
plt.ylabel("Product of First Central Moments")
106
plt.savefig(nick+"bc-kcoreEvo.pdf", format='pdf')
107
plt.clf()
108

  
109
print "THE END"
timeAnalysis.py
73 73

  
74 74
os.chdir("plots"+nick)
75 75
# Plotting
76
code.interact(local=dict(globals(), **locals()))
76

  
77 77

  
78 78
# ACF boxplots
79 79
bcACF.T.boxplot(column=[1]+range(5,lags,5))
......
172 172
toplotdf = pd.DataFrame([[1, a, b],
173 173
                         [a, 1, c],
174 174
                         [b, c, 1]])
175

  
176
#code.interact(local=dict(globals(), **locals()))
175 177
import seaborn as sns
176 178
sns.set()
177 179

  
178
#TODO
179
#sns.heatmap(degdf.corr(), cmap="RdBu_r", center=0.0, vmin=-1.0, vmax=1.0)
180 180

  
181
'''f250=bcdf.iloc[750:1000,:]
182
f250.columns=map(str, range(0, len(f250.columns)))
183
sns.heatmap(f250.corr(), cmap="RdBu_r", center=0.0, vmin=-1.0, vmax=1.0,
184
    cbar_kws={"label": "Cross-nodes BC Pearson Correlation"})
185
plt.xlabel("Nodes")
186
plt.ylabel("Nodes")
187
plt.savefig(nick+"bcNodesCorrHM.pdf", format='pdf')
188
plt.clf()
189

  
190
cg=sns.clustermap(f250.corr(), cmap="RdBu_r", robust=True)
191
cg.ax_row_dendrogram.set_visible(False)
192
cg.ax_col_dendrogram.set_visible(False)
193
cg.savefig(nick+"bcNodesClusteredCorr.pdf", format='pdf')
194
plt.clf()'''
181 195

  
182 196
sns.heatmap(toplotdf, cmap="RdBu_r", center=0.0, vmin=-1.0, vmax=1.0)
183 197
plt.savefig(nick+"meanMetricsCorrelation.pdf", format='pdf')

Also available in: Unified diff