Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-19-2019 10:04 PM
Hi,
Q1: May I know cypher query to find the nodes having minimum 2 edges, either 2 In minimum, or 1 in and 1 out minimum?
based on Degree, I did that, i.e having deg > 2, but without running degree algorithm
Thanks
Solved! Go to Solution.
09-20-2019 08:47 AM
09-20-2019 08:47 AM
MATCH (n) WHERE size( (n)--() ) > 2 RETURN n
should do the trick.
09-27-2019 01:25 PM
That’s a full scan of the relationships file, correct? Even worse, most likely a full scan of the nodes file, plus a relationship pointer chase for each node.
09-29-2019 12:22 AM
No. "Just" a full scan of nodes file. Getting the degree of a node is a O(n)
operation for n<50
and a O(1)
for n>=50
.
09-29-2019 01:01 AM
That’s interesting. I thought I understood Neo4j internals and file record layout.
Can you educate me? Or tell me what part of the documentation I missed?
Thx
09-29-2019 04:03 AM
Neo4j records a pre-calculated value for the following
Count of Nodes , i.e. match (n) return count(n);
Count of Nodes per label, i.e. match (n:Person) return count(n);
Count of relationship types per Node and direction, i.e. match (n) return size( (n)-[:FOLLOWS]->() );
if you PROFILE
or EXPLAIN
the above Cypher statements you should see a block referring to 'CountStore'
09-30-2019 01:52 AM
Super! Which version of Neo4j introduced this?
09-30-2019 10:54 AM
introduced what?
the precalculated values at
Count of Nodes , i.e. match (n) return count(n);
Count of Nodes per label, i.e. match (n:Person) return count(n);
Count of relationship types per Node and direction, i.e. match (n) return size( (n)-[:FOLLOWS]->() );
has been in Neo4j since at least Neo4j version 2.3, if not earlier
All the sessions of the conference are now available online