问题
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