Getting nodes with maximum relationships in Neo4j

13 views
Skip to first unread message

ravi....@innoplexus.com

unread,
Aug 15, 2016, 7:50:08 PM8/15/16
to Neo4j
Hi all,
We have a graph database with 8 million nodes and 50 million relationships. We need to find out nodes with maximum relationships in descending order. The code

start n=node(*)
match (n)-[r]-()
return n, count(r) as rel_count
order by rel_count desc
limit 25

is taking a lot of time. Is there any way to do it quickly?

Michael Hunger

unread,
Aug 15, 2016, 8:25:53 PM8/15/16
to ne...@googlegroups.com
Which Neo4j version do you use?

In 2.3.+ you can use:

MATCH (n)
WITH n, size( (n)--() ) as degree
RETURN n ORDER BY degree DESC LIMIT 100


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages