Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def parseFile(filename):
  2.     file = open(filename)
  3.     for line in f:
  4.         #reg helps parse file
  5.         #\s matches single whitespace character
  6.         #\d matches digit
  7.         reg = re.match( r'(\d+)\s(\d+)', str(line))
  8.         #all matching subgroups in a tuple
  9.         i = int(reg.group(1))
  10.         j = int(reg.group(2))
  11.         #Containers for the graph, graphReverse
  12.         g = []
  13.         gR = []
  14.         while(len(g) < i):
  15.             g.append([])
  16.         g[i-1].append(j)
  17.  
  18.         while(len(gR) < j):
  19.             gR.append([])
  20.         gR[j-1].append(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement