This question is a direct extension of a question I asked previously here (and and even earlier version here).
Say I have a graph database that looks like this:
If this is about families of people, then easiest fix is to add a :Family node for each relational group, like so:
create (f:Family) with f
match (a:person {name:"Adrian"})-[:RELATED_TO*]->(b:person)
merge (f:Family)<-[:FAMILY]-(a)
merge (f:Family)<-[:FAMILY]-(b)
Replace "Adrian" with "Barry" to create the second family group.
That gives you a central :Family node for each family group. You can then pick the family group that has enough :person.SomeProperty = "Yes" family members like so:
// Find families with 2 or more :person.SomeProperty = "yes"
match p = (f:Family)<-[:FAMILY]-(psn:person)
where psn.SomeProperty = "Yes"
with f, count(psn) as cnt
where cnt > 2
// Get the family members
match (a:person)<-[r1:RELATED_TO]-(b:person)-[r2:RELATED_TO*]->(c)
where (a)-[:FAMILY]-(f)
and a = c // to get all the nodes in the loop
// report the first record which'll have two
// family members and all the relationships
return a, r1, b, r2
limit 1