In [1]:
from IPython.html import widgets
from IPython.display import display
from d3networkx import ForceDirectedGraph, EventfulGraph, empty_eventfulgraph_hook


:0: FutureWarning: IPython widgets are experimental and may change in the future.

Hook into the random_graphs NetworkX code.


In [2]:
from networkx.generators import random_graphs
from networkx.generators import classic

# Add a listener to the eventful graph's construction method.
# If an eventful graph is created, build and show a widget
# for the graph.
def handle_graph(graph):
    print(graph.graph._sleep)
    graph_widget = ForceDirectedGraph(graph)
    display(graph_widget)
EventfulGraph.on_constructed(handle_graph)

# Replace the empty graph of the networkx classic module with
# the eventful graph type.
random_graphs.empty_graph = empty_eventfulgraph_hook(sleep=0.2)

Barabasi Albert


In [3]:
random_graphs.barabasi_albert_graph(15, 1)


0.2
Out[3]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c80cadd0>

In [4]:
random_graphs.barabasi_albert_graph(15, 2)


0.2
Out[4]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c807a1d0>

In [5]:
random_graphs.barabasi_albert_graph(10, 5)


0.2
Out[5]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c807a350>

Newman Watts Strogatz


In [6]:
random_graphs.newman_watts_strogatz_graph(15, 3, 0.25)


0.2
Out[6]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c807a610>

Barbell


In [7]:
classic.barbell_graph(5,0,create_using=EventfulGraph(sleep=0.1))


0.1
Out[7]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c807a8d0>

Circular Ladder


In [8]:
classic.circular_ladder_graph(5,create_using=EventfulGraph(sleep=0.1))


0.1
Out[8]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c807a750>

In [9]:
classic.circular_ladder_graph(10,create_using=EventfulGraph(sleep=0.1))


0.1
Out[9]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c807abd0>

Ladder


In [10]:
classic.ladder_graph(10,create_using=EventfulGraph(sleep=0.1))


0.1
Out[10]:
<d3networkx.eventful_graph.EventfulGraph at 0x7f56c807ae50>

Star


In [ ]:
classic.star_graph(10,create_using=EventfulGraph(sleep=0.1))