################################################################## # 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) for re in range(nrealiz): # Generate a randomly rewired graph (conserving the degrees) rewnet = RewireNetwork(net, prewire, directed=False) # Compute the rich club of the rewired graph rewrcdens[re] = RichClub(rewnet, rctype='undirected') # Find the average rich-club and deviation for each k value maxrewphi = rewrcdens.max(axis=0)
from os.path import join from numpy import * import matplotlib.pyplot as plt #from gatools import* from galib import RichClub from gamodels import RewireNetwork # 0) READ THE DATA datapath = '/yourpath/GAlib/Data/' net = loadtxt(join(datapath, 'Cat53_cortex.txt'), uint8) N = len(net) # 1) COMPUTE THE RICH-CLUB OF THE NETWORK # 1.1) RichClub of the input degrees inphi = RichClub(net, weightednet=True, rctype='indegree') outphi = RichClub(net, weightednet=True, rctype='outdegree') avphi = RichClub(net, weightednet=True, rctype='average') # 2) COMPUTE THE RICH-CLUB IN AN ENSEMBLE OF REWIRED NETWORKS FOR COMPARISON nrealiz = 5 prewire = 10 inkmax = len(inphi) inrewphi = zeros((nrealiz, inkmax), float) outkmax = len(outphi) outrewphi = zeros((nrealiz, outkmax), float) avkmax = len(avphi) avrewphi = zeros((nrealiz, avkmax), float) for re in xrange(nrealiz): # 2.1) Rewire the network rewnet = RewireNetwork(net, prewire, directed=True)
from galib import RichClub import galib.models 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 + 'Cat53_cortex.txt', dtype=uint8) N = len(net) # 1) COMPUTE THE RICH-CLUB OF THE NETWORKS # 1.1) Empirical network. Three different cases: input, output & average degrees # Notice that 'net' is weighted but function RichClub ignores the weights. inphi = RichClub(net, rctype='indegree') outphi = RichClub(net, rctype='outdegree') avphi = RichClub(net, rctype='average') # 1.2) Rich-club in an ensemble of rewired networks for comparison nrealiz = 100 prewire = 10 inkmax = len(inphi) rewphi_in = zeros((nrealiz, inkmax), float) outkmax = len(outphi) rewphi_out = zeros((nrealiz, outkmax), float) avkmax = len(avphi) rewphi_av = zeros((nrealiz, avkmax), float) for re in range(nrealiz): # Generate a randomly rewired graph (conserving the in-/out-degrees) rewnet = RewireNetwork(net, prewire, directed=True)
from os.path import join from numpy import * import matplotlib.pyplot as plt #from gatools import* from galib import RichClub from gamodels import RewireNetwork # 0) READ THE DATA datapath = '/yourpath/GAlib/Data/' net = loadtxt(join(datapath, 'Zachary.txt'), uint8) N = len(net) # 1) COMPUTE THE RICH-CLUB OF THE NETWORK # 1.1) RichClub of the input degrees phidens = RichClub(net, weightednet=True, rctype='undirected') # 2) COMPUTE THE RICH-CLUB IN AN ENSEMBLE OF REWIRED NETWORKS FOR COMPARISON nrealiz = 100 prewire = 10 kmax = len(phidens) rewphidens = zeros((nrealiz, kmax), float) for re in xrange(nrealiz): # 2.1) Rewire the network rewnet = RewireNetwork(net, prewire, directed=False) # 2.2) Compute the rich club of the rewired network rewphidens[re] = RichClub(rewnet, rctype='undirected') # 2.3) Find the average rich-club and deviation for each k value meanrewphi = rewphidens.mean(axis=0)