开发者

what is the difference and when to use Save in java as Text file or as an Object?

开发者 https://www.devze.com 2023-03-12 04:11 出处:网络
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 ?? ...

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消