2
votes

I have a large scale graph database with hundreds of nodes and relationships. its look like a tree. i want to write a query to get returned just only a branch. i have attached a simple graphical representation of what i needed for more information....

here i want to start traverse from node A then A->B->C that is a one branch, then again start from A->B-->D that is another branch. finally i want to merge those two branch and get a output as shown in the right side. there can be more than two output to merge it depends on my original graph. this is a example. different color arrows shows different types of relationships.

patterns that i needed to check are:

(A)<-[:ORANGE]-p->[:RED]-q ;where p & p can be any nodes node A is known (A)<-[:ORANGE]-r->[:GREEN]-s ;where r & s can be any nodes node A is known

![figure][1]

https://lh5.googleusercontent.com/-1a41h63adqs/UaQ7B1qdAxI/AAAAAAAAAI4/2QjGS5pa1Zc/s1600/Presentation1.png

1
So, do you want to modify your graph according to the figure or just return a subgrap? Cypher does not return graphs right now, but it could return the paths making up that graph for you to merge on the client side into your target structure? - Peter Neubauer
No i don't want to modify the existing graph. i just want to know whether cypher returns graphs or not. But what i really want is the thing that you have mentioned finally. i want to return paths making up a new graph and render it on client side. Can you provide a reference to follow to do that - Dinidu

1 Answers

0
votes

Try MATCH (n)-[r]->(m) WHERE n.property = "B" RETURN n,r,m. This will return the paths needed to make your graph.