title: How to increment a vertex property value in a TinkerPop graph
body: <p>How would I traverse through a graph and increment a value of a vertex property? Either by some fixed amount or by an amount in a property of an edge leading to it.</p>
  
  <p>eg. with the following graph:</p>
  
  <pre><code>gremlin&gt; graph = TinkerGraph.open()
  ==&gt;tinkergraph[vertices:0 edges:0]
  gremlin&gt; g = graph.traversal()
  ==&gt;graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
  gremlin&gt; a = g.addV('name','a','amount', 100).next()
  ==&gt;v[0]
  gremlin&gt; b = g.addV('name','b','amount', 200).next()
  ==&gt;v[3]
  gremlin&gt; c = g.addV('name','c','amount', 300).next()
  ==&gt;v[6]
  gremlin&gt; a.addEdge('fill', b, 'bonus', 20)
  ==&gt;e[9][0-drain-&gt;3]
  gremlin&gt; b.addEdge('fill', c, 'bonus', 40)
  ==&gt;e[10][3-drain-&gt;6]
  gremlin&gt; 
  </code></pre>
  
  <p>so</p>
  
  <p>1) How would I increment each vertex by <code>10</code>?</p>
  
  <p>at the end I want to have:</p>
  
  <pre><code>gremlin&gt; g.V().valueMap()
  ==&gt;[amount:[110],name:[a]]
  ==&gt;[amount:[210.0],name:[b]]
  ==&gt;[amount:[310.00],name:[c]]
  </code></pre>
  
  <p>Given the statement:</p>
  
  <pre><code>g.V(a).property('amount', X)
  </code></pre>
  
  <p>I guess I'm trying to do something like: </p>
  
  <pre><code>g.V(a).property('amount', g.V(a).values('amount').next()+10)
  </code></pre>
  
  <p>...but for all vertices in my graph. It looks like Tinkerpop2 had <code>loop()</code> and <code>it.object</code> that might have helped, but seems not in Tinkerpop3</p>
  
  <p>Edit: OK, I am closer, but not quite there:</p>
  
  <pre><code>gremlin&gt; g.V().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]
  </code></pre>
  
  <p>2) How would I increment each vertex by the value of the <code>bonus</code> property in the <code>fill</code> edge leading to it.</p>
  
  <p>at the end I want to have:</p>
  
  <pre><code>gremlin&gt; g.V().valueMap()
  ==&gt;[amount:[100],name:[a]]
  ==&gt;[amount:[220.0],name:[b]]
  ==&gt;[amount:[340.00],name:[c]]
  </code></pre>
  
  <p>I tried using a <code>sack</code> to do it, but couldn't quite work it out as a sack accumulates the data throughout the traversal. I tried to put the <code>withSack</code> within the <code>repeat</code> clause to try and create a new sack, but that didn't work. I don't see how I can 'pass' the value of a property from one vertex to an operation on the next vertex.</p>