In [1]:
import cPickle as pickle
import numpy as np
import pandas as pd
import h5py
import matplotlib.pyplot as plt
import CAM_NWB as cn
%matplotlib inline
In [15]:
from lightning import Lightning
lgn = Lightning(ipython=True, local=True, host='http://localhost:3000')
In [16]:
import os
from numpy import random, asarray, argmin
from colorsys import hsv_to_rgb
import networkx as nx
from pylab import cm as cm
import matplotlib
from numpy import asarray, argmin
import networkx as nx
#lgn.create_session('graph-ipython');
In [ ]:
#format for lightning graph: export this from the fwMatch code on Yeti:
#a = {
# "nodes": [[x0,y0], [], ...]
# "links": [[source0, target0, value0], [], ..]
# "color": [[r0,g0,b0], [], ...]
# "label": [l0, l1, ...]
# "size": [s0,s1,...]
#}
In [4]:
G = nx.random_geometric_graph(50, 0.5)
pos = asarray(nx.get_node_attributes(G, 'pos').values())
dists = [(x - 0.5)**2 + (y - 0.5)**2 for x, y in pos]
mat = nx.adjacency_matrix(G).todense()
In [18]:
G = nx.random_geometric_graph(100, 0.2)
pos = asarray(nx.get_node_attributes(G, 'pos').values())
dists = [(x - 0.5)**2 + (y - 0.5)**2 for x, y in pos]
center = argmin(dists)
p = nx.single_source_shortest_path_length(G, center)
xy = asarray([pos[i,:] for i in p.keys()])
mat = nx.adjacency_matrix(G).todense()
l = p.values()
lgn.graph(xy[:,0], xy[:,1], mat, labels=l)
#plt.show()
Out[18]:
In [29]:
d, l = datasets.make_blobs(n_features=5, n_samples=50, centers=5, cluster_std=2.0, random_state=100)
c = corrcoef(d)
c[c<0.9] = 0
lgn.force(c, label=l)
In [24]:
l
Out[24]: