I\'m hooked on using Python and NetworkX for analyzing graphs and as I learn more I want to use more and more data (guess I\'m becoming a data junkie :-). Eventually I think my
I would be interested to see the best way of using the hard drive. In the past I have made multiple graphs and saved them as .dot files. Then kind of mixed some of them in memory somehow. Not the best solution though.
from random import random
import networkx as nx
def make_graph():
G=nx.DiGraph()
N=10
#make a random graph
for i in range(N):
for j in range(i):
if 4*random()<1:
G.add_edge(i,j)
nx.write_dot(G,"savedgraph.dot")
return G
try:
G=nx.read_dot("savedgraph.dot")
except:
G=make_graph() #This will fail if you don't use the same seed but have created the graph in the past. You could use the Singleton design pattern here.
print G.adj