neo4j - Cypher: Graph a nodes's connections 3 deep -
given node, want use d3 graph it, , it's neighborhood 3 deep.
the best strategy can come is:
query1: match (n)-[r]-(m) id(n) in [501] return n, r, m
then results, in app, collect of m's id's, put new id's in in clause (remove ones i've done), , repeat query.
query2: match (n)-[r]-(m) id(n) in [502,511,1111] return n, r, m query3: match (n)-[r]-(m) id(n) in [512,519,1116,1130] return n, r, m
note: don't know id's of 2nd query till after 1st, etc.
but means running 3 query's, , lost of io shuffling.
is there better better way this? feel i'm doing work in app, when should done in cypher. looked in d3 examples, didn't see kind of query.
thanks!
mike
you can run following query or similar, concept should easy understand:
match (n)-[r*1..3]-(m) id(n) in [501] return n, r, m
where *1..3
means match 1 3 relationships away n node
this way single query , should faster running 3 separate queries
Comments
Post a Comment