开始使用免费开始使用

Convergence of PageRank

In this exercise, you will visually inspect how the PageRanks converge by plotting the differences of every two subsequent iterations.

本练习是课程的一部分

Predictive Analytics using Networked Data in R

查看课程

练习说明

  • Create an empty vector called value.
  • Write a for loop with 15 steps. For each step in the loop, compute the PageRank value of network with i iterations. Add the vector attribute as a column to value using cbind().
  • Compute the absolute difference between each subsequent pair of PageRank vectors in value and assign to difference.
  • Plot the difference vector to inspect the convergence of the PageRank values.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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)
编辑并运行代码