How will I know, if two nodes are somehow connected in Cypher Neo4j -
i have graph depicts node , relationships, entity - references - entity.
i want list containing source entity , connected entity these 2 entities not directly connected connected somehow.
for example : - references -b , c - references - a, d - references - c. in case, want cypher qry return d - references - a.
the output :
a-b
c-a
d-c
c-b
d-a
d-b
cypher pattern matching in graphs. pattern interested in cover not a-b
a-c-d
. can using variable length match, e.g.:
match (n)-[*]-(m) return n.name, m.name
this assumes there name property on nodes, can returned. change other relevant property, or return n, m
if you're using browser visualization.
note match relationships regardless of direction, means you'll both a-d
, d-a
in result (and every other combination). if want match 1 direction, use:
match (n)-[*]->(m) return n.name, m.name
be careful these approaches - in small graphs, end matching huge number of combinations , cause neo4j, or application, die (due memory exhaustion, etc).
Comments
Post a Comment