-
Notifications
You must be signed in to change notification settings - Fork 0
/
from_json.py
50 lines (47 loc) · 884 Bytes
/
from_json.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
44
45
46
47
48
49
50
import networkx as nx
from networkx.readwrite import json_graph
import json
from pyvis.network import Network
with open('edge_list_mini.json', 'r') as infile:
js_graph = json.load(infile)
G = json_graph.node_link_graph(js_graph)
print(G)
nt = Network('1000px', '1000px', directed=True)
nt.from_nx(G)
# nt.show_buttons()
nt.set_options(
"""
const options = {
"nodes": {
"borderWidth": 0,
"borderWidthSelected": 1,
"opacity": 1,
"font": {
"strokeWidth": 4,
"size": 20
},
"size": 1
},
"edges": {
"arrowStrikethrough": false,
"color": {
"opacity": 0.8
},
"scaling": {
"max": 8
},
"selfReferenceSize": null,
"selfReference": {
"angle": 0.7853981633974483
},
"smooth": {
"forceDirection": "none"
}
},
"physics": {
"minVelocity": 0.75
}
}
"""
)
nt.show('nx.html')