In [1]:
import py2neo
import pandas as pd
graph= py2neo.Graph()
query="""
MATCH
(s1:Subdomain)<-[:BELONGS_TO]-
(type:Type)-[r:DEPENDS_ON*0..1]->
(dependency:Type)-[:BELONGS_TO]->(s2:Subdomain)
RETURN s1.name as from, s2.name as to, COUNT(r) as x_number
"""
result = graph.run(query).data()
df = pd.DataFrame(result)
In [2]:
df.head(10)
Out[2]:
In [4]:
import json
json_data = df.to_dict(orient='split')['data']
with open ( "chord_data.json", mode='w') as json_file:
json_file.write(json.dumps(json_data, indent=3))
json_data[:10]
Out[4]: