In [21]:
include("../graph.jl")
include("../io.jl")
include("../pr.jl")


Out[21]:
PR (generic function with 5 methods)

In [6]:
@info("loading graph")
core = adjlist(UInt32, is_directed=true)
load_mgs3_graph(core, "../datasets/Arxiv_HEP-PH/Arxiv_HEP-PH_core.mgs")
#load_mgs4_graph(core, "../datasets/Arxiv_HEP-PH/Arxiv_HEP-PH_core.mgz")

# define constants
n = num_vertices(core)
damping = .85
epsilon = 1e-8

# source and target node to be used in the graph
s = convert(UInt32,1)
t = convert(UInt32,100)


Out[6]:
0x00000064

In [11]:
@info("getting rcore")
rcore = get_reverse_graph(core)


┌ Info: getting rcore
└ @ Main In[11]:1
Out[11]:
Directed Graph (12711 vertices, 139981 edges)

In [12]:
@info("computing Pagerank of core and rcore")
@time pr_core = PR(core, rcore, epsilon=epsilon)
#@time pr_rcore = PR(rcore, core, epsilon=epsilon)


┌ Info: computing Pagerank of core and rcore
└ @ Main In[12]:1
┌ Info: computing Pagerank (size of graph 12711)
└ @ Main /home/jimmy/Documents/projects/JCNL/pr.jl:31
 34.390666 seconds (7.20 M allocations: 120.632 MiB, 0.05% gc time)
Out[12]:
12711-element Array{Float64,1}:
 1.2180426083332923e-5 
 5.576958680721473e-5  
 0.0001523018183933433 
 1.881325654228591e-5  
 2.6916039325516338e-5 
 3.021143080036028e-5  
 0.002712795282615076  
 1.7131225142005417e-5 
 0.002050165700823033  
 4.4210978352731306e-5 
 0.0014305859177234886 
 0.0008125784974850691 
 0.00014323071476047894
 ⋮                     
 2.41192412710315e-5   
 1.863458748135917e-5  
 1.2181834342831553e-5 
 1.29865309587917e-5   
 1.4277488989680935e-5 
 1.3850475578385906e-5 
 1.2342431035639167e-5 
 1.4356399707917643e-5 
 1.211041703709851e-5  
 1.3283364288518863e-5 
 1.3274575973293074e-5 
 1.598313331166969e-5  

In [14]:
@info("computing personalized Pageranks for nodes 1 and 100")
@time pr_s = PPR(s, core, rcore, epsilon=epsilon)
#@time pr_t = PPR(t, rcore, core, epsilon=epsilon)


┌ Info: computing personalized Pageranks for nodes 1 and 100
└ @ Main In[14]:1
┌ Info: computing personalized Pagerank (size of graph 12711, source 1)
└ @ Main /home/jimmy/Documents/projects/JCNL/pr.jl:112
 38.855532 seconds (8.23 M allocations: 138.874 MiB, 0.03% gc time)
Out[14]:
12711-element Array{Float64,1}:
 0.15000003731617217   
 0.03886675940776586   
 0.050230378864137455  
 0.025500006346721265  
 0.029835053246013862  
 0.025500045509412397  
 0.017128009924146623  
 0.007225001798238081  
 0.04550645808618301   
 0.013936024708081415  
 0.01852803880126476   
 0.011869258242420914  
 0.01101338748178447   
 ⋮                     
 9.463316603290713e-23 
 2.681298118225403e-23 
 2.0685033052419324e-22
 6.608469564754296e-24 
 7.75077605921725e-21  
 5.388743109387597e-10 
 4.420936212067362e-8  
 6.450921883670794e-19 
 3.603377132829556e-24 
 2.190412794090886e-23 
 2.3470375731396953e-24
 8.29226903090909e-8   

In [13]:
# compute Monte Carlo PR
niter = 100
@info("compute Pagerank (Monte Carlo)")
@time pr_mc = PR(core, niter)

@info("pr_core <-> pr_mc: ", chebyshev(pr_core, pr_mc))


