get all relationships for a node with cypher

The above solution doesn't return a graph representation in 3.1 anymore. Instead below solution should work

MATCH (a:User {username: 'user6'})-[r]-(b)
RETURN r, a, b

This was answered in another SO question


The simplest way to get all relationships for a single node is like this:

MATCH (:User {username: 'user6'})-[r]-()
RETURN r

Most of these answers will work just fine, but if like me, you also need the name of the relationship itself, you need to wrap r with type():

MATCH (a:User {username: 'user6'})-[r]-(b)
RETURN type(r), a, b

MATCH (n1:Node1)-[:HAS_RELATIONSHIP]-(OtherNodes)
RETURN n1, OtherNodes

This will get Node1 and its relations with other nodes

enter image description here

Tags:

Neo4J

Cypher