Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort/filter nodes based on relation properties

Tags:

neo4j

gremlin

Given the following graph:

enter image description here

  1. How do I get the nodes adjacent to node[5] with weight > 50?
  2. How do I get the nodes adjacent to node[5] with label "knows", sorted by weight?
like image 687
zsquare Avatar asked Feb 13 '12 13:02

zsquare


1 Answers

Not sure about Gremlin, but in Cypher it is:

1:

START s=node(5) MATCH s-[r]-f WHERE r.weight > 50 RETURN f

2:

START s=node(5) MATCH s-[r:knows]-f RETURN f ORDER BY r.weight

If you care about the direction of the relationship, put arrows on the relationships, like "s-[]->f" or "s<-[]-f"

like image 114
Josh Adell Avatar answered Sep 28 '22 07:09

Josh Adell