Counting memberships but only conditional displaying

Hi all,

I'm struggling with a certain question I want answered:

The first part of my query is the following (it's a Bloodhound context):
"Give me all the domain admins that have "AMD_" as part of their username, as those are the human DA's, and show me all their first order group memberships." I translated this to:

MATCH (u:User)-[:MemberOf*1]->(g:Group {name:'DOMAIN ADMINS@FOO.LOCAL'}) 
WITH u MATCH p=(u)-[:MemberOf*1]->(n:Group) return p

As one can imagine, this gets ugly fast. With 20 admins at the moment, and 20-50 memberships each. Graphically unusable. What I now would like is to show only those groups that a subset of the "ADM_"'s is member of. (or be able to show only those groups that less than x "ADM_"'s are member of, to make it a bit more generic) So basically remove any node where:

  • The number of incoming "member of" connections is equal to the count of the number of "ADM_"'s OR
  • All "AMD_'s" are member of a particular group.

Maybe a more generic description of the problem would be:
"Show me a graph of group memberships proper subsets (A⊂B) of a given set of nodes are member of."

I think the first approach would be easier, but I don't know how to count these incoming memberof connections.

Looking forward to your help.

Assuming the 'Group' node has a property 'member' that stores the DA's name

MATCH (g:Group)
where g.member STARTS WITH("AMD_") 
Return g