Neo4J: find a sub-graph of arbitrary depth with nodes connected by a given set of relations?

你说的曾经没有我的故事 提交于 2019-12-25 06:28:09

问题


How to build a Neo4J query that:

1) Will return all nodes in a sub-graph of arbitrary depth with nodes connected by a given set of relations?

For example in Cypher-like syntax:

MATCH (*)-[r1:FRIEND_OF AND r2:COLLEAGUE_WITH]->(*) RETURN * 

回答1:


This query will return just the nodes, as you stated in your question:

MATCH (n)-[:FRIEND_OF|COLLEAGUE_WITH*]->(m)
RETURN n, m;

If you also want the relationships:

MATCH (n)-[r:FRIEND_OF|COLLEAGUE_WITH*]->(m)
RETURN n, r, m;


来源:https://stackoverflow.com/questions/23160713/neo4j-find-a-sub-graph-of-arbitrary-depth-with-nodes-connected-by-a-given-set-o

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