Investigate PageRank in a DAG
In [6]:
import igraph as ig
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from math import *
%load_ext autoreload
%autoreload 2
%matplotlib inline
In [45]:
N = int(1e5)
M = 1
# uniform attachment
ua = ig.Graph.Growing_Random(n=N, m=M,
directed=True, citation=True)
# preferential attachment
pa = ig.Graph.Barabasi(n=N, m=M,
directed=True)
In [49]:
plt.figure(figsize=[20, 10])
plt.subplot(1, 2, 1)
indegrees_u = ua.indegree()
plt.scatter(range(N), indegrees_u,
marker='.',
color='black')
plt.xlabel('node age')
plt.ylabel('in degree')
plt.xlim([0, N])
plt.ylim([0, max(indegrees_u)])
plt.title('uniform attachment')
plt.subplot(1, 2, 2)
indegrees_p = pa.indegree()
plt.scatter(range(N), indegrees_p,
marker='.',
color='black')
plt.xlabel('node age')
plt.ylabel('in degree')
plt.xlim([0, N])
plt.ylim([0, max(indegrees_p)])
plt.title('preferential attachment')
Out[49]:
In [57]:
plt.figure(figsize=[20, 10])
# uniforma ttachment
plt.subplot(1, 2, 1)
pageranks_u = ua.pagerank()
plt.scatter(range(N), [log(v) for v in pageranks_u],
marker='.',
color='black')
plt.xlabel('node age')
plt.ylabel('log PageRank')
plt.xlim([0, N])
# plt.ylim([0, max(pageranks_u)])
# plt.ylim([0, .0003])
plt.title('uniform attachment')
# preferential attachment
plt.subplot(1, 2, 2)
pageranks_p = pa.pagerank()
plt.scatter(range(N), [log(v) for v in pageranks_p],
marker='.',
color='black')
plt.xlabel('node age')
plt.ylabel('log PageRank')
plt.xlim([0, N])
# plt.ylim([0, max(pageranks_p)])
# plt.ylim([0, .0003])
plt.title('preferential attachment')
Out[57]:
In [ ]: