如何在py2neo的neo4j图中将所有节点连接到一个节点 [英] How to get all nodes connected to one node in neo4j graph in py2neo

查看:110
本文介绍了如何在py2neo的neo4j图中将所有节点连接到一个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想选择一个节点并获取通过关系连接到它的所有节点.即便如此,它们也是第 n 级联系.

I want to pick a node and get all of the nodes that are connected to it by relationship. Even this they are nth degree connections.

py2neo 或简单的密码查询是什么?

What is the py2neo or simply cypher query for this?

推荐答案

这个 Cypher 查询应该可以工作(如果选择的节点的 myId 值为 123):

This Cypher query should work (if the picked node has a myId value of 123):

MATCH p=(n { myId:123 })-[*]-()
UNWIND FILTER(x IN NODES(p) WHERE x <> n) AS node
RETURN DISTINCT node;

FILTER 函数过滤掉选中的节点,即使存在循环返回它的路径.

The FILTER function filters out the picked node, even if there are paths that cycle back to it.

这篇关于如何在py2neo的neo4j图中将所有节点连接到一个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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