1

I'm using the networkx in python to creat a lot of graphs,and after this I need to use the Isomorphic algorithm to process them.Is there a way to save all these graph together for later retrieval like create a list for them?

Here is an example graph:

import networkx as nx G = nx.Graph() G.add_node(0, label='H') G.add_node(1, label='P') G.add_node(2, label='H') G.add_edge(0, 1, weight=2) G.add_edge(0, 2, weight=8) 
1
  • 1
    In what format you are creating/using your graphs? Maybe show a piece of code. Commented Apr 10, 2019 at 11:33

1 Answer 1

2

You can save/load your graph with networkx save/load functions, here is an example that saves the graph in pickle format:

import networkx as nx import matplotlib.pyplot as plt G = nx.Graph() G.add_node(0, label='H') G.add_node(1, label='P') G.add_node(2, label='H') G.add_edge(0, 1, weight=2) G.add_edge(0, 2, weight=8) # save graph nx.write_gpickle(G, "pathToGraphPickleFile.nx") # load graph G2 = nx.read_gpickle("pathToGraphPickleFile.nx") # display loaded graph nx.draw(G2) plt.show() 

For other functions:https://networkx.github.io/documentation/stable/reference/readwrite/index.html

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.