Convergence of PageRank
In this exercise, you will visually inspect how the PageRanks converge by plotting the differences of every two subsequent iterations.
Este exercício faz parte do curso
Predictive Analytics using Networked Data in R
Instruções do exercício
- Create an empty vector called
value. - Write a
forloop with 15 steps. For each step in the loop, compute the PageRank value ofnetworkwithiiterations. Add thevectorattribute as a column tovalueusingcbind(). - Compute the absolute difference between each subsequent pair of PageRank vectors in
valueand assign todifference. - Plot the
differencevector to inspect the convergence of the PageRank values.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Create an empty vector
___ <- c()
# Write a loop to compute PageRank
for(i in 1:___){
value <- cbind(value, page.rank(___, algo = 'power',options = list(niter = ___))$vector)
}
# Compute the differences
difference <- colSums(abs(___[,1:14] - ___[,2:15]))
# Plot the differences
___(1:14, difference)