cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Extrapolate relations between two nodes based on mediated connection

Hello,
i'm in a situation where i have graph of 300 000 nodes where such pattern occurs:

(A:Human)-[R:Has]-(B:Car)-[P:Stolen]-(C:Human)

i would like to create a new "extrapolated" edge:
(A)-[X:ExtrapolatedConnection]-(C)

(in order to be able to find all shortest paths between humans while understanding and assuming the above connection as direct),

however, when i try simply:

MATCH (A:Human)-[R:Has]-(B:Car)-[P:Stolen]-(C:Human)
MERGE (A)-[X:ExtrapolatedConnection]-(C)

the Execution failed and Java heap space error is returned after a while. I guess it's all wrong?
thank you

1 ACCEPTED SOLUTION

Hello @ldpubsec and welcome to the Neo4j community

The dirty solution is to directly increase the heap size of your database in the neo4j.conf file.

The second option is to modify a bit your query like this (it requires APOC plugin):

CALL apoc.periodic.iterate('MATCH (A:Human)-[:Has]-(:Car)-[:Stolen]-(C:Human) RETURN A, C', 'MERGE (A)-[X:ExtrapolatedConnection]-(C)', {batchSize:1000})

Or you can do both

Regards,
Cobra

View solution in original post

1 REPLY 1

Hello @ldpubsec and welcome to the Neo4j community

The dirty solution is to directly increase the heap size of your database in the neo4j.conf file.

The second option is to modify a bit your query like this (it requires APOC plugin):

CALL apoc.periodic.iterate('MATCH (A:Human)-[:Has]-(:Car)-[:Stolen]-(C:Human) RETURN A, C', 'MERGE (A)-[X:ExtrapolatedConnection]-(C)', {batchSize:1000})

Or you can do both

Regards,
Cobra