简体   繁体   English

Neo4j/Cypher:计算数据库中的图数或匹配结果

[英]Neo4j/Cypher : Counting the number of Graphs in a DB or match result

As a Graph DB is a collection of Graphs (1-N), is there a simple way to return the number of Graphs?由于图形数据库是图形的集合(1-N),是否有一种简单的方法可以返回图形的数量? There are many possibilities to count nodes, properties and relationships, but don't seem to be able to find something on counting Graphs itself, and metadata on those Graphs.计算节点、属性和关系的可能性有很多,但似乎无法找到计算 Graph 本身以及这些 Graph 上的元数据的内容。 Eg returning that there are 5 Graphs of 10 nodes and 15 relationships and 5 Graphs of 5 nodes and 7 relationships ... would be a table if there are many Graphs.例如,返回有 5 个 10 个节点和 15 个关系的图和 5 个 5 个节点和 7 个关系的图......如果有很多图,这将是一个表。 On a second level, the same counting on a match result - that is, match some condition, and count the number of Graphs of which the resulting nodes are part of.在第二个级别上,对匹配结果进行相同的计数 - 即匹配某个条件,并计算结果节点所属的图的数量。

[Adding extras] screendump This is the result of a cypher yielding three distinct Graphs. [Adding extras] screendump这是一个密码生成三个不同图形的结果。 The easiest one is the one at the bottom right, which is 5 nodes with 4 relationships.最简单的一个是右下角的,它是5个节点,有4个关系。 What I would like to get returned is the number 3 (primary goal), as there are 3 Graphs, and for each of them (secondary goal) the number of nodes and relationships contained within them.我想要返回的是数字 3(主要目标),因为有 3 个图,并且对于它们(次要目标)中包含的节点和关系的数量。 Hope this clarifies more.希望这能澄清更多。

Something like this?像这样的东西?

CALL algo.unionFind.stream() YIELD nodeId, setId
RETURN DISTINCT setId, COUNT(DISTINCT nodeId) AS nodesCount
ORDER BY nodesCount DESC LIMIT 100
;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM