How would I go through the graph and increase the value of the vertex property? Either by any fixed amount, or by the quantity in the property of the edge leading to it.
eg. with the following schedule:
gremlin> graph = TinkerGraph.open() ==>tinkergraph[vertices:0 edges:0] gremlin> g = graph.traversal() ==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard] gremlin> a = g.addV('name','a','amount', 100).next() ==>v[0] gremlin> b = g.addV('name','b','amount', 200).next() ==>v[3] gremlin> c = g.addV('name','c','amount', 300).next() ==>v[6] gremlin> a.addEdge('fill', b, 'bonus', 20) ==>e[9][0-drain->3] gremlin> b.addEdge('fill', c, 'bonus', 40) ==>e[10][3-drain->6] gremlin>
So
1) How would I increase each vertex by 10 ?
In the end I want:
gremlin> gV().valueMap() ==>[amount:[110],name:[a]] ==>[amount:[210.0],name:[b]] ==>[amount:[310.00],name:[c]]
Given the statement:
gV(a).property('amount', X)
I think I'm trying to do something like:
gV(a).property('amount', gV(a).values('amount').next()+10)
... but for all the vertices in my graph. It looks like Tinkerpop2 had loop() and it.object that could help, but it seems not in Tinkerpop3
Edit: Ok, I'm closer, but not quite there:
gremlin> gV().as('x').property('amount', select('x').by('amount')+10) No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.plus() is applicable for argument types: (java.lang.Integer) values: [10] Possible solutions: sum(), take(int), sum(groovy.lang.Closure), is(java.lang.Object), use([Ljava.lang.Object;), drop(int) Type ':help' or ':h' for help. Display stack trace? [yN]
2) How would I increase each vertex by the value of the bonus property in the fill edge leading to it.
In the end I want:
gremlin> gV().valueMap() ==>[amount:[100],name:[a]] ==>[amount:[220.0],name:[b]] ==>[amount:[340.00],name:[c]]
I tried to use sack to do this, but could not fully process it, as the bag accumulates data during the crawl. I tried putting withSack in a repeat clause to try and create a new bag, but that didn't work. I donβt see how I can transfer the property value from one vertex to an operation on the next vertex.