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

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 :

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

If you load the sample data in this article Medium 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 ...

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:

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

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

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.

1 Like

yes that looks like it should work ...

1 Like

Thanks Paul ! It works yes :)

1 Like

Hello Paul!

I have read the Medium article and I foun it very helpful.
However, I would like to know one thing.

In the example, for plotting the relations between compnay and persons (the two labels) we have to write all the relations. Here you have it:

(p1)-[:OWNER {holding:45}]->(c1)<-[:OWNER {holding:55}]-(p2),
(p2)-[:OWNER {holding:70}]->(c2)<-[:OWNER {holding:30}]-(p3),
(p3)-[:OWNER {holding:60}]->(c3)<-[:OWNER {holding:40}]-(p1)

I was wondering if it could be possible to, instead of writting all this code, using a loop (foreach statement) as we could do with Python.

Thanks!!