Skip to content

Instantly share code, notes, and snippets.

@accesstoken
Last active December 31, 2015 05:09
Show Gist options
  • Save accesstoken/7938508 to your computer and use it in GitHub Desktop.
Save accesstoken/7938508 to your computer and use it in GitHub Desktop.
import os
import networkx as nx
import memory # include memory.py
import random
import math
def get_filename(i):
return 'foo/foo' + str(i) + '.gml'
if not os.path.exists('foo'):
os.mkdir('foo')
for i in xrange(1000):
n = random.randint(1, 5000)
m = int(n * math.log(n))
g = nx.gnm_random_graph(n, m)
nx.write_gml(g, get_filename(i))
for i in xrange(1000):
g = nx.read_gml(get_filename(i))
mem_usage = memory.resident() / (1024 * 1024) # memory usage in MB of current process
print g.number_of_nodes(), g.number_of_edges(), mem_usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment