Reputation: 352
I scanned a small java application and now I'm trying to run this query on neo4J
MATCH (n:Class)-[rel]-(cls:Class) RETURN n,cls,rel
the result is giving multiple nodes with the same id is there any way to get all these relations but each unique node should come once only. I did manage to get only unique through the loop but is there any way through this query itself will give unique node
Upvotes: 1
Views: 66
Reputation: 6514
If you want to return a node and edge array, I would suggest the following cypher query:
MATCH (n:Class)
WITH collect(n) as nodeArray
MATCH (c1:Class)-[rel]->(c2:Class)
WITH nodeArray, collect([c1,rel,c2]) as edgeArray
RETURN nodeArray, edgeArray
You could obviously construct the edgeArray differently, but I don't know what is your preferred structure.
Upvotes: 1