Example #1
0
    def test_undirected_pure_geometric_graph_yields_right_adjacency_matrix(
            self):

        G, A, D = random_graph_bu.pure_geometric(N=426,
                                                 N_edges=7804,
                                                 L=.75,
                                                 brain_size=[7., 7., 7.])
        self.assertEqual(len(G.nodes()), 426)

        np.testing.assert_array_equal(
            nx.adjacency_matrix(G).todense().astype(int), A.astype(int))
    def test_undirected_pure_geometric_graph_yields_right_adjacency_matrix(self):

        G, A, D = random_graph_bu.pure_geometric(N=426, N_edges=7804, L=.75, brain_size=[7., 7., 7.])
        self.assertEqual(len(G.nodes()), 426)

        np.testing.assert_array_equal(nx.adjacency_matrix(G).todense().astype(int), A.astype(int))
Example #3
0
Gbrain,_,_ = binary_directed()
deg_brain = Gbrain.to_undirected().degree().values()

N = 100

axs[0].hist(deg_brain,deg_bins,facecolor=config.COLORS['brain'], alpha=0.75,normed=True)
leg.append(mlines.Line2D([],[],color=config.COLORS['brain'], linestyle='-',markersize=13,\
                         label='Connectome',lw=3,alpha=0.75))

for i,L in enumerate(Ls):
    print 'L = {}'.format(L)
    degs=[]
    for k in range(N):
        print 'repeat {}'.format(k)
        G,_,_ = pure_geometric(N=bc.num_brain_nodes,N_edges=bc.num_brain_edges_undirected,
                           L=L)
        G_un = G.to_undirected()
        cc_dict = nx.clustering(G_un)
        deg_dict = G_un.degree()
        cc = [cc_dict[k] for k in range(bc.num_brain_nodes)]
        deg = [deg_dict[k] for k in range(bc.num_brain_nodes)]
        degs.extend(deg)

    [slope,intercept,r,_,_] = stats.linregress(deg,cc)
    slopes.append(slope)
    rs.append(r)


    axs[1].scatter(deg,cc,color=cols[i],marker='o',\
                   s=markersize,alpha=alpha,lw=0)