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
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
MATCH (n) WHERE size( (n)--() ) > 2 RETURN n
should do the trick.
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.
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
.
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
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'
Super! Which version of Neo4j introduced this?
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