I'm working with Neo4j from Python and I compare two graphs at the node level in this way:
query = """
MATCH (n)-[r1]-(), (n)-[r2]-()
WHERE r1.disease = 'MyLabel1'
AND r2.disease = 'MyLabel2'
RETURN DISTINCT n
"""
results = driver.execute_query(query)
results[0]
The results of the query are stored in one at the first index of a list, I would like to show the results using a Pandas Dataframe;
I would like to plot the count of nodes in each graph and the nodes in common using a Venn diagramm in matplotlib
Example 1: Counting using Cypher, creating 1-row DataFrame
And here is a sample resulting Venn diagram:
Notes:
count1andcount2.MATCHinto 2MATCHes in the way shown above (where the results from the firstMATCHare aggregated before doing the secondMATCH) avoids producing a cartesian product.Example 2: Using DataFrames with all data
This query assumes that every node has a unique
idproperty.