密码查询以列出所有未连接的图形Neo4j图形数据库? [英] Cypher query to list all disconnected graphs Neo4j graph DB?

查看:93
本文介绍了密码查询以列出所有未连接的图形Neo4j图形数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Neo4j图形数据库大约包含50,000个节点和50,000个关系. 有一个包含大多数节点的主图.但是有几个图(尚未)连接到主图.

The Neo4j graph database holds roughly 50,000 nodes and > 50,000 relationships. There is a main graph that contains most nodes. But there are several graphs that are not (yet) connected to the main graph.

为了连接各种图以形成一个大的主图,我打算使用Cypher查询列出按其大小排序的连接节点的路径或集合(首先是最大的断开连接图).

In order to connect the various graph to form one big main graph I intend to use a Cypher query to list paths or collections of connected nodes ordered by their size (biggest disconnected graph first).

关于stackoverflow的几篇文章,如:

There are several posts on stackoverflow like:

  • Finding all disconnected subgraphs in a graph but it's not obvious how to solve it with Cypher.
  • How do I find disconnected nodes on neo4j with Cypher?

这是一个代表问题的小示例图: Neo4j控制台示例图

Here is a small example graph that represents the problem: Neo4j Console example graph

以下Cypher查询不能解决问题,但只是一个起点. 它列出了所有未连接到主图的那些节点.它错过了将那些节点合并为节点集合的过程.它在一个小图上工作.在大图上,运行10分钟以上后,它只会返回"undefined".

The following Cypher query does not solve the problem but is a starting point. It lists all those nodes that are not connceted to the main graph. It misses the combining of those nodes into collections of nodes. It works on a small graph. On a large graph it only returns "undefined" ... after running more than 10 minutes.

START s=node(3), n=node(*) 
MATCH s-[*1..10]-m 
WITH collect(m) as members, n 
WHERE NOT n in members 
RETURN DISTINCT id(n), n.name? 
ORDER BY id(n) 
LIMIT 10;

如何使用Cypher列出所有断开连接的(子)图形?

How to use Cypher to list all disconnected (sub-) graphs?

环境: -Neo4j-图形数据库内核1.9.M05 -Java-SE运行时环境(内部版本1.7.0_17-b02)

Environment: - Neo4j - Graph Database Kernel 1.9.M05 - Java - SE Runtime Environment (build 1.7.0_17-b02)

推荐答案

这不是一个完整的答案,但我认为您应该(如果可以)退回

this is not a complete answer but I think you should (if you can) fall back the Traversal Framework for this use case.

Cypher是关于匹配图形的特定部分的,而不管您想怎么做. 遍历框架实际上是关于如何遍历图形的.

Cypher is about matching specific portions of a graph, no matter how you wanna do it. The Traversal framework is really about HOW you wanna traverse a graph.

在您的情况下,遍历比要匹配的图形更重要.这是我的建议,请使用遍历框架

In your case, the traversal is more important than the graph to match. Here is what I'd suggest, use the Traversal Framework to

  1. 以所需方式标记节点组
  2. 在地图上汇总结果(或其他经过改进的结果)

这篇关于密码查询以列出所有未连接的图形Neo4j图形数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