0
votes

I have a simple graph with two vertices, having ids 'a' and 'b'.

I have assigned two edges from 'a' to 'b' where each edge has the label = "foo"

[1] gremlin> g.V('a').outE()

==>e[f4b4b71d-ca98-5302-3eb1-7f99a7e74081][a-foo->b]

==>e[98b4b71d-c8c9-4ca2-9fbe-2f58e33d25e4][a-foo->b]

Each of the edges has a property with key = "committed".

[2] gremlin> g.E().properties()

==>p[committed->2]

==>p[committed->1]

My question: I want to enumerate the edges and return their respective properties as in step [2], but how can I match the edge-properties in the results back to their respective edges (ids)? All I get back are the property key-value assignments; nothing that relates to an edge id.

Thanks,

Joel Stevick

1

1 Answers

2
votes

You should avoid returning graph elements like vertices and edges and instead transform your result to the specific form in which you need it. You could do that in a number of ways. In this case project() works nicely:

gremlin> g.V().outE().project('id','weight').by(id).by('weight')
==>[id:9,weight:0.4]
==>[id:7,weight:0.5]
==>[id:8,weight:1.0]
==>[id:10,weight:1.0]
==>[id:11,weight:0.4]
==>[id:12,weight:0.2]

or you could use valueMap() - on 3.4.0 you have the with() syntax:

gremlin> g.V().outE().valueMap('weight').with(WithOptions.tokens)
==>[id:9,label:created,weight:0.4]
==>[id:7,label:knows,weight:0.5]
==>[id:8,label:knows,weight:1.0]