import os, os.path from timeit import default_timer as timer # Third party imports import matplotlib.pyplot as plt from numpy import* # Personal libraries from galib.tools import LoadFromPajek from galib.models import RandomGraph from galib.models_numba import RandomGraph_Numba ################################################################## # 0) READ THE DATA currdir = os.getcwd() currdir = os.path.split(currdir)[0] dataroot = os.path.join(currdir, 'Data/') net, labs = LoadFromPajek(dataroot + 'Cat53_cortex.net', True) netsym = 0.5*(net+net.T) N = len(net) # Define the partition visual = arange(16) audit = arange(16,23) somatomotor = arange(23,39) frontolimbic = arange(39, 53) partition = [visual,audit,somatomotor,frontolimbic] ncoms = len(partition) time1 = timer() N = 5000 # # 1) RING MODELS # latt = Lattice1D(N,5)
# Third party imports import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt from numpy import * # Personal libraries from galib import RichClub from galib.models import RewireNetwork from galib.tools import SymmetriseMatrix, LoadFromPajek ################################################################## # 0) READ THE DATA currdir = os.getcwd() dataroot = os.path.join(currdir, 'Data/') net = loadtxt(dataroot + 'Zachary.txt', dtype=uint8) net = LoadFromPajek(dataroot + 'Dolphins.net', getlabels=False) net, labels = LoadFromPajek(dataroot + 'LesMiserables.net', getlabels=True) # net = loadtxt(dataroot + 'Cat53_cortex.txt', dtype=uint8) # net = SymmetriseMatrix(net) N = len(net) # 1) COMPUTE THE RICH-CLUB OF THE NETWORKS # 1.1) Rich-club of the empirical network. # Notice that 'net' is weighted but function RichClub ignores the weights. rcdens = RichClub(net, rctype='undirected') # 1.2) Rich-club in an ensemble of rewired networks for comparison nrealiz = 100 prewire = 10 kmax = len(rcdens) rewrcdens = zeros((nrealiz, kmax), float)
matplotlib.use('TkAgg') import matplotlib.pyplot as plt from numpy import * # Personal libraries from galib import RichClub from galib.models import RewireNetwork from galib.tools import LoadFromPajek, Save2Pajek, LoadLabels, SaveLabels ################################################################## # 1) READ SOME DATA IN PAJEK FORMAT AND SAVE THE ADJACENCY MATRIX currdir = os.getcwd() dataroot = os.path.join(currdir, 'Data/') # 1.1) Read the data splitting the adjacency matrix and the labels fname = 'LesMiserables.net' net, labels = LoadFromPajek(dataroot + fname, getlabels=True) # 1.2) Save the adjacency matrix as a text file # Give '%d' formatter for integer data, '%f' for real valued data outfname1 = 'spam_LesMiserables.txt' savetxt(dataroot + outfname1, net, fmt='%d') # 1.3) Save the adjacency matrix in a numpy binary file outfname2 = 'spam_LesMiserables.npy' save(dataroot + outfname2, net) # 1.4) Save the labels in an independent text file outfname3 = 'spam_LesMiserables_labels.txt' SaveLabels(dataroot + outfname3, labels) # 2) READ AN ADJACENCY MATRIX AND SAVE IT AS PAJEK FORMAT