Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Expect disruption to service on Thursday, Feb. 9!

Forming relationship based on non-empty intersection of node properties

Node Clone

I have a bunch of nodes with unique_patients property as a list. I want to connect any two nodes through a relationship based on the non-empty intersection of this property. So far, my attempt in getting the number of intersections is as follows -

MATCH (a:Gene)
	MATCH (b:Gene)
    RETURN apoc.coll.intersection(a.unique_patients ,b.unique_patients) AS intersection;

However, this gives both empty and non-empty intersections. My questions are as follows:

  1. How to obtain non-empty intersections?
  2. How to make a relationship based on this non-intersection?
  3. How to make a relationship based on a minimum number of intersections, say at least 2 elements?
  4. How to set other properties of this relationship based on the properties of the nodes (like one of the properties could be the patients exclusive to each of the nodes)?

Thanks in advance.


Graph Steward

Hi Kasthuri,

Could you please explain the scenario and question based on sample data