How to query all relationships of a node in neo4j?

To retrieve all relationships of a node, you can utilize Neo4j’s Cypher query language. Here are some examples of queries:

  1. Retrieve all outgoing relationships of a node.
MATCH (n)-[r]->()
WHERE ID(n) = <节点ID>
RETURN r
  1. Find all the incoming relationships of a node.
MATCH ()-[r]->(n)
WHERE ID(n) = <节点ID>
RETURN r
  1. Retrieve all relationships of a node, including both out-degree and in-degree.
MATCH (n)-[r]-()
WHERE ID(n) = <节点ID>
RETURN r
  1. Search for relationships of a specified type in the node.
MATCH (n)-[r:关系类型]->()
WHERE ID(n) = <节点ID>
RETURN r

Please note that the in the above query should be replaced with the actual ID of the node.

广告
Closing in 10 seconds
bannerAds