Skip to content

Instantly share code, notes, and snippets.

@domluna
Created October 12, 2014 18:36
Show Gist options
  • Select an option

  • Save domluna/2b9358ccc89fee7d5e26 to your computer and use it in GitHub Desktop.

Select an option

Save domluna/2b9358ccc89fee7d5e26 to your computer and use it in GitHub Desktop.
Simple pagerank in Julia
# Simple pagerank implementation
# M - transition matrix
# r - initial rankings
# \beta - the taxation cost, (1-\beta) is the teleport prob
# iter - iterations to run for
function pagerank(M::Matrix{Float64}, r::Vector{Float64}, β::Float64, iter::Int64)
c = (1-β)/length(r)
v_prime = β*M*r + c
for i = 1:iter
v_prime = β*M*v_prime + c
end
return v_prime
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment