Loading and saving graphs in python -


i need create graph based on set of input files. since files loaded during separate iterations, need save graph , able add after re-loading graph information file.

the obvious choice seems graphviz python api doesn't seem allow loading. pydot has parse_dot_data file , referenced in this answer documentation non-existing , there's no clear way 'append' graph. there's networkx seem have ability load although it's in documentation found. lastly there's graph-tool overkill , requires more libraries , tool need simple job.

i'm sure must solved problem , i'm reluctant "reinvent wheel" , write database/persistence layer accomplish this.

how can make simple graph in python, save somewhere , load when needed?

networkx provides abundant file formats reading , writing graphs. refer reading , writing graphs detailed description. instance,

import networkx nx  # create graph g = nx.florentine_families_graph()  # save file filename = 'florentine_families_graph.graphml' g = nx.write_graphml(g, filename)  # load file filename = 'florentine_families_graph.graphml' g = nx.read_graphml(filename) 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo