Created
November 4, 2011 11:15
-
-
Save conradlee/1339119 to your computer and use it in GitHub Desktop.
An example edgelist parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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