Skip to content

Commit

Permalink
Doesn't work yet, trying to get it to print to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
sib12004 committed Apr 21, 2016
1 parent e084848 commit b34d60d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pagerank2.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,21 @@ def PageRank(trans, initVec, damp, incoming, n=0) :

finalRank = PageRank(P, initialVector, .85, incoming)

#turn this into a dictionary of final rank value : index
rankOrder = {}
for i in range(len(finalRank)) :
rankOrder[finalRank[i]] = i

#now write the answer to a text file
file = open("ranking.txt", "w")

#need to print out in order of max to min keys of the dict
#we sort finalRank from min to max
finalRank.sort()

for i in finalRank :
index = finalRank.pop()
file.write(index, urls[index])

file.close()

0 comments on commit b34d60d

Please sign in to comment.