I need to save a graph in order to load it and apply algorithms on it ... so what is best to do save the graph as t开发者_如何学运维ext file or as an object ?? ... or is there another efficient way ???
If you can make your node and edge classes serializable, that will be the easiest thing. You won't have to worry about dealing with circular references on write or reconstructing them on read; they will automatically be reconstituted.
If you use symbolic data, then you will need to have a unique id for each node unless you are guaranteed that no two nodes in the graph will ever have the same data. Then you'll need to maintain a symbol table for reconstructed nodes when you reconstruct the graph. Lots of bookkeeping headaches.
精彩评论