From b34d60d2944b2ba6658e4cbfa5048617e9dc24c6 Mon Sep 17 00:00:00 2001 From: sib12004 Date: Thu, 21 Apr 2016 13:54:54 -0400 Subject: [PATCH] Doesn't work yet, trying to get it to print to a file --- pagerank2.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pagerank2.py b/pagerank2.py index 390d639..365c469 100644 --- a/pagerank2.py +++ b/pagerank2.py @@ -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() +