##// END OF EJS Templates
Merge pull request #8679 from ndunn219/patch-1...
Merge pull request #8679 from ndunn219/patch-1 Update JavaScript Notebook Extensions.ipynb

File last commit:

r20541:1e566dcc
r21560:db1266a5 merge
Show More
Exploring Graphs.ipynb
117 lines | 2.6 KiB | text/plain | TextLexer
Brian E. Granger
Refactoring interact examples.
r16092 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "cells": [
Brian E. Granger
Refactoring interact examples.
r16092 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "cell_type": "markdown",
"metadata": {},
"source": [
"## Explore Random Graphs Using NetworkX"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example, we build a simple UI for exploring random graphs with [NetworkX](http://networkx.github.io/)."
]
},
{
"cell_type": "code",
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "execution_count": null,
Min RK
upate exmaple notebooks to nbformat v4
r18669 "metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from IPython.html.widgets import interact"
]
},
{
"cell_type": "code",
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "execution_count": null,
Min RK
upate exmaple notebooks to nbformat v4
r18669 "metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "execution_count": null,
Min RK
upate exmaple notebooks to nbformat v4
r18669 "metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import networkx as nx"
]
},
{
"cell_type": "code",
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "execution_count": null,
Min RK
upate exmaple notebooks to nbformat v4
r18669 "metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# wrap a few graph generation functions so they have the same signature\n",
"\n",
"def random_lobster(n, m, k, p):\n",
" return nx.random_lobster(n, p, p / m)\n",
"\n",
"def powerlaw_cluster(n, m, k, p):\n",
" return nx.powerlaw_cluster_graph(n, m, p)\n",
"\n",
"def erdos_renyi(n, m, k, p):\n",
" return nx.erdos_renyi_graph(n, p)\n",
"\n",
"def newman_watts_strogatz(n, m, k, p):\n",
" return nx.newman_watts_strogatz_graph(n, k, p)\n",
"\n",
"def plot_random_graph(n, m, k, p, generator):\n",
" g = generator(n, m, k, p)\n",
" nx.draw(g)\n",
" plt.show()"
]
},
{
"cell_type": "code",
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "execution_count": null,
Min RK
upate exmaple notebooks to nbformat v4
r18669 "metadata": {
"collapsed": false
},
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "outputs": [],
Min RK
upate exmaple notebooks to nbformat v4
r18669 "source": [
"interact(plot_random_graph, n=(2,30), m=(1,10), k=(1,10), p=(0.0, 1.0, 0.001),\n",
" generator={'lobster': random_lobster,\n",
" 'power law': powerlaw_cluster,\n",
" 'Newman-Watts-Strogatz': newman_watts_strogatz,\n",
Min RK
add kernel metadata to example notebooks
r20278 " u'Erdős-Rényi': erdos_renyi,\n",
Min RK
upate exmaple notebooks to nbformat v4
r18669 " });"
]
Brian E. Granger
Refactoring interact examples.
r16092 }
Min RK
upate exmaple notebooks to nbformat v4
r18669 ],
Min RK
add kernel metadata to example notebooks
r20278 "metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "version": "3.4.0"
Min RK
add kernel metadata to example notebooks
r20278 }
},
Min RK
upate exmaple notebooks to nbformat v4
r18669 "nbformat": 4,
"nbformat_minor": 0
Min RK
add kernel metadata to example notebooks
r20278 }