Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Created a dictionary of tuples to determine order of ranks
  • Loading branch information
sib12004 committed Apr 17, 2016
1 parent 80b69ab commit a4bc8f4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pagerank.py
Expand Up @@ -3,6 +3,7 @@
#Google PageRank Algorithm Implementation

import csv
import operator

with open("hollins.dat", "r") as data:
reader = csv.reader(data, delimiter = ' ', skipinitialspace=True)
Expand Down Expand Up @@ -92,4 +93,15 @@ def PageRank(verts, initVec, outgoing, damp) :
print("success!")
return nextVector

PageRank(V, initialVector, N, .85)
finalRank = PageRank(V, initialVector, N, .85)
finalRankDict = {}

#Now we need to create a printable list
#First we make finalRank a dictionary of index : rank
for i in range(1,len(finalRank)) :
finalRankDict[i] = finalRank[i]

#now sort these by rank, in descending order; format is a list of (index, rank) tuples
sortedRanks = sorted(finalRankDict.items(), key=operator.itemgetter(1), reverse=True)

#Need to print these in order by searching through the urls dictionary

0 comments on commit a4bc8f4

Please sign in to comment.