コード例 #1
0
    def test_all_random_graphs_yield_correct_number_of_nodes_and_edges(self):

        G, A, D = random_graph.target_attraction(N=426, N_edges=2000)
        self.assertEqual(len(G.nodes()), 426)
        self.assertEqual(len(G.edges()), 2000)

        G, A, D = random_graph.source_growth(N=426, N_edges=2000)
        self.assertEqual(len(G.nodes()), 426)
        self.assertEqual(len(G.edges()), 2000)
コード例 #2
0
    def test_all_random_graphs_yield_correct_number_of_nodes_and_edges(self):

        G, A, D = random_graph.target_attraction(N=426, N_edges=2000)
        self.assertEqual(len(G.nodes()), 426)
        self.assertEqual(len(G.edges()), 2000)

        G, A, D = random_graph.source_growth(N=426, N_edges=2000)
        self.assertEqual(len(G.nodes()), 426)
        self.assertEqual(len(G.edges()), 2000)
コード例 #3
0
    print('Making example models...')
    g_sg_l_inf, a_sg_l_inf, d_sg_l_inf = source_growth(
        N=bc.num_brain_nodes,
        N_edges=bc.num_brain_edges_directed,
        L=np.inf,
        gamma=1,
        brain_size=BRAIN_SIZE)
    g_sg_l_0725, a_sg_l_0725, d_sg_l_0725 = source_growth(
        N=bc.num_brain_nodes,
        N_edges=bc.num_brain_edges_directed,
        L=L,
        gamma=1,
        brain_size=BRAIN_SIZE)
    g_ta_l_inf, a_ta_l_inf, d_ta_l_inf = target_attraction(
        N=bc.num_brain_nodes,
        N_edges=bc.num_brain_edges_directed,
        L=np.inf,
        gamma=1,
        brain_size=BRAIN_SIZE)
    g_ta_l_0725, a_ta_l_0725, d_ta_l_0725 = target_attraction(
        N=bc.num_brain_nodes,
        N_edges=bc.num_brain_edges_directed,
        L=L,
        gamma=1,
        brain_size=BRAIN_SIZE)

    # make graphs and calculate and save reciprocities if not done yet
    if not os.path.isfile(RECIPROCITY_FILE_NAME):
        print('Looping through construction of models for reciprocity...')
        algos = {'sg': source_growth, 'ta': target_attraction}

        rs = {'LS': LS}
コード例 #4
0
ファイル: fig5_ab.py プロジェクト: neofunkatron/neofunkatron
import in_out_plot_config as cf

MARKERSIZE = 25.
FONTSIZE = 12.
ALPHA = 0.5

L = 0.725
BRAIN_SIZE = [7., 7., 7.]

######################################
# Create graphs and calculate metrics
######################################

# create attachment and growth models
G_attachment = target_attraction(N=bc.num_brain_nodes,
                                 N_edges=bc.num_brain_edges_directed, L=L,
                                 gamma=1., brain_size=BRAIN_SIZE)[0]

G_growth = source_growth(N=bc.num_brain_nodes,
                         N_edges=bc.num_brain_edges_directed, L=L, gamma=1.,
                         brain_size=BRAIN_SIZE)[0]

# Get in- & out-degree
indeg_attachment = np.array([G_attachment.in_degree()[node]
                             for node in G_attachment])
outdeg_attachment = np.array([G_attachment.out_degree()[node]
                              for node in G_attachment])
deg_attachment = indeg_attachment + outdeg_attachment

indeg_growth = np.array([G_growth.in_degree()[node] for node in G_growth])
outdeg_growth = np.array([G_growth.out_degree()[node] for node in G_growth])
コード例 #5
0
import config
import in_out_plot_config as cf

MARKERSIZE = 25.
FONTSIZE = 13.
ALPHA = 0.5

L = np.inf
BRAIN_SIZE = [7., 7., 7.]

# create attachment and growth models
Gattachment, _, _ = target_attraction(
    N=bc.num_brain_nodes,
    N_edges=bc.num_brain_edges_directed,
    L=L,
    gamma=1.,
    brain_size=BRAIN_SIZE,
)

Ggrowth, _, _ = source_growth(
    N=bc.num_brain_nodes,
    N_edges=bc.num_brain_edges_directed,
    L=L,
    gamma=1.,
    brain_size=BRAIN_SIZE,
)

# Get in- & out-degree
indeg_attachment = np.array(
    [Gattachment.in_degree()[node] for node in Gattachment])
コード例 #6
0
ファイル: fig5_cde.py プロジェクト: neofunkatron/neofunkatron
    g_brain, a_brain, labels = brain_graph.binary_directed()
    brain_in_deg = g_brain.in_degree().values()
    brain_out_deg = g_brain.out_degree().values()
    # load distance matrix
    d_brain = load_brain_dist_matrix(labels, in_mm=True)

    # make two SG graphs and two TA graphs (each one with either L=0.725 or 0)
    print('Making example models...')
    g_sg_l_inf, a_sg_l_inf, d_sg_l_inf = source_growth(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=np.inf,
        gamma=1, brain_size=BRAIN_SIZE)
    g_sg_l_0725, a_sg_l_0725, d_sg_l_0725 = source_growth(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=L,
        gamma=1, brain_size=BRAIN_SIZE)
    g_ta_l_inf, a_ta_l_inf, d_ta_l_inf = target_attraction(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=np.inf,
        gamma=1, brain_size=BRAIN_SIZE)
    g_ta_l_0725, a_ta_l_0725, d_ta_l_0725 = target_attraction(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=L,
        gamma=1, brain_size=BRAIN_SIZE)

    # make graphs and calculate and save reciprocities if not done yet
    if not os.path.isfile(RECIPROCITY_FILE_NAME):
        print('Looping through construction of models for reciprocity...')
        algos = {'sg': source_growth, 'ta': target_attraction}

        rs = {'LS': LS}

        for key, algo in algos.items():
            print(key)
            rs[key] = np.nan * np.zeros((len(LS), N_REPEATS), dtype=float)