Created
August 2, 2018 04:18
-
-
Save srolel/88a883136e8f5480e4290a80e8fa09bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ranks = [1,1,1,1] | |
links = [[1], [0], [0,3], [2]] | |
damping = 1 | |
iterations = 100 | |
for _ in range(0, iterations): | |
contributions = [0,0,0,0] | |
for i, page_links in enumerate(links): | |
for link in page_links: | |
contributions[link] += ranks[i] / len(page_links) | |
ranks = [(1 - damping) / len(ranks) + damping * c for c in contributions] | |
print ('Page ranks after %d iterations: %s' % (iterations, ranks)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment