How to get all nodes connected to one node in neo4j graph in py2neo

允我心安 提交于 2021-01-28 03:23:41

问题


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.

What is the py2neo or simply cypher query for this?


回答1:


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;

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



来源:https://stackoverflow.com/questions/33487787/how-to-get-all-nodes-connected-to-one-node-in-neo4j-graph-in-py2neo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!