finding and listing groups with identical relations

9 views
Skip to first unread message

tgomell

unread,
Sep 26, 2012, 11:01:23 AM9/26/12
to ne...@googlegroups.com

Hello,

we are searching for a query that enables us to identify groups with equal relations. The groups contain users and have been imported from the AD. The users are connected to the groups with the relation „rel_member“. Now we want to find out if there are multiple groups that contain exactly the same users. How can we filter out (and list) those groups as easy as possible? Is there a suitable algorithm to do so?

regards

Wes Freeman

unread,
Sep 26, 2012, 1:13:13 PM9/26/12
to ne...@googlegroups.com
Looking at just one level? That's kind of an interesting problem. I think with some clever uses of collect aggregation you can manage it.

Something like:
start group=node(*) 
match group-[:rel_member]->user 
with group, user 
with group, collect(user) as users 
with collect(group) as groups, users 
return length(groups) as ngroups, groups, users;

http://console.neo4j.org/r/n4dlpa

--
 
 

Wes Freeman

unread,
Sep 26, 2012, 1:14:54 PM9/26/12
to ne...@googlegroups.com
Woops, I left an extra "with" in there, can be shortened to:
start group=node(*) 
match group-[:rel_member]->user 
with group, collect(user) as users 
with collect(group) as groups, users 
return length(groups) as ngroups, groups, users;

Wes Freeman

unread,
Sep 26, 2012, 1:51:20 PM9/26/12
to ne...@googlegroups.com
And you probably want to add a where length(groups) > 1 just before the return, to get only the ones that match more than one set of users.

Sorry for the group spam.

Wes
Reply all
Reply to author
Forward
0 new messages