Basic use example of visJS_2_jupyter


Authors: Brin Rosenthal ([email protected]), Mikayla Webster ([email protected])


Import packages

In [1]:
import matplotlib as mpl
import matplotlib.pyplot as plt

import networkx as nx
import numpy as np
import pandas as pd

import sys
sys.path.append('../src/')
import visJS_module

import imp
imp.reload(visJS_module)
Out[1]:
<module 'visJS_module' from '../src/visJS_module.pyc'>

Draw a simple network with default parameters

In [4]:
G = nx.connected_watts_strogatz_graph(30,5,.2)
nodes = G.nodes()
edges = G.edges()
In [5]:
nodes_dict = [{"id":n} for n in nodes]
node_map = dict(zip(nodes,range(len(nodes))))  # map to indices for source/target in edges

edges_dict = [{"source":node_map[edges[i][0]], "target":node_map[edges[i][1]], 
              "title":'test'} for i in range(len(edges))]

visJS_module.visjs_network(nodes_dict,edges_dict,time_stamp=0)
Out[5]:
Network | Basic usage
In [ ]: