In [1]:
%load_ext autoreload
%autoreload 2

Generate example graph


In [3]:
import networkx as nx
g = nx.generators.newman_watts_strogatz_graph(500, 2, 0.3)

In [9]:
import ipygraphwidgets.sigma_graph as gw

In [2]:
%%javascript

$.getScript('/nbextensions/sigmajs/sigma.min.js', function() {console.log('sigma.min.js')})
$.getScript('/nbextensions/sigmajs/sigma.layout.forceAtlas2.min.js', function() {console.log('sigma.layout.forceAtlas2.min.js')})
$.getScript('/nbextensions/sigmajs/sigma.plugins.dragNodes.min.js', function() {console.log('sigma.plugins.dragNodes.min.js')})



In [6]:
from ipywidgets import widgets
from pprint import pprint

In [11]:
w = gw.SigmajsWidget()
w.width = 800
w.height = 400
w.slowdown = 1

def newman_watts_strogatz(n, k, p):
    _g = nx.newman_watts_strogatz_graph(n, k, p)
    w.set_graph(_g)

s = widgets.Latex(description='SelectedNode')

c = widgets.VBox()
c.children= [w,s]
c

In [12]:
widgets.interact(newman_watts_strogatz, n=(20,350), m=(1,10), k=(1,10), p=(0.0, 1.0, 0.001))