Hi all,
I have a tree in Neo4j from which I need to export some subtrees.
I need to export each subtree in format that can be read in networkx library. After some research, I ended up using two apoc procedures, one to get a subtree and the other to export to JSON. The problem is that the apoc procedure I'm using to get the subtrees returns a "path" object. This object can be visualized in neo4j-browser and I can export it to a JSON string. However, I don't know how to deal with these paths. How to convert these Neo4j paths in a format networkx can read?
Thats the query I'm using:
WITH "MATCH (p:Area {name: 'UGH'})
CALL apoc.path.expandConfig(p, {
relationshipFilter: '<SON_OF',
minLevel: 1,
maxLevel: 4,
bfs: false,
limit: 10
})
YIELD path RETURN path" as query
CALL apoc.export.json.query(query, null, {stream: true})
YIELD path
RETURN path
and the result is a string like that:
'{"path":{"length":1,"rels":[{"id":"41","type":"relationship","label":"SON_OF","properties":{"type":"IS_SUB_AREA_OF"},"start":{"id":"1318","labels":["Sub_Area"]},"end":{"id":"1319","labels":["Area"]}}],"nodes":[{"type":"node","id":"1319","labels":["Area"]},
Thanks in advance for any help