Skip to content

Commit

Permalink
updated example notebooks. Updated network.py to handle how the .show…
Browse files Browse the repository at this point in the history
… is handled when dealing with notebook generation.
  • Loading branch information
BerserkerGaruk committed Feb 6, 2023
1 parent d128b7a commit c40cd82
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 231 deletions.
36 changes: 28 additions & 8 deletions notebooks/example.html

Large diffs are not rendered by default.

217 changes: 28 additions & 189 deletions notebooks/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,29 @@
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"example.html\n"
]
},
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"example.html\"\n",
" src=\"/home/mpscherer/pyvis/pyvis/notebooks/example.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fa0101b2df0>"
"<IPython.lib.display.IFrame at 0x7f384c2d7d00>"
]
},
"execution_count": 2,
Expand All @@ -48,7 +55,7 @@
}
],
"source": [
"g = Network(notebook=True, cdn_resources='remote')\n",
"g = Network(notebook=True, cdn_resources='in_line')\n",
"g.add_nodes(range(5))\n",
"g.add_edges([\n",
" (0, 2),\n",
Expand All @@ -74,44 +81,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Local cdn resources have problems on chrome/safari when used in jupyter-notebook. \n"
]
},
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"dot.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fa010734070>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"h = Network(notebook=True)\n",
"h.from_DOT(\"test.dot\")\n",
Expand Down Expand Up @@ -161,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
Expand All @@ -174,37 +151,14 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"example2.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fa0107346a0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"nxg = nx.random_tree(20)\n",
"g.from_nx(nxg)\n",
Expand All @@ -224,36 +178,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"example3.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fa0107396a0>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"g.toggle_physics(False)\n",
"g.show(\"example3.html\")"
Expand All @@ -272,36 +203,13 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"example4.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fa01072aa90>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"g = Network(notebook=True,cdn_resources='remote')\n",
"g.add_nodes([1,2,3],\n",
Expand Down Expand Up @@ -334,37 +242,14 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"750px\"\n",
" src=\"example5.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7f9fbe548250>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
Expand Down Expand Up @@ -414,44 +299,21 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"750px\"\n",
" src=\"example6.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7f9fc04ca190>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"got_net.show_buttons(filter_=\"physics\")\n",
"got_net.show(\"example6.html\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
Expand Down Expand Up @@ -486,7 +348,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
Expand All @@ -499,36 +361,13 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"750px\"\n",
" src=\"nx.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7f9fc05ca4c0>"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"nx_graph = nx.cycle_graph(10)\n",
"nx_graph.nodes[1]['title'] = 'Number 1'\n",
Expand All @@ -548,7 +387,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
Expand Down
40 changes: 30 additions & 10 deletions notebooks/example2.html

Large diffs are not rendered by default.

40 changes: 30 additions & 10 deletions notebooks/example3.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion notebooks/example5.html

Large diffs are not rendered by default.

Loading

0 comments on commit c40cd82

Please sign in to comment.