-
Notifications
You must be signed in to change notification settings - Fork 0
/
nwDiffusion.py
43 lines (29 loc) · 917 Bytes
/
nwDiffusion.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
35
36
37
38
39
40
41
42
43
import random
import networkx as nx
from diffusionAE import *
# read graph.txt
# store lines of the graph in a graph_dict
# since it's undirected graph --- for (node1, node2), graph_dict[node1] = [..., node2], graph_dict[node2] = [..., node1]
f_graph = open("newman.txt", "r")
G = nx.Graph()
for line in f_graph:
l= line.split(" ") # read node1 node2
node1 = int(l[0])
node2 = int(l[1])
G.add_edge(node1, node2)
# if node1 in graph_dict:
# graph_dict[node1].append(node2)
# else:
# graph_dict[node1] = [node2]
# if node2 in graph_dict:
# graph_dict[node2].append(node1)
# else:
# graph_dict[node2] = [node1]
f_graph.close()
# sim_list = []
# for x in range(2000):
sim = Simulation(G)
num_input = np.array(sim).shape[1]
# print(num_input)
# sim_list.append(Re_sim)
model(G, 200, 200, sim)