简体   繁体   中英

OpenCypher - Get all nodes that not connect to the center of the graph

I have a graph on Neptune and I used OpenCypher to query on it.

At the middle of the graph I have a big connected nodes, at the edges you can see that I have some single nodes/ nodes that connected only to 1-5 other nodes. (see on the picture)

I want to get all of them, there is an option to do so?

I tried to think about options like take a random Id from the center and check all the nodes that don't have a path from them to this node, or maybe say get a table with all nodes and number of connected nodes to them, and ask for all nodes that not contain more than 10 nodes connected

but I didn't find a way to write this query, Must to know that opencypher on Neptune not contains all the magic keys like 'all' predicate function, so need to find a way with the functions that neptune support

在此处输入图像描述

Ideally, you would want to run Weakly Connected Components algorithm to identify the largest component and then return all nodes that are not part of it. It seems that Neptune doesn't support that algorithm out-of-the-box, but you could implement it with gremlin as discussed in another SO question: Find largest connected components AWS Neptune

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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