Hi, it's the whole day that I'm reading and trying with gremlin, and
I've almost done what I'm looking for... I just need a last step which
I cannot figure it out.
Here's my problem: I've a weight value on the edges, it can be
positive or negative, I look from a vertex down to a deep level equal
to 3, but it's followed only if the weight value of the middle edges
is not present or is not negative (it's ok if it's negative and it's
the last edge). As return I'd like a list of the last edge's weight,
or maybe better a sum of all them (when there are more paths).
This is what I've achieved until now (from vertex A to B):
g.v(A).as('x').outE.inV.loop('x'){it.loops < 3}{
it.object.id ==
B}.simplePath.paths{it.weight}
this gives me: [null, -0.5, null]
the problem is that it also gives me (to a different B vertex): [null,
-0.5, null, null, null]
which is not correct, as the first edge is -0.5 it should not continue
So: [null, 0.1, null], [null, null, null], [null, -0.2, null], [null,
null, null, null, 0.3, null], [null, null, null, null, null, null],
[null, null, null, null, -0.4, null], they're all correct
[null, -0.1, null, null, ANYTHING, null] should be ignored
Considering this, it should return only the last weight, so [null,
0.1, null, null, -0.2, null] => -0.2
Or maybe even better a sum of the last weights for all the paths
returned: ([null, 0.1, null, -0.2, null], [null, 0.3, null], [null,
0.1, null, 0.1, null]) => 0.2
Do you have any idea what should I change in order to get this
behavior?