-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvisualize-J-graph
More file actions
52 lines (40 loc) · 1.33 KB
/
Copy pathvisualize-J-graph
File metadata and controls
52 lines (40 loc) · 1.33 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
#!/usr/bin/env python
import numpy as np
from scipy.special import comb
import matplotlib.pyplot as plt
from matplotlib import colors
import pandas as pd
import networkx as nx
import pickle
from os import path, makedirs
loadfile = 'beta_experiment/beta-1/sim-20180511-163357'
iter_list = np.arange(0, 2000, 1)
numAgents = 50
numNeurons = 10
autoLoad = True
alpha = 0.002 # 1 / len(iter_list)
cmap = plt.get_cmap('plasma')
folder = 'save/' + loadfile + '/figs/J'
fname = folder + '/J-graph_gen-' +\
str(iter_list[0]) + '-' + str(iter_list[1] - iter_list[0]) + \
'-' + str(iter_list[-1]) +\
'.npz'
iter = 1999
filename = 'save/' + loadfile + '/isings/gen[' + str(iter) + ']-isings.pickle'
startstr = 'Loading simulation:' + filename
print(startstr)
isings = pickle.load(open(filename, 'rb'))
J = isings[0].J
J = J + np.transpose(J)
J[:,0:3] = 0
J[abs(J)<0.3] = 0
df = pd.DataFrame(J, index=range(J.shape[0]), columns=range(J.shape[1]))
G = nx.from_pandas_adjacency(df, create_using=nx.DiGraph())
nx.draw(G, with_labels=True, node_size=1500, node_color="skyblue",
pos=nx.spectral_layout(G))
plt.show()
# figname = folder + '/J_gen-' +\
# str(iter_list[0]) + '-' + str(iter_list[1] - iter_list[0]) + \
# '-' + str(iter_list[-1]) + '.png'
# plt.savefig(figname, bbox_inches='tight', dpi=150)
# plt.show()