-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnettest.py
More file actions
32 lines (21 loc) · 769 Bytes
/
nettest.py
File metadata and controls
32 lines (21 loc) · 769 Bytes
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
import networkx as nx
import numpy as np
import string
import json
import sys
input_json_file = sys.argv[1]
output_file = sys.argv[2]
with open(input_json_file, 'r') as json_in:
text_data = json.loads(json_in.read())
labels = [item[0][0]+item[1][0]+item[2] for item in text_data['labels']]
dt = [('len', float)]
float_array = [[round(item,15)*100 for item in sub_array] for sub_array in text_data['data']]
data_array = np.array(float_array)
data_array = data_array.view(dt)
G = nx.from_numpy_matrix(data_array)
labels = dict(zip(G.nodes(),labels))
G = nx.relabel_nodes(G, labels)
G = nx.to_agraph(G)
G.node_attr.update(color="red", style="filled")
G.edge_attr.update(color='black', width="0.5")
G.draw(output_file, format='png', prog='neato')