Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Store Graphs?

Tags:

python

graph

Lets say i have a class Graph defined.

graph iowa = {.....nodes:{edges.......}}

and similar graph clusters.

once the script is running its all in the object.

But how do you store the Graph info (including whatever its attributes were defined) ? Do you save it in a db table, csv ?

Possible unsatisfactory queries: Storing multiple graphs in Neo4J (It says newo4j one instance supports one Graph at a time and to subgraph under one graph if you want to run multiple graphs)

How to store graph data in a database?

*****UPDATE*****: On Alexanders answer below on available Graph DBs, I would like to know if anyone knows of a possible fork of VertexDB where they've imported this high performance lib into any other language preferably NodeJS or Python?

http://www.dekorte.com/projects/opensource/vertexdb/docs/manual.html

And does anyone have experience reading this in using AllegroGraph vs Neo4j?

like image 292
user2290820 Avatar asked Oct 24 '13 12:10

user2290820


1 Answers

The NetworkX python library provides a couple of ways to store graph data:

  1. Serialize a graph to JSON
  2. Pickle a graph
  3. Store a graph in the gml format (link)
  4. Write graph to .dot file (link).

Storing graphs in a relational database is certainly a bad option, because of complexity of the data, complexity of graph queries, which is hard to write in SQL and the performance of these queries. Graph Databases, NOSQL and Neo4j article describes this problem in great details.

However, I think, you should really consider to use Neo4j. I hope after some investigations, you'll find a way to adapt it to your needs. After all, there are a lot of alternatives to the Neo4j.

DB-engines is a great resource to visit. There are a lot of useful information, in particular, you can compare any database with another and find the one, that best suites you.

Also, you can refer to this beautiful answer.

Update:

Since you are using structures, similar to JSON, you can consider using JSON-oriented databases, such as CouchDB or MongoDB. They have decent perfomance and scale better, than Neo4j.

like image 52
13 revs Avatar answered Oct 25 '22 14:10

13 revs