cancel
Showing results for 
Search instead for 
Did you mean: 

Node property array part of other array

VilladsClaes
Node Clone


These nodes have an array as property with start point and end point

I wish to match the orange node based on the fact that the two gray nodes are part of the same array (the distance is in the same span)
I wish to match the blue node based on the fact that the two green nodes are part of the same array

The math seems to be above my league

I tried:

MATCH (m1) WHERE m1.range[0] < m.range[0] AND m1.range[1] < m.range[1]
WITH m1, m
MATCH (m2) WHERE m2.range[0] > m1.range[0] AND m2.range[1] > m1.range[1]
WITH m1,m2,m
RETURN m1.name AS startPart, m2.name AS endPart
1 REPLY 1

nghia71
Node Clone

Hi,

I don't know how many nodes are there in the graph. If there are not too many, you can create a relationship between the nodes.

MATCH (m:MyNode)
WITH m MATCH (n:MyNode) WHERE (m <> n) AND (m.range[0] < n.range[0] AND m.range[1] < n.range[1])
MERGE (m)<-[:IS_IN_RANGE_OF]-(n)

You might need to look for apoc.periodic.iterate() if there are too many of them in order to avoid running out of memory.

When it's done, then you can use
MATCH (m:MyNode)<-[: IS_IN_RANGE_OF]-(n)
RETURN m, COLLECT(n) AS parts

The only thing you might need is to decide which is start and which is end.

My two cents.

Nghia Doan