How do we compare two graphs for equality


We have a business requirement to compare two graphs for equality.
After searching i found a MD5 example from apoc. Although it is resulting error as it simply uses string values from creating hash. i.e. it does a to string of whole node object.

We had issues where the property orders in a node is altered and MD5 is not working.

the fingertrprintgraph functions seems more well equipped but it has no provision to to use it on a specific graph. it works on complete db.

Can anyone help me out here..


Welcome to the community.
Although I have not used the function apoc.util.md5(results), however if you see the documentation it just gives the md5 hash value for the data in results

Also the reference document you had shared

also says the same thing.

In short there is no meaning to compare two graph in whole because there is high chance that their id written differently, however you can compare subgraph which are very much similar in file content.
We cannot compare group of two people
(A,B,C) Vs (C,B,A) however we can compare A vs A.


Hi Vivek,

Unfortunately my need is to compare two graphs as each graph as a whole signifies a unique data.
The fingertrprintgraph method does exactly that although it doesn't take a list of nodes as input and takes the whole db as context.


Hi Sayonsur,

This really great that you got your answer. :slight_smile:
I am not much aware of this and will go to read some white paper on the same.. However how how would you implement fingerprintgraph. Could you please give some ray of light so that I can start my finding from that angle.


When you tested the MD5 function, did you use an approach like this for ordering?

If that link doesn't help, could you explain further or provide an example of what you mean by this:

We had issues where the property orders in a node is altered and MD5 is not working.