In [2]:
import networkx as nx
In [3]:
import numpy as np
In [4]:
import matplotlib.pyplot as plt
In [6]:
NUM_CASCADES = 100
In [7]:
ffr = open('synthetic/synth-cascades-zurich-fig2/synth-cascades-zurich-fig2.txt', 'r')
In [8]:
G = nx.DiGraph()
In [9]:
added_nodes = set()
In [10]:
for line in ffr:
u1, u2, weight = line[:-1].split(',')
u1, u2 = map(int, [u1, u2])
weight = float(weight)
for u in [u1, u2]:
if u not in added_nodes:
added_nodes.add(u)
G.add_node(u)
G.add_edge(u1, u2, weight=weight)
In [16]:
pos = nx.spring_layout(G)
edge_labels = dict([((u, v,), d['weight']) for u, v, d in G.edges(data=True)])
nx.draw_networkx_edge_labels(G,pos,edge_labels=edge_labels)
nx.draw(G, pos)
plt.show()
In [15]:
nx.write_gexf(G, "synthetic/synth-cascades-zurich-fig2/synth-cascades-zurich-fig2.gexf")
In [19]:
np.random.exponential(1/0.01)
Out[19]:
In [ ]: