Skip to content

Instantly share code, notes, and snippets.

@conradlee
Created November 4, 2011 11:15
Show Gist options
  • Save conradlee/1339119 to your computer and use it in GitHub Desktop.
Save conradlee/1339119 to your computer and use it in GitHub Desktop.
An example edgelist parser
def read_edgelist(in_filename):
with open(in_filename) as f:
return [edge for edge in edge_generator(f)]
def edge_generator(f):
for line in f:
n1, n2, weight = line.rstrip("\n").split()
yield int(n1), int(n2), float(weight)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment