Creating a graph overlap using visualizations module

Author: Julia Len ([email protected])


Import packages

In [1]:
import matplotlib as mpl
import networkx as nx
import visJS2jupyter.visualizations as visualizations
import imp
imp.reload(visualizations)
Out[1]:
<module 'visJS2jupyter.visualizations' from '/Users/Julia/anaconda/lib/python2.7/site-packages/visJS2jupyter/visualizations.pyc'>


Create two networks and graph their overlap

In [2]:
G1 = nx.connected_watts_strogatz_graph(10,5,.1)
G2 = nx.connected_watts_strogatz_graph(10,5,.1)
old_nodes = range(5)
new_nodes = range(10,15)
new_node_labels = dict(zip(old_nodes,new_nodes))
G2 = nx.relabel_nodes(G2,new_node_labels)
visualizations.draw_graph_overlap(G1,G2,edge_width=2)
Out[2]:
Network | Basic usage