python - Fastest way to import nodes/edges into a NetworkX DiGraph from CSV? -
i'm trying improve speed of networkx digraph population csv. right i've got straight forward csv reader , graph add situation:
g = digraph() nodes = csv.dictreader(open(nodefile, 'ru'), ['index', 'label', 'type']) row in nodes: g.add_node(row['index'], {'index':row['index'], 'label':row['label'], 'type':row['type']}) edges = csv.dictreader(open(edgefile, 'ru'), ['v1', 'v2', 'weight']) row in edges: g.add_edge(row['v1'], row['v2'], row[weight'])
the graph data i'm dealing can pretty big. 10,000,000 nodes big. memory isn't issue, simple things importing , exporting can eat time better spent on more important data crunching.
does have suggestions? i've been scouring networkx utility methods or techniques can this. i've stripped down import csv requirements these 3 columns , removed value checking.
thank in advance ideas.
Comments
Post a Comment