How can I display groups of nodes which realized more than n realtionships with different nodes in the graph

apoc
cypher
operations

(Mehdi Ajroud) #1

I have many groups in my graph , but I want to display only those which worked together more than n times .
And here is an example :


(Paul Thomas) #2

I am not quite sure what you are asking but ...

If you load the sample data in this article https://medium.com/@paul13thomas/graph-analytics-of-shareholder-data-6f6b5333bd1c then install apoc and use apoc's unionFind to find the clusters ...

CALL algo.unionFind(
'match (n) return id(n) as id',
'match (n1:Person)--(n2) return id(n1) as source, id(n2) as target',
{graph:'cypher', write:true, partitionProperty:"clusterId"})
YIELD nodes, setCount, loadMillis, computeMillis, writeMillis;

then to only show the big clusters run

match (n1)
with n1.clusterId as clusterId, count(n1) as clusterSize
where clusterSize > 10
match (n2) where n2.clusterId = clusterId
return n2

That will only bring back 1 cluster which has 15 nodes.

So a similar query to count the number of relationships

match (n1)-[r]-()
with n1.clusterId as clusterId, count(distinct r) as numberOfRels
where numberOfRels > 10
match (n2) where n2.clusterId = clusterId
return n2

again will only show the large cluster.

This would seem to work if this is what you are looking to do ...


(Mehdi Ajroud) #3

I will try it and let you know . Btw there is no access to the link ! I am having 404 not found when I open it :frowning:


(Mehdi Ajroud) #4

I am using community version , I cannot apply the clustering algo !


(Mehdi Ajroud) #5

What if I use this query ?

match (n1:attribfxplaf)-[r]-()
with n1.clusterId as clusterId, count(n1) as clusterSize,count(distinct r) as numberOfRels
where clusterSize > 10 AND  numberOfRels > 10
match (n2) where n2.clusterId = clusterId
return n2,clusterId

(Paul Thomas) #6

Apoc can be installed manually on the community version I'm fairly certain.

You'll you need to download the various apoc jars and copy them to the correct location and re-start Neo4j.


(Paul Thomas) #7

yes that looks like it should work ...


(Mehdi Ajroud) #8

Thanks Paul ! It works yes :)