Arv*_*vin 6 graph neo4j cypher gremlin
如何获得Neo4j上每个节点的程度,然后找出哪个节点在一个非常大的图形中具有最大程度(200万个节点和500万个关系)?
我知道我可以使用Cypher或Gremlin实现这一目标,例如:
start n = node(*)
match (n)--(c)
return n, count(*) as connections
order by connections dsec
Run Code Online (Sandbox Code Playgroud)
要么
g.V.bothE
Run Code Online (Sandbox Code Playgroud)
但是我的计算机只有2G~4G的RAM,我总是等待很长时间并且在我发出上面的查询时得到"未定义".
有没有人在使用gremlin或cypher在neo4j上查询这样巨大的图表时有一些经验?
对于最大程度,您还应该限制结果,因此 cypher 只需要保留前 10 个结果。
START n = node(*)
MATCH (n)--(c)
RETURN n, count(*) as connections
ORDER BY connections DESC
LIMIT 10
Run Code Online (Sandbox Code Playgroud)
或者你可以这样做:
START n = node(*)
RETURN n, length((n)--(c)) as connections
ORDER BY connections DESC
LIMIT 10
Run Code Online (Sandbox Code Playgroud)
否则我同意斯特凡的观点。
今天你还可以使用call apoc.stats.degrees('TYPE')
where TYPEis关系类型,也可以通过nullor<TYPE或orTYPE>与direction。该过程是并行实施的,并且适用于大型图。