In [1]:
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
In [2]:
G = nx.read_gpickle('20150902_all_ird Final Graph.pkl')
In [3]:
# Number of edges
n_edges = len(G.edges())
n_edges
Out[3]:
In [4]:
# Number of nodes
n_nodes = len(G.nodes())
n_nodes
Out[4]:
In [5]:
# Sparsity of the graph
n_edges / n_nodes**2
Out[5]:
In [6]:
pwis = [d['pwi'] for sc, sk, d in G.edges(data=True)]
plt.hist(pwis)
Out[6]:
In [10]:
np.median(pwis)
Out[10]:
In [13]:
(8 - np.median(pwis)) / 8 * 100
Out[13]:
In [15]:
np.median(pwis) / 8 * 100
Out[15]:
In [8]:
# Plot PWI distribution
from collections import defaultdict
seg_pwis = defaultdict(list)
for sc, sk, d in G.edges(data=True):
for s, p in d['segments'].items(): # s: segment, p: pwi
seg_pwis[s].append(p)
In [9]:
for s, ps in seg_pwis.items():
fig = plt.figure()
ax = fig.add_subplot(111)
ax.hist(ps)
ax.set_title('Segment {0}, Min {1} Max{2}'.format(s, min(ps), max(ps)))
In [ ]: