예제 #1
0
파일: main.py 프로젝트: Arkkraa/466-project
def runFootball():
   """run pagerank on NCAA_football.csv"""

   f = open('NCAA_football.csv')
   graph = PageRank()

   for line in f:
      columns = line.split(',')
      team1 = columns[0].strip()
      value1 = int(columns[1])
      team2 = columns[2].strip()
      value2 = int(columns[3])

      if value1 > value2:
         graph.addEdge(team2, team1)

      elif value1 < value2:
         graph.addEdge(team1, team2)

      else:
         graph.addEdge(team2, team1)
         graph.addEdge(team1, team2)

   graph.printGraph()
   iterations, ranks = graph.getPageRank()
   print "Number of iterations:", iterations
   print returnSorted(ranks)
예제 #2
0
파일: main.py 프로젝트: Arkkraa/466-project
def runStates():
   """run pagerank on stateborders.csv"""
   f = open('stateborders.csv')

   graph = PageRank()
   for line in f:
      columns = line.split(',')
      left = columns[0].strip('"')
      right = columns[2].strip('"')
      graph.addEdge(left, right)

   graph.printGraph()
   iterations, ranks = graph.getPageRank()
   print "Number of iterations:", iterations
   print returnSorted(ranks)