Reputation: 10146
Given the following graph:
node[5]
with weight > 50
?node[5]
with label "knows"
, sorted by weight?Upvotes: 8
Views: 5464
Reputation: 7873
How do I get the nodes linked to node[5] with an edge with a label "knows" and a weight > 50 ?
g.v(5).outE('knows').filter{it.weight > 50}.inV
Depending on the relation/edge direction it might be "inE" instead of outE or "both" step then you will need to adjust the query since you will have edges in the other direction or edges in both directions...
How do I get the nodes related to node[5] with label "knows", sorted by weight?
g.v(5).outE('knows').filter{it.weight > 50}.sort{a,b -> a.weight <=> b.weight}.toList()._.inV
Upvotes: 10
Reputation: 1555
Not sure about Gremlin, but in Cypher it is:
START s=node(5) MATCH s-[r]-f WHERE r.weight > 50 RETURN f
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"
Upvotes: 12