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')


Lightning initialized
Running local mode, some functionality limited.


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)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-29-0cc0f9eef7ea> in <module>()
----> 1 d, l = datasets.make_blobs(n_features=5, n_samples=50, centers=5, cluster_std=2.0, random_state=100)
      2 c = corrcoef(d)
      3 c[c<0.9] = 0
      4 lgn.force(c, label=l)

NameError: name 'datasets' is not defined

In [24]:
l


Out[24]:
array([1, 0, 1, 1, 2, 0, 0, 0, 3, 3, 1, 2, 3, 4, 1, 1, 3, 1, 3, 4, 1, 0, 1,
       1, 3, 2, 2, 0, 4, 1, 4, 3, 4, 4, 1, 0, 3, 1, 3, 4, 3, 2, 2, 2, 1, 1,
       0, 3, 1, 4, 2, 4, 0, 4, 1, 2, 1, 0, 0, 1, 0, 4, 3, 0, 3, 0, 3, 3, 4,
       4, 0, 3, 3, 3, 2, 3, 4, 4, 0, 3, 3, 3, 0, 1, 4, 3, 2, 3, 2, 1, 4, 4,
       2, 0, 3, 4, 4, 1, 2, 0])