Spaces:
Runtime error
Runtime error
delete files
Browse files- pyvis/notebooks/dot.html +0 -84
- pyvis/notebooks/example.html +0 -108
- pyvis/notebooks/example.ipynb +0 -483
- pyvis/notebooks/test.dot +0 -9
pyvis/notebooks/dot.html
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<html>
|
2 |
-
<head>
|
3 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vis-network@latest/styles/vis-network.css" type="text/css" />
|
4 |
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vis-network@latest/dist/vis-network.min.js"> </script>
|
5 |
-
<center>
|
6 |
-
<h1></h1>
|
7 |
-
</center>
|
8 |
-
|
9 |
-
<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
|
10 |
-
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
|
11 |
-
|
12 |
-
<style type="text/css">
|
13 |
-
|
14 |
-
#mynetwork {
|
15 |
-
width: 500px;
|
16 |
-
height: 500px;
|
17 |
-
background-color: #ffffff;
|
18 |
-
border: 1px solid lightgray;
|
19 |
-
position: relative;
|
20 |
-
float: left;
|
21 |
-
}
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
</style>
|
29 |
-
|
30 |
-
</head>
|
31 |
-
|
32 |
-
<body>
|
33 |
-
<div id = "mynetwork"></div>
|
34 |
-
|
35 |
-
|
36 |
-
<script type="text/javascript">
|
37 |
-
|
38 |
-
// initialize global variables.
|
39 |
-
var edges;
|
40 |
-
var nodes;
|
41 |
-
var network;
|
42 |
-
var container;
|
43 |
-
var options, data;
|
44 |
-
|
45 |
-
|
46 |
-
// This method is responsible for drawing the graph, returns the drawn network
|
47 |
-
function drawGraph() {
|
48 |
-
var container = document.getElementById('mynetwork');
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
var DOTstring = "digraph { a [label=12, entity_id=12, entity_class=\"truck\"]; b [label=7, entity_id=7,entity_class=\"bike\"]; c [label=3, entity_id=3, entity_class=\"car\"]; a -> b[label=\"solid edge\"]; a -> b [label=\"dashed edge\", style=dashed]; a -> c [label=\"dashed edge\", style=dashed]; a -> c [label=\"dotted edge\", style=dotted]; }";
|
53 |
-
data = vis.network.dotparser.DOTToGraph(DOTstring);
|
54 |
-
|
55 |
-
var options = data.options;
|
56 |
-
options = Object.assign(options, {
|
57 |
-
nodes: {
|
58 |
-
shape: "dot"
|
59 |
-
},
|
60 |
-
});
|
61 |
-
|
62 |
-
options = Object.assign(options, {"physics": {"enabled": true, "barnesHut": {"theta": 0.5, "gravitationalConstant": -2000, "centralGravity": 0.3, "springLength": 200, "springConstant": 0.04, "damping": 0.09, "avoidOverlap": 0}, "maxVelocity": 50, "minVelocity": 0.1, "solver": "barnesHut", "stabilization": {"enabled": true, "iterations": 1000, "updateInterval": 100, "onlyDynamicEdges": false, "fit": true}}})
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
network = new vis.Network(container, data, options);
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
return network;
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
-
drawGraph();
|
81 |
-
|
82 |
-
</script>
|
83 |
-
</body>
|
84 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyvis/notebooks/example.html
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
<html>
|
2 |
-
<head>
|
3 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vis-network@latest/styles/vis-network.css" type="text/css" />
|
4 |
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vis-network@latest/dist/vis-network.min.js"> </script>
|
5 |
-
<center>
|
6 |
-
<h1></h1>
|
7 |
-
</center>
|
8 |
-
|
9 |
-
<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
|
10 |
-
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
|
11 |
-
|
12 |
-
<style type="text/css">
|
13 |
-
|
14 |
-
#mynetwork {
|
15 |
-
width: 500px;
|
16 |
-
height: 500px;
|
17 |
-
background-color: #ffffff;
|
18 |
-
border: 1px solid lightgray;
|
19 |
-
position: relative;
|
20 |
-
float: left;
|
21 |
-
}
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
</style>
|
29 |
-
|
30 |
-
</head>
|
31 |
-
|
32 |
-
<body>
|
33 |
-
<div id = "mynetwork"></div>
|
34 |
-
|
35 |
-
|
36 |
-
<script type="text/javascript">
|
37 |
-
|
38 |
-
// initialize global variables.
|
39 |
-
var edges;
|
40 |
-
var nodes;
|
41 |
-
var network;
|
42 |
-
var container;
|
43 |
-
var options, data;
|
44 |
-
|
45 |
-
|
46 |
-
// This method is responsible for drawing the graph, returns the drawn network
|
47 |
-
function drawGraph() {
|
48 |
-
var container = document.getElementById('mynetwork');
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
// parsing and collecting nodes and edges from the python
|
53 |
-
nodes = new vis.DataSet([{"id": 0, "label": 0, "shape": "dot"}, {"id": 1, "label": 1, "shape": "dot"}, {"id": 2, "label": 2, "shape": "dot"}, {"id": 3, "label": 3, "shape": "dot"}, {"id": 4, "label": 4, "shape": "dot"}]);
|
54 |
-
edges = new vis.DataSet([{"from": 0, "to": 2}, {"from": 0, "to": 3}, {"from": 0, "to": 4}, {"from": 1, "to": 1}, {"from": 1, "to": 3}, {"from": 1, "to": 2}]);
|
55 |
-
|
56 |
-
// adding nodes and edges to the graph
|
57 |
-
data = {nodes: nodes, edges: edges};
|
58 |
-
|
59 |
-
var options = {
|
60 |
-
"configure": {
|
61 |
-
"enabled": false
|
62 |
-
},
|
63 |
-
"edges": {
|
64 |
-
"color": {
|
65 |
-
"inherit": true
|
66 |
-
},
|
67 |
-
"smooth": {
|
68 |
-
"enabled": true,
|
69 |
-
"type": "dynamic"
|
70 |
-
}
|
71 |
-
},
|
72 |
-
"interaction": {
|
73 |
-
"dragNodes": true,
|
74 |
-
"hideEdgesOnDrag": false,
|
75 |
-
"hideNodesOnDrag": false
|
76 |
-
},
|
77 |
-
"physics": {
|
78 |
-
"enabled": true,
|
79 |
-
"stabilization": {
|
80 |
-
"enabled": true,
|
81 |
-
"fit": true,
|
82 |
-
"iterations": 1000,
|
83 |
-
"onlyDynamicEdges": false,
|
84 |
-
"updateInterval": 50
|
85 |
-
}
|
86 |
-
}
|
87 |
-
};
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
network = new vis.Network(container, data, options);
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
return network;
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
drawGraph();
|
105 |
-
|
106 |
-
</script>
|
107 |
-
</body>
|
108 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyvis/notebooks/example.ipynb
DELETED
@@ -1,483 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 1,
|
6 |
-
"metadata": {},
|
7 |
-
"outputs": [],
|
8 |
-
"source": [
|
9 |
-
"import sys\n",
|
10 |
-
"sys.path.append('../')\n",
|
11 |
-
"from pyvis.network import Network"
|
12 |
-
]
|
13 |
-
},
|
14 |
-
{
|
15 |
-
"cell_type": "markdown",
|
16 |
-
"metadata": {},
|
17 |
-
"source": [
|
18 |
-
"### Basic Example"
|
19 |
-
]
|
20 |
-
},
|
21 |
-
{
|
22 |
-
"cell_type": "code",
|
23 |
-
"execution_count": 2,
|
24 |
-
"metadata": {},
|
25 |
-
"outputs": [
|
26 |
-
{
|
27 |
-
"data": {
|
28 |
-
"text/html": [
|
29 |
-
"\n",
|
30 |
-
" <iframe\n",
|
31 |
-
" width=\"500px\"\n",
|
32 |
-
" height=\"500px\"\n",
|
33 |
-
" src=\"example.html\"\n",
|
34 |
-
" frameborder=\"0\"\n",
|
35 |
-
" allowfullscreen\n",
|
36 |
-
" ></iframe>\n",
|
37 |
-
" "
|
38 |
-
],
|
39 |
-
"text/plain": [
|
40 |
-
"<IPython.lib.display.IFrame at 0x7fbe1d273d30>"
|
41 |
-
]
|
42 |
-
},
|
43 |
-
"execution_count": 2,
|
44 |
-
"metadata": {},
|
45 |
-
"output_type": "execute_result"
|
46 |
-
}
|
47 |
-
],
|
48 |
-
"source": [
|
49 |
-
"g = Network(notebook=True)\n",
|
50 |
-
"g.add_nodes(range(5))\n",
|
51 |
-
"g.add_edges([\n",
|
52 |
-
" (0, 2),\n",
|
53 |
-
" (0, 3),\n",
|
54 |
-
" (0, 4),\n",
|
55 |
-
" (1, 1),\n",
|
56 |
-
" (1, 3),\n",
|
57 |
-
" (1, 2)\n",
|
58 |
-
"])\n",
|
59 |
-
"g.show(\"example.html\")"
|
60 |
-
]
|
61 |
-
},
|
62 |
-
{
|
63 |
-
"cell_type": "markdown",
|
64 |
-
"metadata": {},
|
65 |
-
"source": [
|
66 |
-
"### Dot File example"
|
67 |
-
]
|
68 |
-
},
|
69 |
-
{
|
70 |
-
"cell_type": "code",
|
71 |
-
"execution_count": 9,
|
72 |
-
"metadata": {
|
73 |
-
"scrolled": true
|
74 |
-
},
|
75 |
-
"outputs": [
|
76 |
-
{
|
77 |
-
"data": {
|
78 |
-
"text/html": [
|
79 |
-
"\n",
|
80 |
-
" <iframe\n",
|
81 |
-
" width=\"500px\"\n",
|
82 |
-
" height=\"500px\"\n",
|
83 |
-
" src=\"dot.html\"\n",
|
84 |
-
" frameborder=\"0\"\n",
|
85 |
-
" allowfullscreen\n",
|
86 |
-
" ></iframe>\n",
|
87 |
-
" "
|
88 |
-
],
|
89 |
-
"text/plain": [
|
90 |
-
"<IPython.lib.display.IFrame at 0x7fbe3d2ead00>"
|
91 |
-
]
|
92 |
-
},
|
93 |
-
"execution_count": 9,
|
94 |
-
"metadata": {},
|
95 |
-
"output_type": "execute_result"
|
96 |
-
}
|
97 |
-
],
|
98 |
-
"source": [
|
99 |
-
"h = Network(notebook=True)\n",
|
100 |
-
"h.from_DOT(\"test.dot\")\n",
|
101 |
-
"\n",
|
102 |
-
"# All properties have to be enclosed by double quotes and \n",
|
103 |
-
"# there and there must be no comma at the end of a list.\n",
|
104 |
-
"# See https://visjs.github.io/vis-network/docs/network/ for all options\n",
|
105 |
-
"h.set_options(\"\"\"\n",
|
106 |
-
"var options = {\n",
|
107 |
-
" \"physics\": {\n",
|
108 |
-
" \"enabled\": true,\n",
|
109 |
-
" \"barnesHut\": {\n",
|
110 |
-
" \"theta\": 0.5,\n",
|
111 |
-
" \"gravitationalConstant\": -2000,\n",
|
112 |
-
" \"centralGravity\": 0.3,\n",
|
113 |
-
" \"springLength\": 200,\n",
|
114 |
-
" \"springConstant\": 0.04,\n",
|
115 |
-
" \"damping\": 0.09,\n",
|
116 |
-
" \"avoidOverlap\": 0\n",
|
117 |
-
" },\n",
|
118 |
-
" \"maxVelocity\": 50,\n",
|
119 |
-
" \"minVelocity\": 0.1,\n",
|
120 |
-
" \"solver\": \"barnesHut\",\n",
|
121 |
-
" \"stabilization\": {\n",
|
122 |
-
" \"enabled\": true,\n",
|
123 |
-
" \"iterations\": 1000,\n",
|
124 |
-
" \"updateInterval\": 100,\n",
|
125 |
-
" \"onlyDynamicEdges\": false,\n",
|
126 |
-
" \"fit\": true\n",
|
127 |
-
" }\n",
|
128 |
-
" }\n",
|
129 |
-
"}\n",
|
130 |
-
"\"\"\")\n",
|
131 |
-
"h.show(\"dot.html\")"
|
132 |
-
]
|
133 |
-
},
|
134 |
-
{
|
135 |
-
"cell_type": "markdown",
|
136 |
-
"metadata": {},
|
137 |
-
"source": [
|
138 |
-
"### Basic NetworkX example"
|
139 |
-
]
|
140 |
-
},
|
141 |
-
{
|
142 |
-
"cell_type": "code",
|
143 |
-
"execution_count": 10,
|
144 |
-
"metadata": {},
|
145 |
-
"outputs": [],
|
146 |
-
"source": [
|
147 |
-
"import networkx as nx"
|
148 |
-
]
|
149 |
-
},
|
150 |
-
{
|
151 |
-
"cell_type": "code",
|
152 |
-
"execution_count": 11,
|
153 |
-
"metadata": {
|
154 |
-
"scrolled": false
|
155 |
-
},
|
156 |
-
"outputs": [
|
157 |
-
{
|
158 |
-
"data": {
|
159 |
-
"text/html": [
|
160 |
-
"\n",
|
161 |
-
" <iframe\n",
|
162 |
-
" width=\"500px\"\n",
|
163 |
-
" height=\"500px\"\n",
|
164 |
-
" src=\"example.html\"\n",
|
165 |
-
" frameborder=\"0\"\n",
|
166 |
-
" allowfullscreen\n",
|
167 |
-
" ></iframe>\n",
|
168 |
-
" "
|
169 |
-
],
|
170 |
-
"text/plain": [
|
171 |
-
"<IPython.lib.display.IFrame at 0x7f3ef910af40>"
|
172 |
-
]
|
173 |
-
},
|
174 |
-
"execution_count": 11,
|
175 |
-
"metadata": {},
|
176 |
-
"output_type": "execute_result"
|
177 |
-
}
|
178 |
-
],
|
179 |
-
"source": [
|
180 |
-
"nxg = nx.random_tree(20)\n",
|
181 |
-
"g.from_nx(nxg)\n",
|
182 |
-
"g.show(\"example.html\")"
|
183 |
-
]
|
184 |
-
},
|
185 |
-
{
|
186 |
-
"cell_type": "markdown",
|
187 |
-
"metadata": {},
|
188 |
-
"source": [
|
189 |
-
"### Disabling Physics interaction"
|
190 |
-
]
|
191 |
-
},
|
192 |
-
{
|
193 |
-
"cell_type": "code",
|
194 |
-
"execution_count": 6,
|
195 |
-
"metadata": {},
|
196 |
-
"outputs": [
|
197 |
-
{
|
198 |
-
"data": {
|
199 |
-
"text/html": [
|
200 |
-
"\n",
|
201 |
-
" <iframe\n",
|
202 |
-
" width=\"500px\"\n",
|
203 |
-
" height=\"500px\"\n",
|
204 |
-
" src=\"example.html\"\n",
|
205 |
-
" frameborder=\"0\"\n",
|
206 |
-
" allowfullscreen\n",
|
207 |
-
" \n",
|
208 |
-
" ></iframe>\n",
|
209 |
-
" "
|
210 |
-
],
|
211 |
-
"text/plain": [
|
212 |
-
"<IPython.lib.display.IFrame at 0x7f882040c6d0>"
|
213 |
-
]
|
214 |
-
},
|
215 |
-
"execution_count": 6,
|
216 |
-
"metadata": {},
|
217 |
-
"output_type": "execute_result"
|
218 |
-
}
|
219 |
-
],
|
220 |
-
"source": [
|
221 |
-
"g.toggle_physics(False)\n",
|
222 |
-
"g.show(\"example.html\")"
|
223 |
-
]
|
224 |
-
},
|
225 |
-
{
|
226 |
-
"cell_type": "markdown",
|
227 |
-
"metadata": {},
|
228 |
-
"source": [
|
229 |
-
"### Explicit coordinates to layout nodes"
|
230 |
-
]
|
231 |
-
},
|
232 |
-
{
|
233 |
-
"cell_type": "code",
|
234 |
-
"execution_count": 7,
|
235 |
-
"metadata": {},
|
236 |
-
"outputs": [
|
237 |
-
{
|
238 |
-
"data": {
|
239 |
-
"text/html": [
|
240 |
-
"\n",
|
241 |
-
" <iframe\n",
|
242 |
-
" width=\"500px\"\n",
|
243 |
-
" height=\"500px\"\n",
|
244 |
-
" src=\"example.html\"\n",
|
245 |
-
" frameborder=\"0\"\n",
|
246 |
-
" allowfullscreen\n",
|
247 |
-
" \n",
|
248 |
-
" ></iframe>\n",
|
249 |
-
" "
|
250 |
-
],
|
251 |
-
"text/plain": [
|
252 |
-
"<IPython.lib.display.IFrame at 0x7f87dc679b50>"
|
253 |
-
]
|
254 |
-
},
|
255 |
-
"execution_count": 7,
|
256 |
-
"metadata": {},
|
257 |
-
"output_type": "execute_result"
|
258 |
-
}
|
259 |
-
],
|
260 |
-
"source": [
|
261 |
-
"g = Network(notebook=True)\n",
|
262 |
-
"g.add_nodes([1,2,3],\n",
|
263 |
-
" value=[10, 100, 400],\n",
|
264 |
-
" title=[\"I am node 1\", \"node 2 here\", \"and im node 3\"],\n",
|
265 |
-
" x=[21.4, 21.4, 21.4], y=[100.2, 223.54, 32.1],\n",
|
266 |
-
" label=[\"NODE 1\", \"NODE 2\", \"NODE 3\"],\n",
|
267 |
-
" color=[\"#00ff1e\", \"#162347\", \"#dd4b39\"])\n",
|
268 |
-
"g.show(\"example.html\")"
|
269 |
-
]
|
270 |
-
},
|
271 |
-
{
|
272 |
-
"cell_type": "markdown",
|
273 |
-
"metadata": {},
|
274 |
-
"source": [
|
275 |
-
"### Full Game of Thrones example"
|
276 |
-
]
|
277 |
-
},
|
278 |
-
{
|
279 |
-
"cell_type": "code",
|
280 |
-
"execution_count": 8,
|
281 |
-
"metadata": {},
|
282 |
-
"outputs": [
|
283 |
-
{
|
284 |
-
"data": {
|
285 |
-
"text/html": [
|
286 |
-
"\n",
|
287 |
-
" <iframe\n",
|
288 |
-
" width=\"100%\"\n",
|
289 |
-
" height=\"750px\"\n",
|
290 |
-
" src=\"example.html\"\n",
|
291 |
-
" frameborder=\"0\"\n",
|
292 |
-
" allowfullscreen\n",
|
293 |
-
" \n",
|
294 |
-
" ></iframe>\n",
|
295 |
-
" "
|
296 |
-
],
|
297 |
-
"text/plain": [
|
298 |
-
"<IPython.lib.display.IFrame at 0x7f87da76e430>"
|
299 |
-
]
|
300 |
-
},
|
301 |
-
"execution_count": 8,
|
302 |
-
"metadata": {},
|
303 |
-
"output_type": "execute_result"
|
304 |
-
}
|
305 |
-
],
|
306 |
-
"source": [
|
307 |
-
"import pandas as pd\n",
|
308 |
-
"\n",
|
309 |
-
"got_net = Network(notebook=True, height=\"750px\", width=\"100%\", bgcolor=\"#222222\", font_color=\"white\")\n",
|
310 |
-
"\n",
|
311 |
-
"# set the physics layout of the network\n",
|
312 |
-
"got_net.barnes_hut()\n",
|
313 |
-
"got_data = pd.read_csv(\"https://www.macalester.edu/~abeverid/data/stormofswords.csv\")\n",
|
314 |
-
"\n",
|
315 |
-
"sources = got_data['Source']\n",
|
316 |
-
"targets = got_data['Target']\n",
|
317 |
-
"weights = got_data['Weight']\n",
|
318 |
-
"\n",
|
319 |
-
"edge_data = zip(sources, targets, weights)\n",
|
320 |
-
"\n",
|
321 |
-
"for e in edge_data:\n",
|
322 |
-
" src = e[0]\n",
|
323 |
-
" dst = e[1]\n",
|
324 |
-
" w = e[2]\n",
|
325 |
-
"\n",
|
326 |
-
" got_net.add_node(src, src, title=src)\n",
|
327 |
-
" got_net.add_node(dst, dst, title=dst)\n",
|
328 |
-
" got_net.add_edge(src, dst, value=w)\n",
|
329 |
-
"\n",
|
330 |
-
"neighbor_map = got_net.get_adj_list()\n",
|
331 |
-
"\n",
|
332 |
-
"# add neighbor data to node hover data\n",
|
333 |
-
"for node in got_net.nodes:\n",
|
334 |
-
" node[\"title\"] += \" Neighbors:<br>\" + \"<br>\".join(neighbor_map[node[\"id\"]])\n",
|
335 |
-
" node[\"value\"] = len(neighbor_map[node[\"id\"]]) # this value attrribute for the node affects node size\n",
|
336 |
-
"\n",
|
337 |
-
"got_net.show(\"example.html\")"
|
338 |
-
]
|
339 |
-
},
|
340 |
-
{
|
341 |
-
"cell_type": "markdown",
|
342 |
-
"metadata": {},
|
343 |
-
"source": [
|
344 |
-
"### Experimenting with options UI\n",
|
345 |
-
"Scroll down underneath the graph to play around with the physics settings to acheive optimal layout and behavior. You can use the generate options button to display the JSON representation of the configuration."
|
346 |
-
]
|
347 |
-
},
|
348 |
-
{
|
349 |
-
"cell_type": "code",
|
350 |
-
"execution_count": 9,
|
351 |
-
"metadata": {},
|
352 |
-
"outputs": [
|
353 |
-
{
|
354 |
-
"data": {
|
355 |
-
"text/html": [
|
356 |
-
"\n",
|
357 |
-
" <iframe\n",
|
358 |
-
" width=\"100%\"\n",
|
359 |
-
" height=\"750px\"\n",
|
360 |
-
" src=\"example.html\"\n",
|
361 |
-
" frameborder=\"0\"\n",
|
362 |
-
" allowfullscreen\n",
|
363 |
-
" \n",
|
364 |
-
" ></iframe>\n",
|
365 |
-
" "
|
366 |
-
],
|
367 |
-
"text/plain": [
|
368 |
-
"<IPython.lib.display.IFrame at 0x7f87da76ee50>"
|
369 |
-
]
|
370 |
-
},
|
371 |
-
"execution_count": 9,
|
372 |
-
"metadata": {},
|
373 |
-
"output_type": "execute_result"
|
374 |
-
}
|
375 |
-
],
|
376 |
-
"source": [
|
377 |
-
"got_net.show_buttons(filter_=\"physics\")\n",
|
378 |
-
"got_net.show(\"example.html\")"
|
379 |
-
]
|
380 |
-
},
|
381 |
-
{
|
382 |
-
"cell_type": "code",
|
383 |
-
"execution_count": 13,
|
384 |
-
"metadata": {},
|
385 |
-
"outputs": [],
|
386 |
-
"source": [
|
387 |
-
"got_net.set_options('''var options = {\n",
|
388 |
-
" \"physics\": {\n",
|
389 |
-
" \"barnesHut\": {\n",
|
390 |
-
" \"gravitationalConstant\": -80000,\n",
|
391 |
-
" \"springLength\": 250,\n",
|
392 |
-
" \"springConstant\": 0.001\n",
|
393 |
-
" },\n",
|
394 |
-
" \"maxVelocity\": 34,\n",
|
395 |
-
" \"minVelocity\": 0.75\n",
|
396 |
-
" }\n",
|
397 |
-
"}''')"
|
398 |
-
]
|
399 |
-
},
|
400 |
-
{
|
401 |
-
"cell_type": "code",
|
402 |
-
"execution_count": 10,
|
403 |
-
"metadata": {},
|
404 |
-
"outputs": [],
|
405 |
-
"source": [
|
406 |
-
"import networkx as nx"
|
407 |
-
]
|
408 |
-
},
|
409 |
-
{
|
410 |
-
"cell_type": "code",
|
411 |
-
"execution_count": 11,
|
412 |
-
"metadata": {},
|
413 |
-
"outputs": [
|
414 |
-
{
|
415 |
-
"data": {
|
416 |
-
"text/html": [
|
417 |
-
"\n",
|
418 |
-
" <iframe\n",
|
419 |
-
" width=\"100%\"\n",
|
420 |
-
" height=\"750px\"\n",
|
421 |
-
" src=\"nx.html\"\n",
|
422 |
-
" frameborder=\"0\"\n",
|
423 |
-
" allowfullscreen\n",
|
424 |
-
" \n",
|
425 |
-
" ></iframe>\n",
|
426 |
-
" "
|
427 |
-
],
|
428 |
-
"text/plain": [
|
429 |
-
"<IPython.lib.display.IFrame at 0x7f88443e75b0>"
|
430 |
-
]
|
431 |
-
},
|
432 |
-
"execution_count": 11,
|
433 |
-
"metadata": {},
|
434 |
-
"output_type": "execute_result"
|
435 |
-
}
|
436 |
-
],
|
437 |
-
"source": [
|
438 |
-
"nx_graph = nx.cycle_graph(10)\n",
|
439 |
-
"nx_graph.nodes[1]['title'] = 'Number 1'\n",
|
440 |
-
"nx_graph.nodes[1]['group'] = 1\n",
|
441 |
-
"nx_graph.nodes[3]['title'] = 'I belong to a different group!'\n",
|
442 |
-
"nx_graph.nodes[3]['group'] = 10\n",
|
443 |
-
"nx_graph.add_node(20, size=20, title='couple', group=2)\n",
|
444 |
-
"nx_graph.add_node(21, size=15, title='couple', group=2)\n",
|
445 |
-
"nx_graph.add_edge(20, 21, weight=5)\n",
|
446 |
-
"nx_graph.add_node(25, size=25, label='lonely', title='lonely node', group=3)\n",
|
447 |
-
"\n",
|
448 |
-
"nt = Network(notebook=True, height=\"750px\", width=\"100%\")\n",
|
449 |
-
"\n",
|
450 |
-
"nt.from_nx(nx_graph)\n",
|
451 |
-
"nt.show(\"nx.html\")"
|
452 |
-
]
|
453 |
-
},
|
454 |
-
{
|
455 |
-
"cell_type": "code",
|
456 |
-
"execution_count": null,
|
457 |
-
"metadata": {},
|
458 |
-
"outputs": [],
|
459 |
-
"source": []
|
460 |
-
}
|
461 |
-
],
|
462 |
-
"metadata": {
|
463 |
-
"kernelspec": {
|
464 |
-
"display_name": "Python 3",
|
465 |
-
"language": "python",
|
466 |
-
"name": "python3"
|
467 |
-
},
|
468 |
-
"language_info": {
|
469 |
-
"codemirror_mode": {
|
470 |
-
"name": "ipython",
|
471 |
-
"version": 3
|
472 |
-
},
|
473 |
-
"file_extension": ".py",
|
474 |
-
"mimetype": "text/x-python",
|
475 |
-
"name": "python",
|
476 |
-
"nbconvert_exporter": "python",
|
477 |
-
"pygments_lexer": "ipython3",
|
478 |
-
"version": "3.8.10"
|
479 |
-
}
|
480 |
-
},
|
481 |
-
"nbformat": 4,
|
482 |
-
"nbformat_minor": 2
|
483 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyvis/notebooks/test.dot
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
digraph {
|
2 |
-
a [label=12, entity_id=12, entity_class="truck"];
|
3 |
-
b [label=7, entity_id=7,entity_class="bike"];
|
4 |
-
c [label=3, entity_id=3, entity_class="car"];
|
5 |
-
a -> b[label="solid edge"];
|
6 |
-
a -> b [label="dashed edge", style=dashed];
|
7 |
-
a -> c [label="dashed edge", style=dashed];
|
8 |
-
a -> c [label="dotted edge", style=dotted];
|
9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|