# Scaling of degree correlations and its influence on diffusion in scale-free networks

test

Lazaros K. Gallos, Chaoming Song, Hernán A Makse, 2008. Scaling of Degree Correlations and Its Influence on Diffusion in Scale-Free Networks. Physical Review Letters 100(24):248701 Impact Factor: 7.51 DOI: 10.3731/topologica.2.020 [1]

Internet data: The DIMES project Internet As data: http://data.caida.org/datasets/as-relationships/serial-1/

Chaoming, Song. 2011 Self-similarity and Scaling Theory of Complex Networks. Proquest. Google books link

## Joint degree distribution

$P(k_1, k_2)$ denotes the probability of two nodes of degree $k_1$ and $k_2$ are connected to each other. If no degree correlation: $P(k_1, k_2) \sim k_1 P(k_1) k_2 P(k_2)$

For scale free networks：$P(k_1, k_2) \sim k_1 P(k_1) k_2 P(k_2) \sim k_1^{1-\gamma} k_2^{1-\gamma}$

## Density conservation law

$\int P(k_1, k_2) d k_2 = k_1 P(k_1)$

$\int P(k_1, k_2) d k_2 = k_1 P(k_1) \sim k_1^{-(\gamma -1) }$

## 硬猜$P(k_1, k_2)$

The statistical similarity of the corresponding plots suggests the invariance of $P(k_1, k_2)$. Accordingly, this suggests that the $k_1$ and $k_2$ dependence can be separated, and the behavior of the tail of the joint degree distribution is

$P(k_1, k_2) \sim k_1^{-(\gamma -1 )} k_2^{-\epsilon}$ (1)

for completely random networks:

$P(k_1, k_2) \sim k_1 P(k_1) k_2 P(k_2) \sim k_1^{1-\gamma} k_2^{1-\gamma}$ (2)

Using Eq. (1), we can see that:

1. For low-degree nodes ($k_1 > k_2$), integrating over $k_2$, we retrieve the $k^{1-\gamma}$ dependence.
2. For the case of hubs, where integration is over $k_1$, the dependence on the degree is $k^{-\epsilon}$
600px

Maslov, S. & Sneppen, K. 2002. Specificity and stability in topology of protein networks. Science[2]

The protein interaction network is a representative of the broad class of scale-free networks (4–6 ) in which the number of nodes with a given number of neighbors (connectivity) $K$scales as a power law 􏸙 $K^{-\gamma}$􏸖. In our case the histogram of connectivities can be fitted by a power law with 􏸖 􏸡$\gamma = 2.5 \pm 0.3$ for $K$ ranging from 2 to about 100 (7, 8).

1. $\gamma = 2.5 \pm 0.3$
2. $\gamma -1 = 1.5 \pm 0.3$

## $E_b(k)$

$E_b(k) \equiv \frac{\int_{bk}^{\infty} P(k | k') dk'}{ \int_{bk}^{\infty} P( k') dk' } =\frac{ \int_{bk}^{\infty} \frac{P(k, k') }{k' P(k') } dk'} {\int_{bk}^{\infty} P( k') dk'}$

1. 分子是两节点度为k和大于bk的链接比例；
2. 分母是度大于bk的节点的比例

## 计算$E_b(k)$: 算法与代码

• 将链接表达为$（k, k')$的形式
• 使得其中的 $k' > k$
• 选择 $b = 3$
• 计算：
• 对于每一个$（k, k')$， 计算$k' > 3k, k = k$的链接数量$N_{kk'}$
• 计算$P(k, k') = \frac{N_{kk’}}{Number\;of\;edges}$
• 对于每一个度k'， 当$k' > 3k$时, 计算其比例$P(k')$和$k' P(k')$
• 计算$P_1 = \sum \frac{P(k, k')}{k' P(k')}$和$P_2 = \sum P(k')$。
• 计算 $E_b (k) = P_1/P_2 = \sum \frac{P(k, k')}{k' P(k')} / \sum P(k')$
%matplotlib inline
import networkx as nx
import matplotlib.cm as cm
import matplotlib.pyplot as plt
from collections import defaultdict

def ebkk(g, b):
edge_dict = defaultdict(lambda: defaultdict(int))
degree_dict = defaultdict(int)
edge_degree = [sorted(g.degree(e).values()) for e in g.edges()]
for e in edge_degree:
edge_dict[e[0]][e[-1]] +=1
for i in g.degree().values():
degree_dict[i] +=1
edge_number = g.number_of_edges()
node_number = g.number_of_nodes()
ebks, ks = [], []
for k1 in edge_dict:
p1, p2 = 0, 0
for k2 in edge_dict[k1]:
if k2 >= b*k1:
pkk = float(edge_dict[k1][k2])/edge_number
pk2 = float(degree_dict[k2])/node_number
k2pk2 = k2*pk2
p1 += pkk/k2pk2
p2 += pk2
if p2 > 0:
ebks.append(p1/p2)
ks.append(k1)
return ebks, ks

http://snap.stanford.edu/data/ca-CondMat.html
ca = nx.Graph()
with open ('/Users/chengjun/bigdata/ca-CondMat.txt') as f:
for line in f:
if line[0] != '#':
x, y = line.strip().split('\t')
nx.info(ca)

ebk, k = ebkk(ca, b=3)

plt.plot(k,ebk,'r^')
plt.xlabel(r'$k$', fontsize = 16)
plt.ylabel(r'$E_b(k)$', fontsize = 16)
plt.xscale('log')
plt.yscale('log')
plt.show()


def ebw(g, b):
edge_degree = [sorted([g.degree(i), g.degree(j)]) for i, j in g.edges()]
degree_dict = defaultdict(int)
for i in g.degree().values():
degree_dict[i] +=1
node_number = g.number_of_nodes()
edge_number = g.number_of_edges()
ebks, ks, kv = [],[], set(g.degree().values())
for k in kv:
ek, ekk, k_node_num = 0, 0, 0
for k1, k2 in edge_degree:
if k1 == k or k2 == k:
ek +=1
if k1 ==k and k2 >= b*k:
ekk += 1
ebk = float(ekk)/ek
for ki in degree_dict:
if ki>=b*k:
k_node_num += float(degree_dict[ki])
#k_node_num = float(degree_dict[k])
if ebk != 0:
ebks.append(ebk/k_node_num)
ks.append(k)
return ebks, ks

import numpy as np

def log_binning(x, y, bin_count=35):
max_x = np.log10(max(x))
max_y = np.log10(max(y))
max_base = max([max_x,max_y])
xx = [i for i in x if i>0]
min_x = np.log10(np.min(xx))
bins = np.logspace(min_x,max_base,num=bin_count)
bin_means_y = (np.histogram(x,bins,weights=y)[0] / np.histogram(x,bins)[0])
bin_means_x = (np.histogram(x,bins,weights=x)[0] / np.histogram(x,bins)[0])
return bin_means_x,bin_means_y