How to Store Graphs?

2024/10/7 4:29:52

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?

Answer

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.

https://en.xdnf.cn/q/70289.html

Related Q&A

regex for only numbers in string?

I cant find the regex for strings containing only whitespaces or integers. The string is an input from user on keyboard. It can contain everything but \n (but it doesnt matter I guess), but we can focu…

How to build a chi-square distribution table

I would like to generate a chi-square distribution table in python as a function of the probability level and degree of freedom.How to calculate the probability, given a known chi-value and degree of f…

Reset all weights of Keras model

I would like to be able to reset the weights of my entire Keras model so that I do not have to compile it again. Compiling the model is currently the main bottleneck of my code. Here is an example of w…

How to fix NaN or infinity issue for sparse matrix in python?

Im totally new to python. Ive used some code found online and I tried to work on it. So Im creating a text-document-matrix and I want to add some extra features before training a logistic regression mo…

Mutable default argument for a Python namedtuple

I came across a neat way of having namedtuples use default arguments from here.from collections import namedtuple Node = namedtuple(Node, val left right) Node.__new__.__defaults__ = (None, None, None) …

Windows notification with button using python

I need to make a program that alerts me with a windows notification, and I found out that this can be simply done with the following code. I dont care what library I use from win10toast import ToastNo…

numpy IndexError: too many indices for array when indexing matrix with another

I have a matrix a which I create like this:>>> a = np.matrix("1 2 3; 4 5 6; 7 8 9; 10 11 12")I have a matrix labels which I create like this:>>> labels = np.matrix("1;0…

how to use enum in swig with python?

I have a enum declaration as follows:typedef enum mail_ {Out = 0,Int = 1,Spam = 2 } mail;Function:mail status; int fill_mail_data(int i, &status);In the function above, status gets filled up and wi…

What does except Exception as e mean in python? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 4…

Numpy efficient big matrix multiplication

To store big matrix on disk I use numpy.memmap.Here is a sample code to test big matrix multiplication:import numpy as np import timerows= 10000 # it can be large for example 1kk cols= 1000#create some…