Wikipedia article on PageRank

Original PageRank paper: Page, Lawrence and Brin, Sergey and Motwani, Rajeev and Winograd, Terry (1999) The PageRank Citation Ranking: Bringing Order to the Web. Technical Report. Stanford InfoLab.

Loading the data

The pseudocode for the rest of the code is:

transition_matrix = <compute transition matrix>
times_visited = <list of size N>
for i in range(num_steps):
    page = <take a step with the random surfer>
    times_visited[page] += 1

for c in times_visited:
    print c / num_steps

Computing the transition matrix

Simulating the random surfer

All together