I'm working with Neo4J for the first time and I need to output the ego network of a node whose name was given in input. I'm using python and neo4j library to run queries into my graph.
I'm sorry for the colors, but it's the only way to explain the scenario. The blue node is the input node and the graph you see is the output of Neo4J of the blue node's ego network and it is exactly what I want to achieve in my query. The green edges are the nodes directly connected to the blue, yellow edges are self-relationships and red edges are relationships between the node's neighbours.
With this query I only achieve the green relationships:
MATCH p=(node {name:$name})-[*1]-(othernodes)
with *, relationships(p) as r
RETURN node,r,othernodes
I modified this query and I achieved also the yellow relationships (thanks to the comment below)
MATCH p=(node {name:$name})-[*1]-(othernodes)
with *, relationships(p) as r
MATCH s=(othernodes)-[*0..1]-(othernodes)
with *, relationships(s) as e
RETURN node,r,e,othernodes
But I'm still missing the correct query to achieve also the red edges. Can you help me out with this? Thanks in advance.
