I have the following PageRank code:
n = 5
adj = Float64[0 0 1 1 0;
              0 0 1 0 0;
              0 1 0 0 0;
              1 0 1 0 1;
              0 1 1 0 0]
adj ./= sum(adj,2)

pageRank = ones(Float64,n)
N = 1
for t = 1:N
  temp = zeros(n)
  for j = 1:n
    temp[j] = 0.15 + 0.85 * vecdot(pageRank,adj[:,j])
    pageRank = copy(temp) # this line should have been put below, but isn't 
harmful here either
  end
  # pageRank = copy(temp)
end

pageRank

5-element Array{Float64,1}:
 0.433333
 0.15    
 0.461667
 0.334167
 0.244681


However, the correct result should be

5-element Array{Float64,1}:
 0.433333
 1.425   
 2.13333 
 0.575   
 0.433333

if the `pageRank = copy(temp)` is placed in the right place.

This makes the 2nd and 3rd item do not converge when N is large enough.

Is it a bug? Or am I missing something?

Reply via email to