┌ Info: compute Pagerank (Monte Carlo)
└ @ Main In[13]:3
┌ Info: computing Monte-Carlo Pagerank (size of graph 12711)
└ @ Main /home/jimmy/Documents/projects/JCNL/pr.jl:155
 51.619783 seconds (11.60 M allocations: 180.933 GiB, 10.13% gc time)
┌ Info: pr_core <-> pr_mc: 
│   chebyshev(pr_core, pr_mc) = 5.3649904890323494e-5
└ @ Main In[13]:6

In [7]:
# matrix computation
@info("getting P matrix")
@time P = get_sparse_P_matrix(core)


┌ Info: getting P matrix
└ @ Main In[7]:2
  0.580496 seconds (1.34 M allocations: 77.741 MiB, 3.66% gc time)
Out[7]:
12711×12711 SparseMatrixCSC{Float64,UInt32} with 139981 stored entries:
  [6206 ,     1]  =  0.0285714
  [1    ,     2]  =  0.2
  [4    ,     2]  =  0.333333
  [8    ,     2]  =  1.0
  [6224 ,     2]  =  0.166667
  [7764 ,     2]  =  0.166667
  [7836 ,     2]  =  0.2
  [11502,     2]  =  0.125
  [11641,     2]  =  0.25
  [1    ,     3]  =  0.2
  [5    ,     3]  =  0.5
  [6    ,     3]  =  0.2
  ⋮
  [12700, 12701]  =  0.333333
  [12160, 12702]  =  0.0322581
  [8898 , 12703]  =  0.111111
  [11957, 12704]  =  0.2
  [12160, 12704]  =  0.0322581
  [3574 , 12705]  =  0.166667
  [5377 , 12706]  =  0.05
  [4500 , 12707]  =  0.25
  [6534 , 12708]  =  0.0294118
  [11499, 12709]  =  0.142857
  [11682, 12710]  =  0.142857
  [10413, 12711]  =  0.333333

In [15]:
@info("compute Pagerank (power iteration)")
ppr = zeros(Float64,n)
ppr[s] = 1.
@time pr_pi = PR(P, epsilon=epsilon)

@info("computing personalized Pageranks for node 1 (power iteration)")
@time pr_pi_s = PR(P, ppr=ppr, epsilon=epsilon)

@info("pr_core <-> pr_pi: ", chebyshev(pr_core, pr_pi))
@info("pr_s <-> pr_pi_s: ", chebyshev(pr_s, pr_pi_s))


┌ Info: compute Pagerank (power iteration)
└ @ Main In[15]:1
  0.135502 seconds (1.45 k allocations: 188.382 MiB, 5.79% gc time)
┌ Info: computing personalized Pageranks for node 1 (power iteration)
└ @ Main In[15]:6
  0.149270 seconds (1.67 k allocations: 217.804 MiB, 5.08% gc time)
┌ Info: pr_core <-> pr_pi: 
│   chebyshev(pr_core, pr_pi) = 2.7755575615628914e-17
└ @ Main In[15]:9
┌ Info: pr_s <-> pr_pi_s: 
│   chebyshev(pr_s, pr_pi_s) = 5.3649326516025386e-8
└ @ Main In[15]:10

In [27]:
@info("compute non-linear Pagerank (power iteration)")
ppr = zeros(Float64, n)
ppr[s] = 1.
# change damping
damping = 0.95
max_iter = 15

@time pr_pi_nl = PR(P, tanh, damping=damping, epsilon=epsilon, max_iter=max_iter)

@info("pr_pi <-> pr_pi_nl: ", chebyshev(pr_pi, pr_pi_nl))


  0.045595 seconds (498 allocations: 57.097 MiB, 3.77% gc time)
┌ Info: compute non-linear Pagerank (power iteration)
└ @ Main In[27]:1
┌ Info: pr_pi <-> pr_pi_nl: 
│   chebyshev(pr_pi, pr_pi_nl) = 0.06966279339435626
└ @ Main In[27]:10